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.5k stars 1.4k forks source link

unhold not working #2383

Open tanish20j opened 7 months ago

tanish20j commented 7 months ago

Describe the bug Cannot hear any sound on leg-A after I unhold it using uuid_hold. Can hear sound on leg-B. [ sending INVITE sdp(recvonly) instead of INVITE sdp(sendrecv) ] . Call fixed when:

  1. hold leg-A
  2. hold leg-B
  3. unhold leg-B
  4. unhold leg-A

To Reproduce Steps to reproduce the behavior:

  1. originate {origination_caller_id_number=XXX,origination_uuid=abcd}sofia/gateway/number1 &bridge({origination_caller_id_number=XXX,origination_uuid=dcba})sofia/gateway/number2
  2. uuid_hold toggle abcd
  3. uuid_hold toggle abcd

Expected behavior should send sip INVITE sdp(sendrecv) when unholding

Package version or git hash

Trace logs

freeswitch@internal> uuid_hold toggle abcd
Local SDP:
v=0
o=FreeSWITCH 1707287938 1707287940 IN IP4 172.23.187.237
s=FreeSWITCH
c=IN IP4 172.23.187.237
t=0 0
m=audio 18234 RTP/AVP 0 101
a=rtpmap:0 PCMU/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-15
a=ptime:20
a=sendrecv

send 1192 bytes to udp/[X.X.X.X]:5060 at 17:13:10.550086:
------------------------------------------------------------------------
INVITE sip:lucentNGFS-019740@X.X.X.X;transport=udp;x-fbi=stdn-6;x-afi=26 SIP/2.0
Via: SIP/2.0/UDP 172.23.187.237;rport;branch=z9hG4bKtHrcgtK4ZmaKj
Max-Forwards: 70
From: <sip:origination_caller_id_number@PSTN>;tag=cjaaKmDHv3r5c
To: <sip:number1@PSTN>;tag=652f81cb-65c36cbc3b68208a-0052-15-ic-ibt-cacid170730617299667417006-lucentIBCF-106009
Call-ID: de841edf-4050-123d-d89e-506b8de5ec6d
CSeq: 79099295 INVITE
Contact: <sip:origination_caller_id_number@172.23.187.237:5060;transport=udp;gw=8044733340>
User-Agent: FreeSWITCH-mod_sofia/1.10.11-release~64bit
Allow: INVITE, ACK, BYE, CANCEL, OPTIONS, MESSAGE, INFO, UPDATE, REGISTER, REFER, NOTIFY
Require: timer
Supported: timer, path, replaces
Session-Expires: 7200;refresher=uas
Min-SE: 120
Privacy: none
Content-Type: application/sdp
Content-Disposition: session
Content-Length: 236
X-FS-Support: update_display,send_info
P-Asserted-Identity: <sip:+918044733341@PSTN>

v=0
o=FreeSWITCH 1707287938 1707287940 IN IP4 172.23.187.237
s=FreeSWITCH
c=IN IP4 172.23.187.237
t=0 0
m=audio 18234 RTP/AVP 0 101
a=rtpmap:0 PCMU/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-15
a=sendonly
a=ptime:20

recv 438 bytes from udp/[X.X.X.X]:5060 at 17:13:10.551559:
------------------------------------------------------------------------
SIP/2.0 100 Trying
Call-ID: de841edf-4050-123d-d89e-506b8de5ec6d
Via: SIP/2.0/UDP 172.23.187.237;received=172.23.187.237;branch=z9hG4bKtHrcgtK4ZmaKj;rport=5060
To: <sip:number1@PSTN>;tag=652f81cb-65c36cbc3b68208a-0052-15-ic-ibt-cacid170730617299667417006-lucentIBCF-106009
From: <sip:origination_caller_id_number@PSTN>;tag=cjaaKmDHv3r5c
CSeq: 79099295 INVITE
Date: Wed, 07 Feb 2024 11:43:10 GMT
Content-Length: 0

2024-02-07 17:13:10.556329 96.87% [DEBUG] sofia.c:7493 Channel sofia/external/number1 entering state [calling][0]
recv 1053 bytes from udp/[X.X.X.X]:5060 at 17:13:10.613891:
------------------------------------------------------------------------
SIP/2.0 200 OK
Call-ID: de841edf-4050-123d-d89e-506b8de5ec6d
Via: SIP/2.0/UDP 172.23.187.237;received=172.23.187.237;branch=z9hG4bKtHrcgtK4ZmaKj;rport=5060
To: <sip:number1@PSTN>;tag=652f81cb-65c36cbc3b68208a-0052-15-ic-ibt-cacid170730617299667417006-lucentIBCF-106009
From: <sip:origination_caller_id_number@PSTN>;tag=cjaaKmDHv3r5c
CSeq: 79099295 INVITE
Require: timer
Accept: application/sdp
Contact: <sip:lucentNGFS-019740@X.X.X.X;transport=udp;x-fbi=stdn-6;x-afi=26>
Content-Type: application/sdp
P-Charging-Vector: icid-value=9a65e9bd374f1a35ab60025ec8512c5b;orig-ioi=PSTN;term-ioi=IMS.MNC045.MCC404.3GPPNETWORK.ORG
Session-Expires: 7200;refresher=uas
Supported: timer
Content-Length: 316

