Long running websocket connections and timeouts

I’m trying to debug code that uses ARI. My problem is that the connection is being disconnected after 5 minutes of inactivity.

I can connect with wscat to asterisk and let it run without interaction and eventually I will get:

Disconnected (code: 1006, reason: "")

And the following on the asterisk shell:

[2020-12-09 12:53:44] ERROR[14095]: res_http_websocket.c:567 ws_safe_read: Error reading from web socket: Connection reset by peer
[2020-12-09 12:53:44] WARNING[14095]: ari/ari_websockets.c:126 ast_ari_websocket_session_read: WebSocket read error: Connection reset by peer

Does this sound like a timeout issue on the side of asterisk? If so, is it configurable? I’m also investigating if this could be due to a firewall.

Further investagion about Websocket status codes reveals that 1006 means:

**Reserved.** Used to indicate that a connection was closed abnormally (that is, with no close frame being sent) when a status code is expected.

It gives me the impression that this is something outside of asterisk, but I’m not so sure about that.

Yes your TCP timeouts can be on your OS or firewall - sometimes you can adjust these. But maybe add a ping/pong type message in to your code to keep the door open.