-
Notifications
You must be signed in to change notification settings - Fork 789
Description
Unfortunately I think, that commit db132dd
"Allow sending DTMF during early dialog #689 (#925)"
introduced a severe bug concerning the ACK sequence number
when sending later in-Dialog INVITEs (for session refresh, hold, resume, ...).
Since the member variable ack_seqnum is never updated when sending messages,
it keeps its initial value assigned in the dialog constructor.
So the ACK sent in the second handshake still uses the CSeq of the first handshake.
See last ACK below, at 18:40:52.876Z.
In case the remote party sends an INVITE, the result would be even worse.
First ack_seqnum is overwritten by the INVITE CSeq of the incoming INVITE,
and then, on reception of the corresponding ACK, ack_seqnum is set to null,
probably causing a crash in next call to createRequest(ACK).
Perhaps I might have overseen something, but actually I don't think so.
Regards,
Karsten Luedtke.
Initial handshake:
palappbundle-021919.js:18369 18:25:46.841Z INFO > JsSIP: JsSIP:Transport sending message:
INVITE sip:+431600284@s1.e1.sp1.fmcc SIP/2.0
Via: SIP/2.0/WSS 192.168.162.91;alias;rport;branch=z9hG4bK3734881
Max-Forwards: 69
To: sip:+431600284@s1.e1.sp1.fmcc
From: sip:431600283@s1.e1.sp1.fmcc;tag=i5e48ov3ak
Call-ID: 0k5he60hn92oe1n868rc
CSeq: 5723 INVITE
Contact: sip:431600283@192.168.162.91;transport=wss;line=L52ef0d;x-ts;ob
Content-Type: application/sdp
Session-Expires: 1800;refresher=uac
Allow: INVITE,ACK,CANCEL,BYE,UPDATE,MESSAGE,OPTIONS,REFER,INFO,NOTIFY
Supported: timer,ice,replaces,outbound
User-Agent: C5.WebControl/2.6.0 (X11; Linux x86_64)
Content-Length: 4810
v=0
o=- 877973517338905065 2 IN IP4 127.0.0.1
s=WebRTC session
t=0 0
a=group:BUNDLE 0 1
a=extmap-allow-mixed
a=msid-semantic: WMS ce42edb1-eb62-4db0-93e0-fd2f7dc130c5
m=audio 57227 UDP/TLS/RTP/SAVPF 111 9 0 8 110 126
[...]
palappbundle-021919.js:18369 18:25:46.966Z INFO > JsSIP: JsSIP:Transport received text message:
SIP/2.0 407 Proxy Authentication Required
Via: SIP/2.0/WSS 192.168.162.91;alias;received=10.201.0.5;rport=45456;branch=z9hG4bK3734881
Max-Forwards: 68
From: sip:431600283@s1.e1.sp1.fmcc;tag=i5e48ov3ak
To: sip:+431600284@s1.e1.sp1.fmcc;tag=~x2Ra0CmRS
Call-ID: 0k5he60hn92oe1n868rc
CSeq: 5723 INVITE
Supported: ice,outbound,timer,replaces,sdp-anat
Allow: INVITE,ACK,CANCEL,BYE,MESSAGE,OPTIONS,REFER,INFO,NOTIFY
Proxy-Authenticate: Digest realm="s1.e1.sp1.fmcc",nonce="a5c766c990bc66b66b4a590ba84a839b",opaque="4101ccba0cbcb64ae38594c0a6ee6e8b",algorithm=MD5,qop="auth"
Session-Expires: 1800;refresher=uac
User-Agent: C5.WebControl/2.6.0 (X11; Linux x86_64)
Content-Length: 0
palappbundle-021919.js:18369 18:25:46.968Z INFO > JsSIP: JsSIP:Transport sending message:
ACK sip:+431600284@s1.e1.sp1.fmcc SIP/2.0
Via: SIP/2.0/WSS 192.168.162.91;alias;rport;branch=z9hG4bK3734881
Max-Forwards: 69
To: sip:+431600284@s1.e1.sp1.fmcc;tag=~x2Ra0CmRS
From: sip:431600283@s1.e1.sp1.fmcc;tag=i5e48ov3ak
Call-ID: 0k5he60hn92oe1n868rc
CSeq: 5723 ACK
Allow: INVITE,ACK,CANCEL,BYE,UPDATE,MESSAGE,OPTIONS,REFER,INFO,NOTIFY
Supported: outbound
User-Agent: C5.WebControl/2.6.0 (X11; Linux x86_64)
Content-Length: 0
palappbundle-021919.js:18369 18:25:46.970Z INFO > JsSIP: JsSIP:Transport sending message:
INVITE sip:+431600284@s1.e1.sp1.fmcc SIP/2.0
Via: SIP/2.0/WSS 192.168.162.91;alias;rport;branch=z9hG4bK4978456
Max-Forwards: 69
To: sip:+431600284@s1.e1.sp1.fmcc
From: sip:431600283@s1.e1.sp1.fmcc;tag=i5e48ov3ak
Call-ID: 0k5he60hn92oe1n868rc
CSeq: 5724 INVITE
Proxy-Authorization: Digest****************************************************************************************************************************************************************************************************************************************************************************************
Contact: sip:431600283@192.168.162.91;transport=wss;line=L52ef0d;x-ts;ob
Content-Type: application/sdp
Session-Expires: 1800;refresher=uac
Allow: INVITE,ACK,CANCEL,BYE,UPDATE,MESSAGE,OPTIONS,REFER,INFO,NOTIFY
Supported: timer,ice,replaces,outbound
User-Agent: C5.WebControl/2.6.0 (X11; Linux x86_64)
Content-Length: 4810
v=0
o=- 877973517338905065 2 IN IP4 127.0.0.1
s=WebRTC session
t=0 0
a=group:BUNDLE 0 1
a=extmap-allow-mixed
[...]
palappbundle-021919.js:18369 18:25:52.678Z INFO > JsSIP: JsSIP:Transport received text message:
SIP/2.0 200 OK
Via: SIP/2.0/WSS 192.168.162.91;alias;received=10.201.0.5;rport=45456;branch=z9hG4bK4978456
From: sip:431600283@s1.e1.sp1.fmcc;tag=i5e48ov3ak
To: sip:+431600284@s1.e1.sp1.fmcc;tag=7Lm3JPXKC5
Call-ID: 0k5he60hn92oe1n868rc
CSeq: 5724 INVITE
Contact: sip:10.220.39.65:443;transport=wss
Supported: timer,sdp-anat
Allow: INVITE,ACK,CANCEL,BYE,INFO,REGISTER,NOTIFY
Session-Expires: 1800;refresher=uac
User-Agent: Communi5.PROXY/8.2.1.10
Allow-Events: talk
Content-Type: application/sdp
Content-Length: 2432
X-Call-ID: 0k5he60hn92oe1n868rc-UASession-7svz17WYbH
v=0
o=- 1796000334 70802821 IN IP4 10.220.39.65
s=WebRTC session
t=0 0
a=ice-lite
m=audio 18548 UDP/TLS/RTP/SAVPF 111 9 0 8 110 126
[...]
18:25:52.700Z INFO > JsSIP: JsSIP:Transport sending message:
ACK sip:10.220.39.65:443;transport=wss SIP/2.0
Via: SIP/2.0/WSS 192.168.162.91;alias;rport;branch=z9hG4bK5390738
Max-Forwards: 69
To: sip:+431600284@s1.e1.sp1.fmcc;tag=7Lm3JPXKC5
From: sip:431600283@s1.e1.sp1.fmcc;tag=i5e48ov3ak
Call-ID: 0k5he60hn92oe1n868rc
CSeq: 5724 ACK
Allow: INVITE,ACK,CANCEL,BYE,UPDATE,MESSAGE,OPTIONS,REFER,INFO,NOTIFY
Supported: outbound
User-Agent: C5.WebControl/2.6.0 (X11; Linux x86_64)
Content-Length: 0
Session refresh, 15 minutes later ...
palappbundle-021919.js:18369 18:40:52.722Z INFO > JsSIP: JsSIP:Transport sending message:
INVITE sip:10.220.39.65:443;transport=wss SIP/2.0
Via: SIP/2.0/WSS 192.168.162.91;alias;rport;branch=z9hG4bK3727702
Max-Forwards: 69
To: sip:+431600284@s1.e1.sp1.fmcc;tag=7Lm3JPXKC5
From: sip:431600283@s1.e1.sp1.fmcc;tag=i5e48ov3ak
Call-ID: 0k5he60hn92oe1n868rc
CSeq: 5725 INVITE
Contact: sip:431600283@192.168.162.91;transport=wss;line=L52ef0d;x-ts;ob
Content-Type: application/sdp
Session-Expires: 1800;refresher=uac
Allow: INVITE,ACK,CANCEL,BYE,UPDATE,MESSAGE,OPTIONS,REFER,INFO,NOTIFY
Supported: timer,ice,replaces,outbound
User-Agent: C5.WebControl/2.6.0 (X11; Linux x86_64)
Content-Length: 5092
v=0
o=- 877973517338905065 3 IN IP4 127.0.0.1
s=WebRTC session
t=0 0
a=group:BUNDLE 0 1
a=extmap-allow-mixed
a=msid-semantic: WMS ce42edb1-eb62-4db0-93e0-fd2f7dc130c5
m=audio 65530 UDP/TLS/RTP/SAVPF 111 9 0 8 110 126
[...]
palappbundle-021919.js:18369 18:40:52.874Z INFO > JsSIP: JsSIP:Transport received text message:
SIP/2.0 200 OK
Via: SIP/2.0/WSS 192.168.162.91;alias;received=10.201.0.5;rport=45456;branch=z9hG4bK3727702
From: sip:431600283@s1.e1.sp1.fmcc;tag=i5e48ov3ak
To: sip:+431600284@s1.e1.sp1.fmcc;tag=7Lm3JPXKC5
Call-ID: 0k5he60hn92oe1n868rc
CSeq: 5725 INVITE
Contact: sip:10.220.39.65:443;transport=wss
Supported: timer,sdp-anat
Allow: INVITE,ACK,CANCEL,BYE,INFO,REGISTER,NOTIFY
Session-Expires: 1800;refresher=uac
User-Agent: Communi5.PROXY/8.2.1.10
Allow-Events: talk
Content-Type: application/sdp
Content-Length: 2432
X-Call-ID: 0k5he60hn92oe1n868rc-UASession-7svz17WYbH
v=0
o=- 1796000334 70802822 IN IP4 10.220.39.65
s=WebRTC session
t=0 0
a=ice-lite
m=audio 18548 UDP/TLS/RTP/SAVPF 111 9 0 8 110 126
[...]
palappbundle-021919.js:18369 18:40:52.876Z INFO > JsSIP: JsSIP:Transport sending message:
ACK sip:10.220.39.65:443;transport=wss SIP/2.0
Via: SIP/2.0/WSS 192.168.162.91;alias;rport;branch=z9hG4bK3211221
Max-Forwards: 69
To: sip:+431600284@s1.e1.sp1.fmcc;tag=7Lm3JPXKC5
From: sip:431600283@s1.e1.sp1.fmcc;tag=i5e48ov3ak
Call-ID: 0k5he60hn92oe1n868rc
CSeq: 5724 ACK <======= WRONG, must be 5725! ========
Allow: INVITE,ACK,CANCEL,BYE,UPDATE,MESSAGE,OPTIONS,REFER,INFO,NOTIFY
Supported: outbound
User-Agent: C5.WebControl/2.6.0 (X11; Linux x86_64)
Content-Length: 0
In my patch, I first introduced a new member variable local_acknum,
so that incoming INVITES from the remote party do not overwrite
my stored CSeq for the next ACK to be sent.
Then I update local_acknum whenever an INVITE is sent, and
in the onAuthentication callback.
Finally I use the value stored in local_acknum when creating an INVITE.
--- /tmp/Dialog-3.10.9.js 2026-01-02 18:18:11.100119017 +0100
+++ node_modules/jssip/lib/Dialog.js 2026-01-02 20:13:37.551011426 +0100
@@ -63,7 +63,7 @@
this._remote_uri = message.parseHeader('from').uri;
this._remote_target = contact.uri;
this._route_set = message.getHeaders('record-route');
-
this._ack_seqnum = message.cseq;
-
}
this._ack_seqnum = this._remote_seqnum;
// RFC 3261 12.1.2.
else if (type === 'UAC')
@@ -83,7 +83,8 @@
this._remote_uri = message.parseHeader('to').uri;
this._remote_target = contact.uri;
this._route_set = message.getHeaders('record-route').reverse();
-
this._ack_seqnum = this._local_seqnum;
-
this._ack_seqnum = null; -
this._local_acknum = this._local_seqnum;}
@@ -159,11 +160,25 @@
const body = options.body || null;
const request = this._createRequest(method, extraHeaders, body);
- // Increase the local CSeq on authentication.
- eventHandlers.onAuthenticated = () =>
- // INVITE to be sent. Update this._local_acknum.
- if (request.method === JsSIP_C.INVITE)
{
-
this._local_seqnum += 1; - };
-
this._local_acknum = request.cseq; -
// Increase both local CSeq and ACK CSeq on authentication. -
eventHandlers.onAuthenticated = () => -
{ -
this._local_seqnum += 1; -
this._local_acknum = this._local_seqnum; -
}; -
}
-
else
-
{
-
// Increase the local CSeq on authentication. -
eventHandlers.onAuthenticated = () => -
{ -
this._local_seqnum += 1; -
}; -
}
const request_sender = new Dialog_RequestSender(this, request, eventHandlers);
@@ -204,7 +219,7 @@
// CANCEL and ACK must use the same sequence number as the INVITE.
const cseq = (method === JsSIP_C.CANCEL || method === JsSIP_C.ACK) ?
-
this._ack_seqnum :
-
this._local_acknum : this._local_seqnum += 1;const request = new SIPMessage.OutgoingRequest(