v=0
o=LucentIBCF 340923370 340923371 IN IP4 ABC
s=-
c=IN IP4 10.2.13.245
t=0 0
a=recvonly
m=audio 42002 RTP/AVP 0 101
c=IN IP4 10.2.13.245
b=RR:3000
b=RS:1000
a=rtpmap:0 PCMU/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-15
a=maxptime:40

2024-02-07 17:13:10.616321 96.87% [DEBUG] sofia.c:7493 Channel sofia/external/number1 entering state [completing][200]
2024-02-07 17:13:10.616321 96.87% [DEBUG] sofia.c:7503 Remote SDP:
v=0
o=LucentIBCF 340923370 340923371 IN IP4 ABC
s=-
c=IN IP4 10.2.13.245
t=0 0
a=recvonly
m=audio 42002 RTP/AVP 0 101
c=IN IP4 10.2.13.245
b=RR:3000
b=RS:1000
a=rtpmap:0 PCMU/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-15
a=maxptime:40

send 527 bytes to udp/[X.X.X.X]:5060 at 17:13:10.632117:
------------------------------------------------------------------------
ACK sip:lucentNGFS-019740@X.X.X.X;transport=udp;x-fbi=stdn-6;x-afi=26 SIP/2.0
Via: SIP/2.0/UDP 172.23.187.237;rport;branch=z9hG4bKUtH5HN47vX05D
Max-Forwards: 70
From: <sip:origination_caller_id_number@PSTN>;tag=cjaaKmDHv3r5c
To: <sip:number1@PSTN>;tag=652f81cb-65c36cbc3b68208a-0052-15-ic-ibt-cacid170730617299667417006-lucentIBCF-106009
Call-ID: de841edf-4050-123d-d89e-506b8de5ec6d
CSeq: 79099295 ACK
Contact: <sip:origination_caller_id_number@172.23.187.237:5060;transport=udp;gw=8044733340>
Content-Length: 0
freeswitch@internal> uuid_hold toggle abcd

Local SDP:
v=0
o=FreeSWITCH 1707287938 1707287941 IN IP4 172.23.187.237
s=FreeSWITCH
c=IN IP4 172.23.187.237
t=0 0
m=audio 18234 RTP/AVP 0 101
a=rtpmap:0 PCMU/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-15
a=ptime:20
a=recvonly

send 1192 bytes to udp/[X.X.X.X]:5060 at 17:13:20.477173:
------------------------------------------------------------------------
INVITE sip:lucentNGFS-019740@X.X.X.X;transport=udp;x-fbi=stdn-6;x-afi=26 SIP/2.0
Via: SIP/2.0/UDP 172.23.187.237;rport;branch=z9hG4bKv3ayKgNBt6prS
Max-Forwards: 70
From: <sip:origination_caller_id_number@PSTN>;tag=cjaaKmDHv3r5c
To: <sip:number1@PSTN>;tag=652f81cb-65c36cbc3b68208a-0052-15-ic-ibt-cacid170730617299667417006-lucentIBCF-106009
Call-ID: de841edf-4050-123d-d89e-506b8de5ec6d
CSeq: 79099296 INVITE
Contact: <sip:origination_caller_id_number@172.23.187.237:5060;transport=udp;gw=8044733340>
User-Agent: FreeSWITCH-mod_sofia/1.10.11-release~64bit
Allow: INVITE, ACK, BYE, CANCEL, OPTIONS, MESSAGE, INFO, UPDATE, REGISTER, REFER, NOTIFY
Require: timer
Supported: timer, path, replaces
Session-Expires: 7200;refresher=uas
Min-SE: 120
Privacy: none
Content-Type: application/sdp
Content-Disposition: session
Content-Length: 236
X-FS-Support: update_display,send_info
P-Asserted-Identity: <sip:+918044733341@PSTN>

v=0
o=FreeSWITCH 1707287938 1707287941 IN IP4 172.23.187.237
s=FreeSWITCH
c=IN IP4 172.23.187.237
t=0 0
m=audio 18234 RTP/AVP 0 101
a=rtpmap:0 PCMU/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-15
a=recvonly
a=ptime:20

2024-02-07 17:13:20.476321 96.97% [DEBUG] sofia.c:7493 Channel sofia/external/number1 entering state [calling][0]
2024-02-07 17:13:20.476321 96.97% [DEBUG] switch_core_io.c:941 (sofia/external/number1) Callstate Change UNHELD -> ACTIVE
2024-02-07 17:13:20.476321 96.97% [DEBUG] switch_ivr_play_say.c:2010 done playing file local_stream://moh
recv 438 bytes from udp/[X.X.X.X]:5060 at 17:13:20.478471:
------------------------------------------------------------------------
SIP/2.0 100 Trying
Call-ID: de841edf-4050-123d-d89e-506b8de5ec6d
Via: SIP/2.0/UDP 172.23.187.237;received=172.23.187.237;branch=z9hG4bKv3ayKgNBt6prS;rport=5060
To: <sip:number1@PSTN>;tag=652f81cb-65c36cbc3b68208a-0052-15-ic-ibt-cacid170730617299667417006-lucentIBCF-106009
From: <sip:origination_caller_id_number@PSTN>;tag=cjaaKmDHv3r5c
CSeq: 79099296 INVITE
Date: Wed, 07 Feb 2024 11:43:20 GMT
Content-Length: 0

