freeswitch icon indicating copy to clipboard operation
freeswitch copied to clipboard

websocket fd leak when webpage closed during network break

Open ygxstar opened this issue 1 year ago • 12 comments

Describe the bug Using nginx for forward wss port 443 to freeswitch websocket local-IP port 5066, when the client network disconnected and connected quickly, but the web page using sip.js closed during this time. When the network is ok again, the nginx will try reset the websocket connection to freeswitch, but lead to fd leak issue. using lsof , the "protocol: TCP" fd will remains always. freeswitc 91 root 96u sock 0,7 0t0 157747872 protocol: TCP freeswitc 91 root 98u sock 0,7 0t0 161907744 protocol: TCP

To Reproduce Steps to reproduce the behavior:

  1. Using nginx for forward wss port 443 to freeswitch websocket port 5066,
  2. Open webpage using sip.js 0.21.2 with transportOptions: {server: sipConfig.wssServer, keepAliveInterval: 20, connectionTimeout: 35}, and SimpleUserOptions.userAgentOptions.contactParams: {transport:"ws"}
  3. the UA is connected and registed with Via: SIP/2.0/WS
  4. Shutdown WLAN connection in Windows 10 PC
  5. Close the webpage of the sip UA
  6. Reconnect the WLAN connection quicky. (should be less than 15s ,otherwise the bug not happen)
  7. keep tacking the fd in bash while loop, lsof -p pidof freeswitch |grep "protocol: TCP" , the count of fd leak increase by 2

Expected behavior No websocket fd leak

Package version or git hash fs 1.10.9 and fs 1.10.10 using Debian 11.7 kenel 5.10.149-2

attachemt 01 is tcpdump pcap file of the ws part ,from nginx to freeswitch. And 02 for both the wss and ws side.

[fd-leak01.zip](https://github.com/signalwire/freeswitch/files/13581580/fd-leak01.zip)
[fd-leak02.zip](https://github.com/signalwire/freeswitch/files/13582507/fd-leak02.zip)

ygxstar avatar Dec 06 '23 11:12 ygxstar

微信截图_20231206191251

ygxstar avatar Dec 06 '23 11:12 ygxstar

what sofia-sip library version are you using?

andywolk avatar Dec 06 '23 11:12 andywolk

libsofia-sip-ua0 1.13.16-125~dfc7095f4c~bullseye

ygxstar avatar Dec 06 '23 11:12 ygxstar

It is old. You must update libsofia

andywolk avatar Dec 06 '23 11:12 andywolk

and libsofia-sip-ua0 1.13.17-128~6198851a61~bullseye

ygxstar avatar Dec 06 '23 11:12 ygxstar

please try using the latest freeswitch master and the latest sofia-sip

andywolk avatar Dec 06 '23 11:12 andywolk

I am using the official debian bullseye release oflibfreeswitch1/testing,now 1.10.10~release~24~4cb05e7f4a~bullseye-1~bullseye+1 and libsofia-sip-ua0/testing,now 1.13.17-128~6198851a61~bullseye . Not compiled by source. You mean the latest master branch of fs or sofia-sip may be ok?

ygxstar avatar Dec 06 '23 11:12 ygxstar

Still same issue, Should I push this issue to sofia project?

ygxstar avatar Feb 06 '24 13:02 ygxstar

Is it fixed now? Version 1.8.6 encounters the same problem.

2954456878 avatar May 24 '24 05:05 2954456878

The latest freeswitch master (1.10.10) and the latest sofia-sip(1.13.17) still have this problem

2954456878 avatar May 24 '24 08:05 2954456878

However since the fixes in sofia-sip 1.13.17 it should no longer be necessary to stick nginx in front of freeswitch for this as the problems that solution was to bypass have been fixed.

themsley-voiceflex avatar May 24 '24 12:05 themsley-voiceflex

This problem has been fixed in the latest version, no need to use nginx proxy wss port

2954456878 avatar May 25 '24 01:05 2954456878