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.32k stars 1.38k forks source link

mod_sofia: with TLS gateway pinging never expires and no OPTIONS are sent after reseting the connection #2489

Open wmasilva opened 2 weeks ago

wmasilva commented 2 weeks ago

using TLS connection the gateway pinging status remains active and no options are sent after restarting the connection on the remote side.

Expires     3600
Freq        3600
Ping        1718360143
PingFreq    30
PingTime    53.34
PingState   1/1/1
State       NOREG
**Status    UP (ping)**
Uptime      265472s

From the other side OPTIONS are sent and FS replies with ACK correctly. Restarting the gateway in FS solves the issue.

wmasilva commented 2 weeks ago

hi,

I'm trying to reproduce it on a lab machine but i can't.. cant find the conditions to force it..

Searching in the code, the reason seams to be that the gateway was not identified or missing result from the OPTIONS:

In sofia_reg.c its set to 1 the value "pinging" before sending the "OPTIONS"

https://github.com/signalwire/freeswitch/blob/40a33e7bb7f64fbfdc5831efab6873a52f9f7d6d/src/mod/endpoints/mod_sofia/sofia_reg.c#L394

and it's reset at sofia.c when receiving the OPTIONS result:

https://github.com/signalwire/freeswitch/blob/40a33e7bb7f64fbfdc5831efab6873a52f9f7d6d/src/mod/endpoints/mod_sofia/sofia.c#L6507

I think that would be to ok to reset the pinging state directly in sofia_reg_check_gateway after a timeout or remove pinging control (we already have a ping_freq to avoid send simultaneous OPTIONS), what do you think is better?