recv 1053 bytes from udp/[X.X.X.X]:5060 at 17:13:20.576191:
------------------------------------------------------------------------
SIP/2.0 200 OK
Call-ID: de841edf-4050-123d-d89e-506b8de5ec6d
Via: SIP/2.0/UDP 172.23.187.237;received=172.23.187.237;branch=z9hG4bKv3ayKgNBt6prS;rport=5060
To: <sip:number1@PSTN>;tag=652f81cb-65c36cbc3b68208a-0052-15-ic-ibt-cacid170730617299667417006-lucentIBCF-106009
From: <sip:origination_caller_id_number@PSTN>;tag=cjaaKmDHv3r5c
CSeq: 79099296 INVITE
Require: timer
Accept: application/sdp
Contact: <sip:lucentNGFS-019740@X.X.X.X;transport=udp;x-fbi=stdn-6;x-afi=26>
Content-Type: application/sdp
P-Charging-Vector: icid-value=9a65e9bd374f1a35ab60025ec8512c5b;orig-ioi=PSTN;term-ioi=IMS.MNC045.MCC404.3GPPNETWORK.ORG
Session-Expires: 7200;refresher=uas
Supported: timer
Content-Length: 316

v=0
o=LucentIBCF 340923370 340923372 IN IP4 ABC
s=-
c=IN IP4 10.2.13.245
t=0 0
a=sendonly
m=audio 42002 RTP/AVP 0 101
c=IN IP4 10.2.13.245
b=RR:3000
b=RS:1000
a=rtpmap:0 PCMU/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-15
a=maxptime:40

2024-02-07 17:13:20.576326 96.97% [DEBUG] sofia.c:7493 Channel sofia/external/number1 entering state [completing][200]
2024-02-07 17:13:20.576326 96.97% [DEBUG] sofia.c:7503 Remote SDP:
v=0
o=LucentIBCF 340923370 340923372 IN IP4 ABC
s=-
c=IN IP4 10.2.13.245
t=0 0
a=sendonly
m=audio 42002 RTP/AVP 0 101
c=IN IP4 10.2.13.245
b=RR:3000
b=RS:1000
a=rtpmap:0 PCMU/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-15
a=maxptime:40

send 527 bytes to udp/[X.X.X.X]:5060 at 17:13:20.592080:
------------------------------------------------------------------------
ACK sip:lucentNGFS-019740@X.X.X.X;transport=udp;x-fbi=stdn-6;x-afi=26 SIP/2.0
Via: SIP/2.0/UDP 172.23.187.237;rport;branch=z9hG4bKXc4pNB6eQFDBN
Max-Forwards: 70
From: <sip:origination_caller_id_number@PSTN>;tag=cjaaKmDHv3r5c
To: <sip:number1@PSTN>;tag=652f81cb-65c36cbc3b68208a-0052-15-ic-ibt-cacid170730617299667417006-lucentIBCF-106009
Call-ID: de841edf-4050-123d-d89e-506b8de5ec6d
CSeq: 79099296 ACK
Contact: <sip:origination_caller_id_number@172.23.187.237:5060;transport=udp;gw=8044733340>
Content-Length: 0
tanish20j commented 6 months ago

I want to share an update on the issue I was facing with a specific telecom provider. The issue was caused by the SDP from the gateway, which had the following format `

v=0 o=LucentIBCF 50839308 50839309 IN IP4 imsgroup0-328-0000008.kkp33.ims.mnc045.mcc404.3gppnetwork.org s=- c=IN IP4 10.2.13.242 t=0 0 a=recvonly m=audio 29518 RTP/AVP 0 101 c=IN IP4 10.2.13.242 b=RR:3000 b=RS:1000 a=rtpmap:0 PCMU/8000 a=rtpmap:101 telephone-event/8000 a=fmtp:101 0-15 a=maxptime:40

`

As you can see, there is only a Session Attribute (a) but no Media Attribute (a) for the media direction. This made thesdp_session() function create sdp->sdp_attributes->a_nameand sdp->sdp_media->m_mode with the value recvonly in src/switch_core_media.c

I temporarily fixed this issue by adding a check in the for (attr = sdp->sdp_attributes; attr; attr = attr->a_next) { to skip else if (!strcasecmp(attr->a_name, <flow direction>) && m->m_mode != <flow direction>)

Is this the correct behavior of the sdp_session() function? Should I submit a pull request for this fix or should I report this issue to sofia-sip instead?

tanish20j commented 6 months ago

I checked test_sdp in sofia-sip, it is working as expected. I think FS is not handling SDP properly when it has Session Attribute (a) instead of Media Attribute (a)

tanish20j commented 6 months ago

Related PR