Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Http3ServerExample & Http3ClientExample and python client questions #188

Closed
xtuyaowu opened this issue Feb 23, 2022 · 1 comment
Closed

Comments

@xtuyaowu
Copy link

xtuyaowu commented Feb 23, 2022

hi guys
My scenario is java server side other languages java, python, c++ keep long connect client, after client subscribe, server keep send data
Http3ServerExample & Http3ClientExample and python client question

1、Http3ServerExample what is the difference of Http3HeadersFrame frame and Http3DataFrame frame ?

when run Http3ClientExample come into Http3DataFrame frame when run python client into Http3HeadersFrame
@OverRide
protected void channelRead(ChannelHandlerContext ctx,
Http3HeadersFrame frame, boolean isLast) {
if (isLast) {
for(int i = 0; i<1000; i++) {
writeResponse(ctx, i);
}
}
ReferenceCountUtil.release(frame);
}

@OverRide
protected void channelRead(ChannelHandlerContext ctx,
Http3DataFrame frame, boolean isLast) {
if (isLast) {
for(int i = 0; i<1000; i++) {
writeResponse(ctx, i);
}
}
ReferenceCountUtil.release(frame);
}

2、server loop send data

1)java
java client if send .addListener(QuicStreamChannel.SHUTDOWN_OUTPUT) just receive one hello word
but if comment //send .addListener(QuicStreamChannel.SHUTDOWN_OUTPUT) can receive what server send

2)python
need execute .addListener(QuicStreamChannel.SHUTDOWN_OUTPUT)? what QuicStreamChannel.SHUTDOWN_OUTPUT WRITE_FIN mean?

3、python client how to keep long connect?

if python client send wss got error:

io.netty.incubator.codec.http3.Http3HeadersValidationException: Invalid HTTP/3 pseudo-header ':protocol' encountered.
at io.netty.incubator.codec.http3.Http3HeadersSink.validate(Http3HeadersSink.java:138)
at io.netty.incubator.codec.http3.Http3HeadersSink.accept(Http3HeadersSink.java:118)
at io.netty.incubator.codec.http3.Http3HeadersSink.accept(Http3HeadersSink.java:29)
at io.netty.incubator.codec.http3.QpackDecoder.decodeLiteral(QpackDecoder.java:390)
at io.netty.incubator.codec.http3.QpackDecoder.decode(QpackDecoder.java:135)
at io.netty.incubator.codec.http3.Http3FrameCodec.decodeHeaders(Http3FrameCodec.java:390)
at io.netty.incubator.codec.http3.Http3FrameCodec.decodeFrame(Http3FrameCodec.java:243)
at io.netty.incubator.codec.http3.Http3FrameCodec.decode(Http3FrameCodec.java:192)
at io.netty.handler.codec.ByteToMessageDecoder.decodeRemovalReentryProtection(ByteToMessageDecoder.java:507)
at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:446)
at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:276)
at io.netty.incubator.codec.http3.Http3FrameCodec.channelRead(Http3FrameCodec.java:122)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919)
at io.netty.incubator.codec.quic.QuicheQuicStreamChannel$QuicStreamChannelUnsafe.recv(QuicheQuicStreamChannel.java:900)
at io.netty.incubator.codec.quic.QuicheQuicStreamChannel$QuicStreamChannelUnsafe.beginRead(QuicheQuicStreamChannel.java:602)
at io.netty.channel.DefaultChannelPipeline$HeadContext.read(DefaultChannelPipeline.java:1362)
at io.netty.channel.AbstractChannelHandlerContext.invokeRead(AbstractChannelHandlerContext.java:686)
at io.netty.channel.AbstractChannelHandlerContext.read(AbstractChannelHandlerContext.java:671)
at io.netty.incubator.codec.http3.Http3FrameCodec.read(Http3FrameCodec.java:625)
at io.netty.channel.AbstractChannelHandlerContext.invokeRead(AbstractChannelHandlerContext.java:686)
at io.netty.channel.AbstractChannelHandlerContext.read(AbstractChannelHandlerContext.java:671)
at io.netty.incubator.codec.http3.Http3FrameTypeDuplexValidationHandler.read(Http3FrameTypeDuplexValidationHandler.java:85)
at io.netty.channel.AbstractChannelHandlerContext.invokeRead(AbstractChannelHandlerContext.java:686)
at io.netty.channel.AbstractChannelHandlerContext.read(AbstractChannelHandlerContext.java:671)
at io.netty.channel.DefaultChannelPipeline.read(DefaultChannelPipeline.java:1004)
at io.netty.channel.DefaultChannelPipeline.read(DefaultChannelPipeline.java:46)
at io.netty.incubator.codec.quic.QuicheQuicStreamChannel.read(QuicheQuicStreamChannel.java:287)
at io.netty.incubator.codec.quic.QuicheQuicStreamChannel.read(QuicheQuicStreamChannel.java:51)
at io.netty.channel.DefaultChannelPipeline$HeadContext.readIfIsAutoRead(DefaultChannelPipeline.java:1422)
at io.netty.channel.DefaultChannelPipeline$HeadContext.channelActive(DefaultChannelPipeline.java:1400)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelActive(AbstractChannelHandlerContext.java:230)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelActive(AbstractChannelHandlerContext.java:216)
at io.netty.channel.DefaultChannelPipeline.fireChannelActive(DefaultChannelPipeline.java:895)
at io.netty.incubator.codec.quic.QuicheQuicStreamChannel$QuicStreamChannelUnsafe.register(QuicheQuicStreamChannel.java:474)
at io.netty.channel.SingleThreadEventLoop.register(SingleThreadEventLoop.java:87)
at io.netty.channel.SingleThreadEventLoop.register(SingleThreadEventLoop.java:81)
at io.netty.incubator.codec.quic.QuicheQuicChannel$1.onUnhandledInboundMessage(QuicheQuicChannel.java:439)

python core code:

async def get(self, url: str, headers: Optional[Dict] = None) -> Deque[H3Event]:
    """
    Perform a GET request.
    """
    return await self._request(
        HttpRequest(method="GET", url=URL(url), headers=headers)
    )

async def post(
    self, url: str, data: bytes, headers: Optional[Dict] = None
) -> Deque[H3Event]:
    """
    Perform a POST request.
    """
    return await self._request(
        HttpRequest(method="POST", url=URL(url), content=data, headers=headers)
    )

async def websocket(
    self, url: str, subprotocols: Optional[List[str]] = None
) -> WebSocket:
    """
    Open a WebSocket.
    """
    request = HttpRequest(method="CONNECT", url=URL(url))
    stream_id = self._quic.get_next_available_stream_id()
    websocket = WebSocket(
        http=self._http, stream_id=stream_id, transmit=self.transmit
    )

    self._websockets[stream_id] = websocket

    headers = [
        (b":method", b"CONNECT"),
        (b":scheme", b"https"),
        (b":authority", request.url.authority.encode()),
        (b":path", request.url.full_path.encode()),
        (b":protocol", b"websocket"),
        (b"user-agent", USER_AGENT.encode()),
        (b"sec-websocket-version", b"13"),
    ]
    if subprotocols:
        headers.append(
            (b"sec-websocket-protocol", ", ".join(subprotocols).encode())
        )
    self._http.send_headers(stream_id=stream_id, headers=headers)

    self.transmit()

    return websocket

4、can netty-incubator-codec-http3 support websocket?

@hyperxpro
Copy link

WebSocket is not implemented on HTTP/3 on this repository yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants