drachtio / drachtio-fsmrf

Drachtio freeswitch-based media resource function -- http://davehorton.github.io/drachtio-fsmrf
MIT License
48 stars 27 forks source link

SDP Cut off on Invite from Drachtio->FreeSwitch #66

Open lylepratt opened 1 year ago

lylepratt commented 1 year ago

We've begin leveraging TURN servers for our WebRTC connections, and it seems to have pushed us over some kind of limit on the size of the SDP that can be sent from Drachtio -> Freeswitch. We noticed because we began getting some SIP 400s sent back to us from Freeswitch. When the SDP is cut off in a particular spot that breaks parsing, then a 400 results. Usually it seems to work anyway though because what is getting cut off doesn't seem to matter.

In the drachtio logs, I see the 2 invites (a) one from wp#send which contains the full SDP (I've cut off some of it to save space) and (b) the Msg sent: log which is what is actually sent to FS. Also notice the 2 Content-Lengths are different.

Do you have any idea what could be causing this?

Correct invite

2022-12-28T21:15:45.219Z drachtio:agent wp#send 0.0.0.0:9022 - 8671#03878403-7a04-4122-9eef-a10b5f60eff9|sip||
INVITE sip:drachtio@104.131.19.169:5038 SIP/2.0
User-Agent: drachtio-fsmrf:d33ea6ce-4142-4585-9b61-a19c468267be
X-esl-outbound: 137.184.49.198:8103
Content-Length: 8452

v=0
o=- 85472555477210657 2 IN IP4 127.0.0.1
s=-
t=0 0
{.......... LOTS OF SDP ..... }
a=ssrc-group:FID 3683095972 3429814089
a=ssrc:3683095972 cname:OKoL/EIn4ZsuRc8D
a=ssrc:3683095972 msid:DkHMBAlVaOZNLJKkWbghoXzY3U61MFpRNPEW 3b3c6746-45c8-4554-86a0-88991e0f1109
a=ssrc:3429814089 cname:OKoL/EIn4ZsuRc8D
a=ssrc:3429814089 msid:DkHMBAlVaOZNLJKkWbghoXzY3U61MFpRNPEW 3b3c6746-45c8-4554-86a0-88991e0f1109

Cut off invite...notice the last line is cut

2022-12-28T21:15:45.221Z drachtio:agent <===9058#ed9ea344-3754-414f-99b7-e46b21533c9e|response|03878403-7a04-4122-9eef-a10b5f60eff9|OK|application|8866|tcp|104.131.19.169|5038|21:15:45.221075|54495c2e-c90d-464b-8b46-1e61cfe28138|Msg sent:|
INVITE sip:drachtio@104.131.19.169:5038 SIP/2.0
Via: SIP/2.0/TCP 137.184.49.198;branch=z9hG4bKj6a582gKg6a2H
Max-Forwards: 70
From: <sip:137.184.49.198:5060>;tag=rcDX375t8y55j
To: <sip:drachtio@104.131.19.169:5038>
Call-ID: a23eb86d-0197-123c-1585-0242ac110002
CSeq: 61577280 INVITE
Contact: <sip:137.184.49.198:5060>
User-Agent: drachtio-fsmrf:d33ea6ce-4142-4585-9b61-a19c468267be
Content-Type: application/sdp
Content-Length: 8384
X-esl-outbound: 137.184.49.198:8103

v=0
o=- 85472555477210657 2 IN IP4 127.0.0.1
s=-
t=0 0
{.......... LOTS OF SDP ..... }
a=ssrc-group:FID 3683095972 3429814089
a=ssrc:3683095972 cname:OKoL/EIn4ZsuRc8D
a=ssrc:3683095972 msid:DkHMBAlVaOZNLJKkWbghoXzY3U61MFpRNPEW 3b3c6746-45c8-4554-86a0-88991e0f1109
a=ssrc:3429814089 cname:OKoL/EIn4ZsuRc8D
a=ssrc:3429814089 msid:DkHMBAl      < ----- NOTICE THIS IS CUT OFF
brandonrobinson5060 commented 1 year ago

Perhaps something else worth mentioning, it seems the truncated INVITE always has a Content-Length of 8384. However, wasn't able to find anything in code that would account for this ceiling.

lylepratt commented 1 year ago

Wanted to also note that when this happens, it seems to eventually put Drachtio into a bad state where it stops responding to requests.

lylepratt commented 1 year ago

After looking at the code, it seems like its actually a drachtio-server issue. Let me know which I should keep open.

https://github.com/drachtio/drachtio-server/issues/247

davehorton commented 1 year ago

I don't think it is a drachtio server issue as it seems the message being sent over to drachtio server is truncated; ie truncation is not happening on drachtio server side

lylepratt commented 1 year ago

Not sure I understand what you mean. You mean the message sent over to drachtio-fsmrf? Drachtio server seems to get the Full Invite from the client (you can see this because drachtio-server logs the full invite), but when it is sent out from drachtio-server -> FSMRF, it gets cut off.

davehorton commented 1 year ago

I'm referring to this log snippet

2022-12-28T21:15:45.221Z drachtio:agent <===9058

which is from drachtio-srf.

If you are indicating that the full INVITE was sent over to drachtio-server from the app, but a truncated version went out, then yes it would be a drachtio-server bug. And we would want the full drachtio server debug log

lylepratt commented 1 year ago

Yes that seems to be the case.

Here is a full drachtio debug log starting with the INVITE from the client. The invite that gets sent to FreeSwitch is ID cefeb7b3-0246-123c-b286-0242ac110002 on line 1467 with length 8384. If you scroll up from there you'll see the original INVITE that is supposed to get sent to FS has a length of 8451.

drachtio-CutOffInvite.log

lylepratt commented 1 year ago

Something else to note is that the SDP content length is always capped at 8384, but the total length returned by tport_send_msg() is always 8866 (even if I send in a giant 10kbyte INVITE which often comes from Safari over WebRTC, these are the capped amounts that always hit the wire outbound to FS)

lylepratt commented 1 year ago

howdy! just following up here. Any thoughts or insights Dave?

davehorton commented 1 year ago

can you recreate that with sofia-loglevel at 9 ?

lylepratt commented 1 year ago

working on it!

lylepratt commented 1 year ago

OK. Bad INVITE with Content-Length 8384 is at line 906. You can see the good version of it right above that with a full Content-Length of 10693. These invites were generated by Safari webrtc.

drachtio-CutOffInvite-Log9.log

lylepratt commented 1 year ago

any insights with log level 9 turned on?

davehorton commented 1 year ago

are you certain sofia logging was at 9? I expected to see more logging

lylepratt commented 1 year ago

well I started the container with that sofia log level command and set it to 9. can give it another shot tomorrow though. is there a way i can verify?

davehorton commented 1 year ago

this should be fixed in drachtio-server release v0.8.21-rc2.