Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jain SIP in multi-thread environment

Tags:

jain-sip

It's not clear how to use jain SIP stack in mutli-thread environment. I need to create multiple SIP sessions from different threads, e.g each client should be proceeded in its own transaction. Below is few options:

  • Use single SipProvider for receiving and sending SIP requests and do multiplexing on application side. SipProvider is not thread-safe, hence sending requests requires proper locking.
  • Create new SipProvider and new ListeningPoint for each client. This is how it works for me now. However, I don't really like it. And it's not clear, whther SipStack threadsafe or not
  • Create new instance of SipStack for every client
like image 287
user12384512 Avatar asked Feb 16 '26 16:02

user12384512


1 Answers

Its been a long time since I thought about JAIN-SIP (or even SIP for that matter or even Java) but here goes:

  1. Set the re-entrant listener flag when you create the stack. (look up the javadocs). Specify a thread pool size. When a sip request or response comes along, the stack may potentially create a new thread for you and invoke your listener.

  2. Your critical section is the SipListener implementation. You should not block for ever in it - otherwise new inbound requests and responses will not be routed to the sip listener for the transaction that is being processed at the time you blocked.

Hope that answers your question. Happy hacking.

Thats it.

like image 79
LostInTheFrequencyDomain Avatar answered Feb 21 '26 14:02

LostInTheFrequencyDomain