onsip / SIP.js

A simple, intuitive, and powerful JavaScript signaling library
https://sipjs.com
MIT License
1.88k stars 700 forks source link

sip.Parser | error parsing first line of SIP message #996

Closed Aayushi-Mashru closed 2 years ago

Aayushi-Mashru commented 2 years ago

Describe the bug I am using sip.js in my react native application, here when I am receiving a specific SIP response from the client's SIP server the Sip parser is not able to parse the first line of the SIP response.

Logs

SIP/2.0 480 Temporarily Unavailable [call Processing Released] Via: SIP/2.0/WSS 192.0.2.252;rport=38474;received=49.34.52.208;branch=z9hG4bK4396670 Record-Route: <sip:xx.xx.xx.xxx;lr;ep> Record-Route: <sip:_sipserver:5060;r2=on;lr;ftag=ba6jpgsua4;did=39e.5d07f992> Record-Route: <sip:_sipserver:port;transport=wss;r2=on;lr;ftag=ba6jpgsua4;did=39e.5d07f992> To: sip:A@xx.xx.xx.xxx;tag=GAYHZDDL6AQDGBND7EZQ____.i From: "B_display_name" sip:B@xx.xx.xx.xxx;tag=ba6jpgsua4 Call-ID: av1on3d1tb2sb1ksftfa CSeq: 2 INVITE Allow: INVITE, ACK, BYE, CANCEL, INFO, SUBSCRIBE, NOTIFY, REFER, MESSAGE, OPTIONS, UPDATE, PRACK Server: PortaSIP Content-Length: 0

2022-06-29T07:20:16.964Z [WARN] Wed Jun 29 2022 12:50:16 GMT+0530 (IST) | sip.Parser | error parsing first line of SIP message: "SIP/2.0 480 Temporarily Unavailable [call Processing Released]" 2022-06-29T07:20:16.971Z [WARN] Wed Jun 29 2022 12:50:16 GMT+0530 (IST) | sip.UserAgent | Failed to parse incoming message. Dropping. 2022-06-29T07:20:17.183Z [INFO] Wed Jun 29 2022 12:50:17 GMT+0530 (IST) | sip.Transport | Received WebSocket text message:

SIP/2.0 481 Call Leg Does Not Exist Via: SIP/2.0/WSS 192.0.2.252;rport=38474;received=49.34.52.208;branch=z9hG4bK1252611 Call-ID: av1on3d1tb2sb1ksftfa CSeq: 4 PRACK From: "B_display_name" sip:B@xx.xx.xx.xxx;tag=ba6jpgsua4 To: sip:A@xx.xx.xx.xxx;tag=GAYHZDDL6AQDGBND7EZQ____.i Server: PortaSIP Allow: INVITE, ACK, BYE, CANCEL, INFO, SUBSCRIBE, NOTIFY, REFER, MESSAGE, OPTIONS Content-Length: 0

To Reproduce (if possible) It's reproduced in case some additional text is there in the SIP response's first line. The parser should be resilient to it.

Expected behavior Sip.js should be able to parse the SIP response and behave accordingly.

Observed behavior Sip.js is not able to parse the SIP response and not sending any relevant response back to the server.

Environment Information

seanbright commented 2 years ago

when I am receiving a specific SIP response from the client's SIP server the Sip parser is not able to parse the first line of the SIP response

The parser is rejecting invalid input - this is what parsers are supposed to do. Neither [ nor ] (separators in the BNF) are permitted in the status line. The problem is with the server, not SIP.js.

john-e-riordan commented 2 years ago

@seanbright - thank you!

Not a bug.