versatica / JsSIP

JsSIP, the JavaScript SIP library
https://jssip.net
Other
2.39k stars 737 forks source link

SDP is cut off between recieving 200 OK and the sdp event being emitted #853

Open CameronJYoung opened 3 months ago

CameronJYoung commented 3 months ago

Hello! Apologies if i'm putting this in the wrong place (I was going to start in the JSSIP mail group but it looks like it's been overrun with spam). I think I have a potential bug with JSSIP where the SDP being received in the 200 OK response looks to be cut off in the RTCSession "sdp" event. I'm aware it could be a problem with my SDP but I've enabled JSSIP debug logs and I can't see any errors indicating what could be wrong with the SDP itself. Here's the full logs:

jssip-logs.txt

I'm using JsSIP v3.10.1

As you can see it recieves a 200 OK for the INVITE

 SIP/2.0 200 OK
    Via: SIP/2.0/WSS REDACTEDHOSTNAME;rport=5063;received=127.0.0.1;branch=z9hG4bK3518430
    Call-ID: v853rkfqi5smr01om638
    From: <sip:+447700900040@REDACTEDHOSTNAME>;tag=58ofabaaig
    To: <sip:+447700900637@REDACTEDHOSTNAME>;tag=60586025-d850-4e85-8b33-ea3a341c49af
    CSeq: 4854 INVITE
    Server: SOMESERVER
    Allow: OPTIONS, REGISTER, SUBSCRIBE, NOTIFY, PUBLISH, INVITE, ACK, BYE, CANCEL, UPDATE, PRACK, MESSAGE, REFER
    Contact: <sip:28.164.90.240:5061>
    Supported: 100rel, timer, replaces, norefersub
    Session-Expires: 90;refresher=uac
    Require: timer
    Content-Type: application/sdp
    Content-Length: 624

    v=0
    o=- 187479965 4 IN IP4 10.39.7.65
    s=Asterisk
    c=IN IP4 10.39.7.65
    t=0 0
    m=audio 31634 UDP/TLS/RTP/SAVPF 8 126
    a=maxptime:150
    a=mid:0
    a=rtpmap:8 PCMA/8000
    a=rtpmap:126 telephone-event/8000
    a=sendrecv
    a=rtcp:31635
    a=setup:passive
    a=fingerprint:sha-256 BB:6A:AC:45:29:0B:47:84:B8:5B:0F:0B:E6:7D:6A:0D:3B:5B:D4:02:D8:0B:E3:C5:3B:0E:04:33:FC:DD:7B:95
    a=tls-id:7f5e545994815781254afbf6e9090865
    a=ptime:20
    a=ice-ufrag:FHk2EC0f
    a=ice-pwd:WdwRwem38dwAqj5PLEbXwjpPzl
    a=ice-options:trickle
    a=candidate:rfHjyG3GnNMOgcbB 1 UDP 2130706431 10.39.7.65 31634 typ host
    a=candidate:rfHjyG3GnNMOgcbB 2 UDP 2130706430 10.39.7.65 31635 typ host
    a=end-of-candidates

And then a moment later the "sdp" event get's fired and it's missing the last line and a half

RTCSession sdp from event:

v=0
    o=- 187479965 4 IN IP4 10.39.7.65
    s=Asterisk
    c=IN IP4 10.39.7.65
    t=0 0
    m=audio 31634 UDP/TLS/RTP/SAVPF 8 126
    a=maxptime:150
    a=mid:0
    a=rtpmap:8 PCMA/8000
    a=rtpmap:126 telephone-event/8000
    a=sendrecv
    a=rtcp:31635
    a=setup:passive
    a=fingerprint:sha-256 BB:6A:AC:45:29:0B:47:84:B8:5B:0F:0B:E6:7D:6A:0D:3B:5B:D4:02:D8:0B:E3:C5:3B:0E:04:33:FC:DD:7B:95
    a=tls-id:7f5e545994815781254afbf6e9090865
    a=ptime:20
    a=ice-ufrag:FHk2EC0f
    a=ice-pwd:WdwRwem38dwAqj5PLEbXwjpPzl
    a=ice-options:trickle
    a=candidate:rfHjyG3GnNMOgcbB 1 UDP 2130706431 10.39.7.65 31634 typ host
    a=candidate:rfHjyG3GnNMOgcbB 2 UDP 2130706430 10.3

After that JSSIP sends an ACK and then a BYE with:

Reason: SIP ;cause=488; text="Not Acceptable Here"

And an error from JSSIP after it sends the bye

%cJsSIP:WARN:RTCSession %cemit "peerconnection:setremotedescriptionfailed" [error:%o]%c +0ms color: #66CC00 color: inherit DOMException: Failed to execute 'setRemoteDescription' on 'RTCPeerConnection': Failed to parse SessionDescription. a=candidate:rfHjyG3GnNMOgcbB 2 UDP 2130706430 10.3 Invalid SDP line.
        at jssip.min.js:9:157630 color: #66CC00

If it is a problem with the SDP recieved in the 200 OK it might be a good place for a more descriptive log? Any additional information needed to help let me know.

PadScratchJohns commented 1 month ago

Hey there,

You might have fixed this already, but this looks like packet fragmentation issues.

As per: https://datatracker.ietf.org/doc/html/rfc4459

CameronJYoung commented 1 month ago

Hey there,

You might have fixed this already, but this looks like packet fragmentation issues.

As per: https://datatracker.ietf.org/doc/html/rfc4459

I can't imagine it's to do with packet fragmentation as JSSIP receives the "OK 200" with the full SDP. This implies the full message has already been received. Thanks