Reputation: 89
I have the cowboy example eventsource running on a local Debian server. For the code please see --> https://github.com/ninenines/cowboy/tree/master/examples/eventsource
After about 60 seconds there is always a 'eventsource was closed' then a 'eventsource connected' message.
I am testing on the latest chrome browser on win10.
I cannot see any reason for this and I wondered if this something built into the SSE standard, that the connection is dropped at regular intervals.
The chrome debugger shows the following error message: GET http://192.168.1.100:8080/eventsource net::ERR_INCOMPLETE_CHUNKED_ENCODING 200 (OK)
Any thoughts?
MPC
Upvotes: 1
Views: 611
Reputation: 3509
You're most likely hitting the idle timeout.
You can change it with the following snippet in the cowboy example:
{ok, _} = cowboy:start_clear(http, [{port, 8080}], #{
idle_timeout => 15000,
env => #{dispatch => Dispatch}
}),
You have more information about ProtocolOpts in the cowboy doc
Upvotes: 2