Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Heroku WebSocket connection timeout

I have a Play Framework application, serving as a WebSocket server, running on Heroku and some WebSocket clients (chat-like application).

I noticed that Heroku closes each connection after 55 seconds of inactivity and I want to prevent this so I thought about creating a mechanism in my Play application that sends some kind of "ping" to each client in order to keep the connections alive.

I am just wondering if this is the way to go? Am I am missing something crucial here?

Best regards

like image 873
Anton Avatar asked Apr 03 '14 19:04

Anton


People also ask

Does WebSocket have timeout?

A WebSocket times out if no read or write activity occurs and no Ping messages are received within the configured timeout period. The container enforces a 30-second timeout period as the default. If the timeout period is set to -1 , no timeout period is set for the connection.

Does Heroku allow Websockets?

It gives you the flexibility of a TCP connection with the additional security model and meta data built into the HTTP protocol. For more details on the WebSocket protocol refer to RFC 6455, which is the version supported on Heroku.


1 Answers

I am just wondering if this is the way to go?

Yes. Here's what Heroku writes

The normal Heroku HTTP routing timeout rules apply to the WebSocket labs feature. Either client or server can prevent the connection from idling by sending an occasional ping packet over the connection.

https://devcenter.heroku.com/articles/heroku-labs-websockets#timeouts

like image 99
Prinzhorn Avatar answered Sep 23 '22 21:09

Prinzhorn