signalwire / freeswitch

FreeSWITCH is a Software Defined Telecom Stack enabling the digital transformation from proprietary telecom switches to a versatile software implementation that runs on any commodity hardware. From a Raspberry PI to a multi-core server, FreeSWITCH can unlock the telecommunications potential of any device.
https://freeswitch.com/#getting-started
Other
3.35k stars 1.38k forks source link

websocket fd leak when webpage closed during network break #2325

Open ygxstar opened 7 months ago

ygxstar commented 7 months ago

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 commented 7 months ago

微信截图_20231206191251

andywolk commented 7 months ago

what sofia-sip library version are you using?

ygxstar commented 7 months ago

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

andywolk commented 7 months ago

It is old. You must update libsofia

ygxstar commented 7 months ago

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

andywolk commented 7 months ago

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

ygxstar commented 7 months ago

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 commented 5 months ago

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

2954456878 commented 1 month ago

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

2954456878 commented 1 month ago

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

themsley-voiceflex commented 1 month ago

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.

2954456878 commented 1 month ago

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