JsSIP icon indicating copy to clipboard operation
JsSIP copied to clipboard

INFO request timeout leads to BYE and session termination

Open eeremin opened this issue 4 months ago • 7 comments

Steps to reproduce:

  1. Send INFO request with RTCSession::sendInfo
  2. Result of request is one of the following:
  • "SIP/2.0 408 Request Timeout" response
  • No response after Timers.TIMER_F timeout

Actual Result:

jssip sends BYE request and terminates the session.

Expected Result:

session is not terminated due to INFO request timeout.

According to https://datatracker.ietf.org/doc/html/rfc5057#section-5.1 timeout response or timeout of transaction is considered as "Transaction Only" failure and should not destroy the dialog.

This might be related to fix of the following issue on "Request Timeout" BYE is not sent

eeremin avatar Aug 25 '25 08:08 eeremin

Seems like just rewriting the behaviour for timeout for Info.js and DTMF.js would be needed.

Could you test this patch?

diff --git a/lib/RTCSession/Info.js b/lib/RTCSession/Info.js
index c331c35..dd4fedd 100644
--- a/lib/RTCSession/Info.js
+++ b/lib/RTCSession/Info.js
@@ -77,7 +77,10 @@ module.exports = class Info extends EventEmitter
         },
         onRequestTimeout : () =>
         {
-          this._session.onRequestTimeout();
+          this.emit('failed', {
+            originator : 'remote',
+            response
+          });
         },
         onDialogError : () =>
         {
~
~

jmillan avatar Sep 26 '25 11:09 jmillan

Tested with patch below (set response to null, added cause) and it seems to work - no session termination after timeout, didn't notice other issues.

diff --git a/lib/RTCSession/Info.js b/lib/RTCSession/Info.js
index c331c35..5516f92 100644
--- a/lib/RTCSession/Info.js
+++ b/lib/RTCSession/Info.js
@@ -77,7 +77,11 @@ module.exports = class Info extends EventEmitter
         },
         onRequestTimeout : () =>
         {
-          this._session.onRequestTimeout();
+          this.emit('failed', {
+            originator : 'remote',
+            response   : null,
+            cause      : JsSIP_C.causes.REQUEST_TIMEOUT
+          });
         },
         onDialogError : () =>
         {

eeremin avatar Sep 26 '25 14:09 eeremin

I noticed that it will be not possible to handle this timeout on the consumer side. Maybe its worth to add some onTimeout to the options parameter of RTCSession::sendInfo method

eeremin avatar Sep 26 '25 14:09 eeremin

I noticed that it will be not possible to handle this timeout on the consumer side.

Can you please be specific here?

jmillan avatar Oct 01 '25 09:10 jmillan

Can you please be specific here?

When i, as a user of the jssip library, will use session.sendInfo method then it will be not possible for me to know when this request is considered timed out. As i understand the this.emit('failed' ... part is internal and cannot be handled by user.

But it's just a notice, not relevant to the bug, i think that it will be sufficient to have only changes that directly fix subject bug without adding any functionality like ability to handle timeouts.

eeremin avatar Oct 01 '25 10:10 eeremin

this.emit('failed' ... part is internal and cannot be handled by user.

mm, it definitely should. sendInfo() should return the Info instance so the client can handle it's events..

Otherwise those events being emitted in Info are not handled by anyone in reality.

Let's keep this issue open. Feel free to create a PR where RTCSession.sendInfo() returns the Info instance.

jmillan avatar Oct 06 '25 08:10 jmillan

Indeed there IS public API for it: https://jssip.net/documentation/api/session/#event_newInfo

RTCSession newInfo will fire with the Info instance. So you can:

session.once('newInfo', (info) => { info.on('failed', console.log)});
session.sendInfo();

jmillan avatar Oct 06 '25 08:10 jmillan