Skip to content

Carefully manage Keep-Alive/Close connection headers in all examples#8966

Merged
normanmaurer merged 1 commit intonetty:4.1from
kachayev:fix-keep-alive-examples
Apr 2, 2019
Merged

Carefully manage Keep-Alive/Close connection headers in all examples#8966
normanmaurer merged 1 commit intonetty:4.1from
kachayev:fix-keep-alive-examples

Conversation

@kachayev
Copy link
Copy Markdown
Contributor

Motivation:

"Connection: close" header should be specified each time we're going to close an underlying TCP connection when sending HTTP/1.1 reply.

Modifications:

Introduces changes made in #8914 into the following examples:

  • WebSocket index page and WebSocket server handler
  • HelloWorld server
  • SPDY server handler
  • HTTP/1.1 server handler from HTTP/2 HelloWorld example
  • HTTP/1.1 server handler from tiles example

Result:

Keep-Alive connections management conforms with RFCs.

@netty-bot
Copy link
Copy Markdown

Can one of the admins verify this patch?

@normanmaurer
Copy link
Copy Markdown
Member

@netty-bot test this please

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kachayev one question... isn't this assuming that we are talking HTTP/1.1 ? I mean for 1.0 we would need to add the keep-alive imho

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, probably you're correct: we're responding with 1.1 but any 1.0 client would not be able to process this correctly.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mind fixing it ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, will do.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@normanmaurer Done! HttpStaticFileServerHandler was not that simple to rework because of exception catch branch. I also updated HttpUploadServerHandler to use HttpUtils. PTAL.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@normanmaurer Another question here, is it generally safe to close the connection after "write" operation instead of after "flush"?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes as the write is only be "executed" when the flush happens. Executed here means that it is "written to the socket".

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, cool! I'm checking just because this is the only place we're adding the listener to .write when in other cases to .writeAndFlush.

@kachayev kachayev force-pushed the fix-keep-alive-examples branch from d076863 to 9891f35 Compare March 31, 2019 00:26
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why ? It should work also with pipelining atm.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The request is reassigned on each channelRead0. If we read, let's say, 3 requests consistently and the exception has occurred when writing the 2nd response, we still rely on the properties of the last request. I'm not sure if it's possible to catch in this particular scenario as the processing of each request is pretty streamlined.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

got it... I think thats fine.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I think that works too. Do you think it's better to remove the comment to avoid confusion?

@normanmaurer
Copy link
Copy Markdown
Member

normanmaurer commented Apr 2, 2019 via email

Motivation:

"Connection: close" header should be specified each time we're going
to close an underlying TCP connection when sending HTTP/1.1 reply.

Modifications:

Introduces changes made in netty#8914 for the following examples:

* WebSocket index page and WebSocket server handler
* HelloWorld server
* SPDY server handler
* HTTP/1.1 server handler from HTTP/2 HelloWorld example
* HTTP/1.1 server handler from tiles example

Result:

Keep-Alive connections management conforms with RFCs.
@kachayev kachayev force-pushed the fix-keep-alive-examples branch from 9891f35 to f498f7d Compare April 2, 2019 05:35
@kachayev
Copy link
Copy Markdown
Contributor Author

kachayev commented Apr 2, 2019

@normanmaurer Done!

@normanmaurer normanmaurer added this to the 4.1.35.Final milestone Apr 2, 2019
@normanmaurer
Copy link
Copy Markdown
Member

@netty-bot test this please

@normanmaurer normanmaurer merged commit 5241123 into netty:4.1 Apr 2, 2019
normanmaurer pushed a commit that referenced this pull request Apr 2, 2019
…8966)

Motivation:

"Connection: close" header should be specified each time we're going
to close an underlying TCP connection when sending HTTP/1.1 reply.

Modifications:

Introduces changes made in #8914 for the following examples:

* WebSocket index page and WebSocket server handler
* HelloWorld server
* SPDY server handler
* HTTP/1.1 server handler from HTTP/2 HelloWorld example
* HTTP/1.1 server handler from tiles example

Result:

Keep-Alive connections management conforms with RFCs.
@normanmaurer
Copy link
Copy Markdown
Member

@kachayev merged thanks

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

Successfully merging this pull request may close these issues.

3 participants