sipsorcery icon indicating copy to clipboard operation
sipsorcery copied to clipboard

There seems to be no way of handling a received SIPNonInviteTransaction asynchronously

Open axelsommerfeldt opened this issue 2 years ago • 0 comments

I receive a SIP (non-INVITE) request via SIPTransport.SIPTransportRequestReceived and would like to use SIPNonInviteTransaction but handle the transaction asynchronously. This leads into the problem that duplicates are not detected reliably since SIPNonInviteTransaction will not be put into the transaction list of the transaction engine until SIPNonInviteTransaction.SendResponse() is called.

Inside the constructor of SIPNonInviteTransaction the following code lines could be found:

// This transaction type can be used to represent two different things:
// - a tx that the application wants to use to send a request reliably,
// - a tx for a request that has been received from a remote end point and that duplicates need
//   to be detected for.
// This block is for the second case. The tx request has been received and the tx engine
// needs to be signalled that it is now at the request processing stage.
base.UpdateTransactionState(SIPTransactionStatesEnum.Proceeding);

But just setting the transaction state is not sufficient here to offer what the code comment promises, "a tx for a request that has been received from a remote end point and that duplicates need to be detected for".

Proposed solutions:

  1. Add _sipTransport.AddTransaction(this); inside the constructor of SIPNonInviteTransaction, right after the code line above.
  2. or offer void SetPending() -> _sipTransport.AddTransaction(this);
  3. or split SIPNonInviteTransaction into UASNonInviteTransaction and UACNonInviteTransaction, and UASNonInviteTransaction will have _sipTransport.AddTransaction(this); inside the constructor.

axelsommerfeldt avatar Aug 27 '22 17:08 axelsommerfeldt