I am building a java application using SIP over websockets and working as b2bua, i.e. this application registers a number of sip users on another SIP server.
I was wondering if there is a way to somehow reuse an existing listening point? It seems that for each of the SIP clients I should create SipStack
, SipListeningPoint
, SipProvider
and then call SipProvider
's sendRequest
to actually send SIP message to the destination server. The creation of a SipListeningPoint
however allocates a new socket to accept incoming connections (which I don't really need), so I need one open socket for each SIP client I am registering on the remote server.
I tried to reuse SipListeningPoint
, but there is a limitation that only one listening point is allowed per SipStack
. I also tried to reuse SipProvider
, but it leads to an exception in SSLStateMachine
.
javax.net.ssl.SSLException: Received fatal alert: handshake_failure
at sun.security.ssl.Alerts.getSSLException(Alerts.java:208)
at sun.security.ssl.SSLEngineImpl.fatal(SSLEngineImpl.java:1666)
at sun.security.ssl.SSLEngineImpl.fatal(SSLEngineImpl.java:1634)
at sun.security.ssl.SSLEngineImpl.recvAlert(SSLEngineImpl.java:1800)
at sun.security.ssl.SSLEngineImpl.readRecord(SSLEngineImpl.java:1083)
at sun.security.ssl.SSLEngineImpl.readNetRecord(SSLEngineImpl.java:907)
at sun.security.ssl.SSLEngineImpl.unwrap(SSLEngineImpl.java:781)
at javax.net.ssl.SSLEngine.unwrap(SSLEngine.java:624)
at gov.nist.javax.sip.stack.SSLStateMachine.unwrap(SSLStateMachine.java:303)
at gov.nist.javax.sip.stack.SSLStateMachine.unwrap(SSLStateMachine.java:244)
at gov.nist.javax.sip.stack.NioTlsWebSocketMessageChannel.addBytes(NioTlsWebSocketMessageChannel.java:282)
at gov.nist.javax.sip.stack.NioTcpMessageChannel.readChannel(NioTcpMessageChannel.java:121)
at gov.nist.javax.sip.stack.NioTcpMessageProcessor$ProcessorTask.read(NioTcpMessageProcessor.java:154)
at gov.nist.javax.sip.stack.NioTcpMessageProcessor$ProcessorTask.run(NioTcpMessageProcessor.java:344)
at java.lang.Thread.run(Thread.java:745)
(Yes I know that this stack trace usually means that there is some issue with an SSL certificate. But SSL connection establishes successfully when I create separate listening points for each sip user or when I register just one sip user)
Here are SipStack
properties I set:
properties.setProperty("javax.sip.STACK_NAME", s"im.dlg.sip:$localAddress:$transport")
properties.setProperty("javax.sip.AUTOMATIC_DIALOG_SUPPORT", "on") // must be on to leverage dialog usage!
properties.setProperty("gov.nist.javax.sip.DELIVER_RETRANSMITTED_ACK_TO_LISTENER", "true")
properties.setProperty("gov.nist.javax.sip.REENTRANT_LISTENER", "false")
properties.setProperty("gov.nist.javax.sip.MESSAGE_PROCESSOR_FACTORY", "gov.nist.javax.sip.stack.NioMessageProcessorFactory")
properties.setProperty("gov.nist.javax.sip.THREAD_POOL_SIZE", "10")
I am using javax.sip:jain-sip-ri:1.2.265
.