Need help: websocket proxy stops working after a while

Maxim Dounin mdounin at
Tue Jun 4 10:45:07 UTC 2013


On Mon, Jun 03, 2013 at 03:24:52PM -0700, Alder Network wrote:

>   I got nginx websocket proxy working but the socket would close
> in a minute or so. So I add
> proxy_read_timeout 180s;
> and it works within 3 minutes but closed the websocket after 3
> minutes, but it works OK before that. Why is that?
> BTW, I am using Nginx 1.4 now.

Much like with normal http, nginx will time out connection to the 
upstream server if it doesn't see any data from it.  If with a 
backend you use there are no data expected from the backend to a 
client, there are two possible solutions:

1) Send periodic ping frames from the backend. 

2) Configure higher proxy_read_timeout in a location where 
websocket connections are handled.

Maxim Dounin

More information about the nginx mailing list