HTTP/2 Client react on PUSH_PROMISE Frame

102 views
Skip to first unread message

lukeju...@gmail.com

unread,
Apr 14, 2016, 3:24:00 AM4/14/16
to Netty discussions
Hello,

after my Server now is able to send PUSH_PROMISE Frames. I try to push resources to the client. Therefore i want to know: How do i have to handle the PUSH_PROMISE on the Client. For now the Client answers automaticly with a GO_AWAY Frame.


Regards,
Luke

Julien Viet

unread,
Apr 14, 2016, 3:26:20 AM4/14/16
to ne...@googlegroups.com
you need to handle the push promise with the Http2FrameListener onPushPromiseRead and I think then there is nothing else special to do except receive the headers / data frames for this new stream.

--
You received this message because you are subscribed to the Google Groups "Netty discussions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to netty+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/netty/eea5a347-fe94-4dcc-8ac5-d0a63cb863c0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

lukeju...@gmail.com

unread,
Apr 14, 2016, 3:48:17 AM4/14/16
to Netty discussions
Thank you again. Can I simply add the Http2FrameListener to the Client Pipeline?

Julien Viet

unread,
Apr 14, 2016, 4:04:37 AM4/14/16
to ne...@googlegroups.com
it needs to be registered against the Http2ConnectionDecoder

lukeju...@gmail.com

unread,
Apr 14, 2016, 4:08:35 AM4/14/16
to Netty discussions
Ok, can't I use a Class extends Http2ConnectionHandler implements Http2FrameListener to handle PUSH_PROMISES?

lukeju...@gmail.com

unread,
Apr 14, 2016, 4:31:43 AM4/14/16
to Netty discussions
I have a problem to find the right place to add the Http2FrameListenere on netty http2 client example (https://github.com/netty/netty/tree/4.1/example/src/main/java/io/netty/example/http2/helloworld/client)

You may have a hint for me?

Regards and thank you!

Julien Viet

unread,
Apr 14, 2016, 4:35:30 AM4/14/16
to ne...@googlegroups.com
this client uses an adapter of HTTP/1.1 on top of HTTP/2 so there is no way to do it this way.

Julien Viet

unread,
Apr 14, 2016, 4:36:13 AM4/14/16
to ne...@googlegroups.com
actually what I said is stupid :-), HTTP/1.1 is used for the Upgrade

let me look

Julien Viet

unread,
Apr 14, 2016, 4:40:15 AM4/14/16
to ne...@googlegroups.com
actually no, I was right.

this example does not use the HTTP/2 api and instead the HTTP/1.1 codec :

Process {@link io.netty.handler.codec.http.FullHttpResponse} translated from HTTP/2 frames

so you need to look elsewhere.

lukeju...@gmail.com

unread,
Apr 14, 2016, 4:44:02 AM4/14/16
to Netty discussions
I thought that the 1.1 upgrade lets the Client Server Communication run over HTTP/2 Api :/

So i have to write a Client in HTTP/2 to use the HTTP/2 API. This is possible in netty?

Julien Viet

unread,
Apr 14, 2016, 4:53:12 AM4/14/16
to ne...@googlegroups.com
of course!

but client/server api are really similar once you get the HTTP2Connection and the codec.

you should first focus on setting up an Http2Connection in the client using the Http2ConnectionBuilder and then after register your frame listener

lukeju...@gmail.com

unread,
Apr 14, 2016, 5:00:28 AM4/14/16
to Netty discussions
Okay,

i will try to set up the client on HTTP2.

I am using netty 4.1 RC7 btw.

A problem i figured out earlier was that the import static io.netty.handler.codec.http.HttpVersion.HTTP_1_1; is the highest Version i find. So i was not able to send GET or POST Requests over HTTP2....

So i have to set up a connection? And then i can sent POST / GETS via frames and streams manually?

Julien Viet

unread,
Apr 14, 2016, 5:04:18 AM4/14/16
to ne...@googlegroups.com
yes.

you make requests using the encoder .

you receive responses with the frame listener .

lukeju...@gmail.com

unread,
Apr 14, 2016, 5:13:02 AM4/14/16
to Netty discussions
Thank you. Can i answer you for further questions?

Julien Viet

unread,
Apr 14, 2016, 5:15:13 AM4/14/16
to ne...@googlegroups.com
I think you can post questions in this forum and people can reply, I will reply if I’m available and I can help you, otherwise others might as well!

Message has been deleted

lukeju...@gmail.com

unread,
Apr 15, 2016, 4:56:14 AM4/15/16
to Netty discussions
Now i am able to call the encoder from my main method

  Http2ResponseHandler http2responseHandler = initializer.http2responseHandler();
            http2responseHandler.encoder().writeFrame(ChannelHandlerContext ctx, byte frameType, int streamId, Http2Flags flags, ByteBuf payload, ChannelPromise promise)

now i have the question about the ChannelHandlerContext. I have non  in my main method. So where to create it?`because its needed to do the request...

lukeju...@gmail.com

unread,
Apr 15, 2016, 5:10:08 AM4/15/16
to Netty discussions
I changed it to this

ByteBuf payload = unreleasableBuffer(copiedBuffer(poststring, CharsetUtil.UTF_8));
http2responseHandler.encoder().writeFrame(ctx, Http2FrameTypes.HEADERS, streamId, new Http2Flags().priorityPresent(true) , payload, ctx.newPromise());

Now i recive

----------------OUTBOUND--------------------
[id: 0x1b3be271, L:/127.0.0.1:3152 - R:/127.0.0.1:8443] UNKNOWN: frameType=1, streamId=5, flags=32, length=46, bytes=7b2
022616374696f6e223a20226368616e6e656c5f666f725f70757368222c202273747265616d4964223a20357d

What means UNKNOWN: there Should be HEADERS ...

lukeju...@gmail.com

unread,
Apr 15, 2016, 7:10:00 AM4/15/16
to Netty discussions
you should first focus on setting up an Http2Connection in the client using the Http2ConnectionBuilder and then after register your frame listener

i didnt find the named  Http2ConnectionBuilder  :/

Julien Viet

unread,
Apr 15, 2016, 7:17:11 AM4/15/16
to ne...@googlegroups.com
I meant : AbstractHttp2ConnectionHandlerBuilder

this could have been named by Spring folks :-)

liuch...@gmail.com

unread,
Oct 11, 2018, 8:31:56 AM10/11/18
to Netty discussions
Hi luke

Have you resolved this issue? I also found this error.

Thanks.

在 2016年4月15日星期五 UTC+8下午5:10:08,lukeju...@gmail.com写道:
Reply all
Reply to author
Forward
0 new messages