Hello. Asterisk 16.13.0 please could somebody help me to understand what’s cause of following issue. Sometimes webrtc client socket connections closed:
[
Dec 1 09:00:48] NOTICE[458451]: res_pjsip/pjsip_transport_management.c:170 idle_sched_cb: Shutting down transport 'WS to 127.0.0.1:37938' since no request was received in 32 seconds
[Dec 1 09:00:48] WARNING[792000]: res_http_websocket.c:559 ws_safe_read: Web socket closed abruptly
I’m using nginx server as proxy for websocket connection with settings
There is built in functionality to terminate Websocket connections which open and send nothing. That appears to have happened. Have you confirmed the client actually sent something?
I’ll try to check from client side. JS Client must sent ping websocket packets everytime to save connection open? can I increase interval of 32 second using some options?
It requires SIP traffic to flow, once that happens then it will not be disconnected. The time is based on SIP timers and I would not recommend modifying that.
so, if I’ll change qualify_frequency = 20
and asterisk will send options packets every 20 seconds and receive 200 OK responses from client(it will help to keep SIP interconnection longer time), how do you think is it good solution or not?
OPTIONS will only be sent to a registered client, which would require the client to send a REGISTER to Asterisk. That REGISTER would stop this disconnection from occurring in the first place. Only 1 SIP packet has to be sent from the client to stop the disconnection.
It’s still not a bad idea to leave the qualify at around 60.
If your connections are disconnecting abruptly after say around 120 seconds, it could be the router. If its totally random, then it’s probably your client internet connections or something on your network (like a congested switch).
I have seen some routers close persistent connections if they consider the connection to be “idle”, make sure this idle timeout is higher than your qualify. Remember what websocket connections are asking routers to do is keep a TCP connection open for a long time regardless of traffic… something that they are traditionally not used to.
The only other place that will close the websocket connection is the browser, check the console for errors there.
So, the disconnection in question in the original post only occurs if there is a Websocket connection that has NEVER sent a SIP request. If it does send at least one SIP request, then that disconnection timer is terminated indefinitely for the connection.
From a general perspective of keeping the connection open in general - then qualify can potentially help with that, but it can also be browser side as @InnovateAsterisk said.
In Chrome, or whatever browser open the developer tools and select the network tab, there you need to find the /ws/ connection (it normally the one open for the longest, or you can filter by WS), then select it. The panel then shows “messages”, check that SIP messages are being sent to and receive from the asterisk server. These messages are the raw SIP messages, the same messages you would normally see in a wireshark trace or SIP history/debug in Asterisk.