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
Add more HTTP/1.1 timeout options (only idle_timeout missing in cowboy_http2) #1032
Comments
|
If the client does not send any data until timeout, then it is normal that the connection gets closed. Note that due to underlying changes in master, the current code does not perform the detection of data sent by the client, and therefore the timeout is always triggered. |
|
Yes.. I have no issue with close connection if client not send any data, |
|
Is the issue that if you set, say, 60s, that Cowboy closes the connection after 5s? |
|
Yes |
|
Ah understood. I'll have to take a look. |
|
Maybe I misunderstood the issue, but I tried: And it worked using master, rev c528d9b. |
|
This one is about loop handlers which have a different kind of timeout, that's not working on current master. |
|
OK so the old loop handler option is not needed anymore. HTTP/2 has its own timeout mechanism so it's perfectly fine to have a loop handler running forever (until the connection closes). We already have a timeout in HTTP/1.1 saying how long we have to wait between requests. But it's not working properly (it's closing the connection despite a request ongoing). What we will however need is a separate timeout in HTTP/1.1 to close the connection on client inactivity when there is a request ongoing. |
Cowboy 2 timeout if nothing is done in 5s dor now. Let set a larger timeout waiting for a proper fix cowboy. related issue: ninenines/cowboy#1032 (comment)
|
Well if loop the handler is a gen_server it has its default time out that can be configured in Erlang system, and I don't remember well but they can be also set to infinity in gen_server call arguments. |
|
I'm bitten by this bug. I don't know enough about cowboy's internal but what do you think about an internal command like It's not very elegant but it's a quick fix for |
|
Normal fix is simpler, just need to enable this timeout when there are no requests currently running. |
|
I have a patch fixing request_timeout and adding idle_timeout that I will push soon after I investigate why the process may not always exit (#1156). |
|
We now have request_timeout, idle_timeout and inactivity_timeout for HTTP/1.1. HTTP/2 is still missing idle_timeout. |
|
I am trying to understand SSE and Cowboy here. Thanks. |
|
You will need to tweak the timeout value for HTTP/1.1. It's not a problem for HTTP/2 as long as the client sends pings. The problem is that we can't reliably detect TCP connections being closed, so we need to rely on the data coming in + a timeout. If no data comes in (SSE) then we just close on timeout. Best to make sure your client reconnects. |
|
As usual I am using couple tools to test this. Web browsers have reconnect support implemented and I can even control reconnect time from SSE (retry parameter). Curl does not work so well here for me. Gun is really helpful as usual and I guess I would have to add some code for Gun to make it reconnect and listen again to SSE. One last question: Thanks. |
|
Yes, client. About not losing any events, that's why you have the Last-Event-ID header. When you reconnect you are supposed to put the last known ID there and the server resumes from that point. If you can't allow anything to be dropped you'll most likely need a complex solution involving storing these events to disk somewhere so you can replay if the client or the node goes down. |
|
FYI: 2.6 will include a way to increase the |
|
I've now added the idle_timeout option to HTTP/2 as well and it'll be part of 2.6 to be released next week. Closing, thanks! |
Hi ..
I try eventsource example, and experiment trying to change value of timeout, and seems it doesn't work. Server still close connection every 5 seconds.
The text was updated successfully, but these errors were encountered: