# WebSockets - connection keeps closing after 1 minute

**URL:** <https://www.ruby-forum.com/t/websockets-connection-keeps-closing-after-1-minute/226763>\
**Category:** NGINX\
**Created:** [February 20, 2013, 4:58pm UTC](https://www.ruby-forum.com/t/websockets-connection-keeps-closing-after-1-minute/226763 "2013-02-20T16:58:13Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![WGH](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/ba9def/32.png) [@WGH](https://www.ruby-forum.com/u/WGH)\
**Post date:** [February 20, 2013, 4:58pm UTC](https://www.ruby-forum.com/t/websockets-connection-keeps-closing-after-1-minute/226763/1 "2013-02-20T16:58:13Z")

</div>

Hello!

My WebSocket connections keep closing after precisely one minute.  
The configuration is the same as provided in that commit comment.  
[http://trac.nginx.org/nginx/changeset/5073/nginx](http://trac.nginx.org/nginx/changeset/5073/nginx)

Direct connections to the server (without intermediate nginx) happily  
live  
for many hours.

What option should I change to fix that?

Posted at Nginx Forum:

> **[WebSockets - connection keeps closing after 1 minute](https://forum.nginx.org/read.php?2,236382,236382#msg-236382)**
>
> Hello! My WebSocket connections keep closing after precisely one minute. The configuration is the same as provided in that commit comment. http://trac.nginx.org/nginx/changeset/5073/nginx Direct connections to the server (without intermediate nginx)...

---

<div class="post-metadata">

**Author:** ![WGH](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/ba9def/32.png) [@WGH](https://www.ruby-forum.com/u/WGH)\
**Post date:** [February 20, 2013, 5:07pm UTC](https://www.ruby-forum.com/t/websockets-connection-keeps-closing-after-1-minute/226763/2 "2013-02-20T17:07:00Z")

</div>

Hello!

On Wed, Feb 20, 2013 at 10:57:40AM -0500, WGH wrote:

> Hello!
> 
> My WebSocket connections keep closing after precisely one minute.  
> The configuration is the same as provided in that commit comment.  
> [http://trac.nginx.org/nginx/changeset/5073/nginx](http://trac.nginx.org/nginx/changeset/5073/nginx)
> 
> Direct connections to the server (without intermediate nginx) happily live  
> for many hours.
> 
> What option should I change to fix that?

There is proxy\_read\_timeout ([Module ngx\_http\_proxy\_module](http://nginx.org/r/proxy_read_timeout))  
which as well applies to WebSocket connections. You have to bump  
it if your backend do not send anything for a long time.  
Alternatively, you may configure your backend to send websocket  
ping frames periodically to reset the timeout (and check if the  
connection is still alive).

–  
Maxim D.

> **[F5 NGINX: Built for cloud-native apps. Ready for AI traffic.](https://www.f5.com/products/nginx)**
>
> Deliver modern applications with NGINX. Explore high-performance load balancing, API gateways, and web server solutions trusted by top global enterprises.

---

<div class="post-metadata">

**Author:** ![WGH](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/ba9def/32.png) [@WGH](https://www.ruby-forum.com/u/WGH)\
**Post date:** [February 20, 2013, 5:17pm UTC](https://www.ruby-forum.com/t/websockets-connection-keeps-closing-after-1-minute/226763/3 "2013-02-20T17:17:31Z")

</div>

## Maxim D. Wrote:

> There is proxy\_read\_timeout ([Module ngx\_http\_proxy\_module](http://nginx.org/r/proxy_read_timeout))  
> which as well applies to WebSocket connections. You have to bump  
> it if your backend do not send anything for a long time.  
> Alternatively, you may configure your backend to send websocket  
> ping frames periodically to reset the timeout (and check if the  
> connection is still alive).

Thanks, raising the timeout resolved the problem.

Posted at Nginx Forum:  
[http://forum.nginx.org/read.php?2,236382,236386#msg-236386](http://forum.nginx.org/read.php?2,236382,236386#msg-236386)
