Sync Gateway is closing websocket changes feed connection after 5 minutes of inactivity

Hi all,

while implementing the Couchbase Sync Gateway changes feed using a websocket, we noticed that the sync gateway closes the connection after 5 minutes of inactivity. The sync gateway isn’t responding to WebSocket Ping frames (sent by our client) with a Pong, as it should (and is specified in RFC 6455), but with a normal TCP ACK message. Even when sending periodical Ping frames, the connection is closed after 5 minutes. We have found no official way to fix this problem, but we found a workaround which is working, but not elegant.

Workaround:
Even though the documentation says the heartbeat parameter only applies to feed=longpoll or feed=continuous, it is also possible to set it for feed=websocket connections. This leads to sync gateway sending periodical empty messages which keep the connections open, but each message will trigger the client’s “on message” callback and thus has to be handled (e.g. dropped).

Did we miss something, is this expected behaviour or is this a bug and will potentially be fixed in the future?

Thanks for your time and best regards

Under the hood, we use Go’s Websocket server implementation from golang.org/x/net, which should support handling of solicited and unsolicited ping frames by sending a pong response. The thing it doesn’t do out of the box is send its own ping frames to the other side of the connection, but in your case I’m not sure that’s a requirement, as long as we’re sending pong replies correctly.

Can you go into some more detail about what version of Sync Gateway you’re using, and in addition, a packet capture of what you’re seeing (TCP ACK instead of pong) ?

Thanks for your response!
We are using Sync Gateway 2.8.2-community (the couchbase docker hub image). We built the image 2 weeks ago.
Here is a screenshot of the packet capture. Sync gateway runs on 192.168.50.4:4984. There is no following WebSocket Pong frame being sent.


We use the Python websocket-client package on the client side.
If you need further information please let me know. Thank you for your help!