-
Notifications
You must be signed in to change notification settings - Fork 151
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to use SIP stack with NIO TCP properly? #164
Comments
I'm having a problem with NIO TCP as well, while it was working on version 1.2.307 . The symptoms are that requests that are destined to tcp destinations, are never being sent. Tcp connection is made, but the content is never sent. Reproduction can of this issue can easily be made using the following code:
After a while the servlet's doErrorResponse will be called with status 408, and reason phrase 'Request timeout' The exact same code is working if I replace jain-sip-ri jar with the 1.2.307 version. |
@pimenas thanks for sharing your finds. This does sound like a regression... Have you been able to track the code that might be causing the issue? Perhaps if you have, you would like to have a go at contributing a fix for this one? ;) Let me know and I can assist along the way, etc. |
@gsaslis I'll try to find a few hours to spend on this during the next days! |
@pimenas awesome stuff! Again, plz feel free to reach out if you need any help. |
Well, I started with writing a small test in groovy which only tried to send an options request to a remote sip server using NIO TCP, and made a 'git bisect'. Here's the log from bisect:
So NIO TCP stops working at commit 365fb3e, which is this change:
That "connected" variable never seems to be set at something other rather than |
After reading more carefully the first comments, I guess @lhodovsk is experiencing a different issue with NIO TCP than the one I'm trying to fix... |
@gsaslis my comment means that #176 is a fix to my issue which is described in my first comment in this issue, which is different than the one that @lhodovsk reported in the first comment. In any case, I think it should be merged in the master because it fixes outgoing tcp connections. To tell you the truth, after reading the first comment, I'm not sure what is the issue that @lhodovsk tries to report here, otherwise I would have a look at this also. Maybe I should create a new issue for my fix, but it seems to me a little overkill for just a one-line-of-code fix, so I think I'll just update the pull request description. |
I was trying to use the SIP stack (latest version) with the NIO TCP message channel. I have set the property "gov.nist.javax.sip.MESSAGE_PROCESSOR_FACTORY" to use the NioMessageProcessorFactory class,
Anyway, then I experienced strange behavior with even one outgoing TCP SIP call. It looked like the received messages were not parsed correctly. E.g. parser for first received OPTIONS from called party complained there is a Content-Length header with value of 133, although there was no any such Header in recieved OPTIONS. Looking into logs I found that 200 OK received for INVITE and also later for UPDATE sent by my application contained the content with the length of 133. Maybe I am missing some configuration, but I have not found any relevant example.
It was working fine with the default MessageProcessorFactory implementation.
A bit of my logs:
1. 200 OK for initial INVITE
21.09.2017 15:25:10,646 +02:00 DEBUG LX-S-MED-GSP-01 P17488/T27 B2BUA/NioSelector-TCP-10.17.53.11/5060/SipStackLogger.logDebug Got something on nioTcpMessageChannel gov.nist.javax.sip.stack.NioTcpMessageChannel@593fd0f1 socket java.nio.channels.SocketChannel[connected local=/10.17.53.11:60258 remote=/10.17.53.43:5060]
21.09.2017 15:25:10,646 +02:00 DEBUG LX-S-MED-GSP-01 P17488/T27 B2BUA/NioSelector-TCP-10.17.53.11/5060/SipStackLogger.logDebug NioTcpMessageChannel::readChannel
21.09.2017 15:25:10,647 +02:00 DEBUG LX-S-MED-GSP-01 P17488/T27 B2BUA/NioSelector-TCP-10.17.53.11/5060/SipStackLogger.logDebug Read 617 from socketChannel
21.09.2017 15:25:10,648 +02:00 DEBUG LX-S-MED-GSP-01 P17488/T27 B2BUA/NioSelector-TCP-10.17.53.11/5060/SipStackLogger.logDebug Received CRLF
21.09.2017 15:25:10,648 +02:00 DEBUG LX-S-MED-GSP-01 P17488/T27 B2BUA/NioSelector-TCP-10.17.53.11/5060/SipStackLogger.logDebug Content Length parsed is 133
21.09.2017 15:25:10,656 +02:00 DEBUG LX-S-MED-GSP-01 P17488/T27 B2BUA/NioSelector-TCP-10.17.53.11/5060/SipStackLogger.logDebug Next thread id=0
21.09.2017 15:25:10,661 +02:00 INFO LX-S-MED-GSP-01 P17488/T46 B2BUA/pool-AffinityJAIN-thread-1/SipStackLogger.logInfo serving msg on call id [email protected]
21.09.2017 15:25:10,661 +02:00 DEBUG LX-S-MED-GSP-01 P17488/T46 B2BUA/pool-AffinityJAIN-thread-1/SipStackLogger.logDebug
21.09.2017 15:25:10,661 +02:00 DEBUG LX-S-MED-GSP-01 P17488/T46 B2BUA/pool-AffinityJAIN-thread-1/SipStackLogger.logDebug Unparsed message before parser is:
21.09.2017 15:25:10,661 +02:00 DEBUG LX-S-MED-GSP-01 P17488/T46 B2BUA/pool-AffinityJAIN-thread-1/SipStackLogger.logDebug gov.nist.javax.sip.parser.NioPipelineParser$UnparsedMessage@1d40d399
21.09.2017 15:25:10,661 +02:00 DEBUG LX-S-MED-GSP-01 P17488/T46 B2BUA/pool-AffinityJAIN-thread-1/SipStackLogger.logDebug SIP/2.0 200 OK
21.09.2017 15:25:10,661 +02:00 DEBUG LX-S-MED-GSP-01 P17488/T46 B2BUA/pool-AffinityJAIN-thread-1/SipStackLogger.logDebug Via: SIP/2.0/TCP 10.17.53.11:5060; branch=z9hG4bK-363332-193112260b0756b39fa8081e9b4f3d46
21.09.2017 15:25:10,661 +02:00 DEBUG LX-S-MED-GSP-01 P17488/T46 B2BUA/pool-AffinityJAIN-thread-1/SipStackLogger.logDebug Call-ID: [email protected]
21.09.2017 15:25:10,661 +02:00 DEBUG LX-S-MED-GSP-01 P17488/T46 B2BUA/pool-AffinityJAIN-thread-1/SipStackLogger.logDebug CSeq: 1 INVITE
21.09.2017 15:25:10,661 +02:00 DEBUG LX-S-MED-GSP-01 P17488/T46 B2BUA/pool-AffinityJAIN-thread-1/SipStackLogger.logDebug From: sip:[email protected];tag=-712247862
21.09.2017 15:25:10,661 +02:00 DEBUG LX-S-MED-GSP-01 P17488/T46 B2BUA/pool-AffinityJAIN-thread-1/SipStackLogger.logDebug To: sip:[email protected];tag=5A36DCFD-F35B-4E67-A840-E87B6362FC27
21.09.2017 15:25:10,661 +02:00 DEBUG LX-S-MED-GSP-01 P17488/T46 B2BUA/pool-AffinityJAIN-thread-1/SipStackLogger.logDebug Contact: sip:[email protected]:5060
21.09.2017 15:25:10,661 +02:00 DEBUG LX-S-MED-GSP-01 P17488/T46 B2BUA/pool-AffinityJAIN-thread-1/SipStackLogger.logDebug Date: Thu, 21 Sep 2017 13:25:10 GMT
21.09.2017 15:25:10,661 +02:00 DEBUG LX-S-MED-GSP-01 P17488/T46 B2BUA/pool-AffinityJAIN-thread-1/SipStackLogger.logDebug User-Agent: Recorder.SDP/400.00.001 libTPP/3.33.006
21.09.2017 15:25:10,661 +02:00 DEBUG LX-S-MED-GSP-01 P17488/T46 B2BUA/pool-AffinityJAIN-thread-1/SipStackLogger.logDebug Content-Type: application/sdp
21.09.2017 15:25:10,661 +02:00 DEBUG LX-S-MED-GSP-01 P17488/T46 B2BUA/pool-AffinityJAIN-thread-1/SipStackLogger.logDebug Content-Length: 133
21.09.2017 15:25:10,661 +02:00 DEBUG LX-S-MED-GSP-01 P17488/T46 B2BUA/pool-AffinityJAIN-thread-1/SipStackLogger.logDebug
21.09.2017 15:25:10,661 +02:00 DEBUG LX-S-MED-GSP-01 P17488/T46 B2BUA/pool-AffinityJAIN-thread-1/SipStackLogger.logDebug ;
21.09.2017 15:25:10,663 +02:00 DEBUG LX-S-MED-GSP-01 P17488/T46 B2BUA/pool-AffinityJAIN-thread-1/SipStackLogger.logDebug acquireSem [[[[gov.nist.javax.sip.stack.SIPClientTransactionImpl@8bbf3f41
21.09.2017 15:25:10,664 +02:00 DEBUG LX-S-MED-GSP-01 P17488/T46 B2BUA/pool-AffinityJAIN-thread-1/SipStackLogger.logDebug acquireSem() returning : true
2. received 200 OK for UPDATE message
21.09.2017 15:25:10,857 +02:00 DEBUG LX-S-MED-GSP-01 P17488/T27 B2BUA/NioSelector-TCP-10.17.53.11/5060/SipStackLogger.logDebug Got something on nioTcpMessageChannel gov.nist.javax.sip.stack.NioTcpMessageChannel@593fd0f1 socket java.nio.channels.SocketChannel[connected local=/10.17.53.11:60258 remote=/10.17.53.43:5060]
21.09.2017 15:25:10,857 +02:00 DEBUG LX-S-MED-GSP-01 P17488/T27 B2BUA/NioSelector-TCP-10.17.53.11/5060/SipStackLogger.logDebug NioTcpMessageChannel::readChannel
21.09.2017 15:25:10,857 +02:00 DEBUG LX-S-MED-GSP-01 P17488/T27 B2BUA/NioSelector-TCP-10.17.53.11/5060/SipStackLogger.logDebug Read 617 from socketChannel
21.09.2017 15:25:10,858 +02:00 DEBUG LX-S-MED-GSP-01 P17488/T27 B2BUA/NioSelector-TCP-10.17.53.11/5060/SipStackLogger.logDebug Received CRLF
21.09.2017 15:25:10,858 +02:00 DEBUG LX-S-MED-GSP-01 P17488/T27 B2BUA/NioSelector-TCP-10.17.53.11/5060/SipStackLogger.logDebug Content Length parsed is 133
21.09.2017 15:25:10,858 +02:00 DEBUG LX-S-MED-GSP-01 P17488/T27 B2BUA/NioSelector-TCP-10.17.53.11/5060/SipStackLogger.logDebug Next thread id=0
21.09.2017 15:25:10,859 +02:00 INFO LX-S-MED-GSP-01 P17488/T46 B2BUA/pool-AffinityJAIN-thread-1/SipStackLogger.logInfo serving msg on call id [email protected]
21.09.2017 15:25:10,860 +02:00 DEBUG LX-S-MED-GSP-01 P17488/T46 B2BUA/pool-AffinityJAIN-thread-1/SipStackLogger.logDebug
21.09.2017 15:25:10,860 +02:00 DEBUG LX-S-MED-GSP-01 P17488/T46 B2BUA/pool-AffinityJAIN-thread-1/SipStackLogger.logDebug Unparsed message before parser is:
21.09.2017 15:25:10,860 +02:00 DEBUG LX-S-MED-GSP-01 P17488/T46 B2BUA/pool-AffinityJAIN-thread-1/SipStackLogger.logDebug gov.nist.javax.sip.parser.NioPipelineParser$UnparsedMessage@69d0b343
21.09.2017 15:25:10,860 +02:00 DEBUG LX-S-MED-GSP-01 P17488/T46 B2BUA/pool-AffinityJAIN-thread-1/SipStackLogger.logDebug SIP/2.0 200 OK
21.09.2017 15:25:10,860 +02:00 DEBUG LX-S-MED-GSP-01 P17488/T46 B2BUA/pool-AffinityJAIN-thread-1/SipStackLogger.logDebug Via: SIP/2.0/TCP 10.17.53.11:5060; branch=z9hG4bK-363332-02eac2f55df871532ebb2a66ac9c1e41
21.09.2017 15:25:10,860 +02:00 DEBUG LX-S-MED-GSP-01 P17488/T46 B2BUA/pool-AffinityJAIN-thread-1/SipStackLogger.logDebug Call-ID: [email protected]
21.09.2017 15:25:10,860 +02:00 DEBUG LX-S-MED-GSP-01 P17488/T46 B2BUA/pool-AffinityJAIN-thread-1/SipStackLogger.logDebug CSeq: 2 UPDATE
21.09.2017 15:25:10,860 +02:00 DEBUG LX-S-MED-GSP-01 P17488/T46 B2BUA/pool-AffinityJAIN-thread-1/SipStackLogger.logDebug From: sip:[email protected];tag=-712247862
21.09.2017 15:25:10,860 +02:00 DEBUG LX-S-MED-GSP-01 P17488/T46 B2BUA/pool-AffinityJAIN-thread-1/SipStackLogger.logDebug To: sip:[email protected];tag=5A36DCFD-F35B-4E67-A840-E87B6362FC27
21.09.2017 15:25:10,860 +02:00 DEBUG LX-S-MED-GSP-01 P17488/T46 B2BUA/pool-AffinityJAIN-thread-1/SipStackLogger.logDebug Contact: sip:[email protected]:5060
21.09.2017 15:25:10,860 +02:00 DEBUG LX-S-MED-GSP-01 P17488/T46 B2BUA/pool-AffinityJAIN-thread-1/SipStackLogger.logDebug Date: Thu, 21 Sep 2017 13:25:10 GMT
21.09.2017 15:25:10,860 +02:00 DEBUG LX-S-MED-GSP-01 P17488/T46 B2BUA/pool-AffinityJAIN-thread-1/SipStackLogger.logDebug User-Agent: Recorder.SDP/400.00.001 libTPP/3.33.006
21.09.2017 15:25:10,860 +02:00 DEBUG LX-S-MED-GSP-01 P17488/T46 B2BUA/pool-AffinityJAIN-thread-1/SipStackLogger.logDebug Content-Type: application/sdp
21.09.2017 15:25:10,860 +02:00 DEBUG LX-S-MED-GSP-01 P17488/T46 B2BUA/pool-AffinityJAIN-thread-1/SipStackLogger.logDebug Content-Length: 133
21.09.2017 15:25:10,860 +02:00 DEBUG LX-S-MED-GSP-01 P17488/T46 B2BUA/pool-AffinityJAIN-thread-1/SipStackLogger.logDebug
21.09.2017 15:25:10,860 +02:00 DEBUG LX-S-MED-GSP-01 P17488/T46 B2BUA/pool-AffinityJAIN-thread-1/SipStackLogger.logDebug ;
21.09.2017 15:25:10,863 +02:00 DEBUG LX-S-MED-GSP-01 P17488/T46 B2BUA/pool-AffinityJAIN-thread-1/SipStackLogger.logDebug acquireSem [[[[gov.nist.javax.sip.stack.SIPClientTransactionImpl@cd0baa51
21.09.2017 15:25:10,863 +02:00 DEBUG LX-S-MED-GSP-01 P17488/T46 B2BUA/pool-AffinityJAIN-thread-1/SipStackLogger.logDebug acquireSem() returning : true
3. received OPTIONS with non-existing, but reported Content-Length
21.09.2017 15:25:20,996 +02:00 DEBUG LX-S-MED-GSP-01 P17488/T27 B2BUA/NioSelector-TCP-10.17.53.11/5060/SipStackLogger.logDebug We got selkey sun.nio.ch.SelectionKeyImpl@388977e7
21.09.2017 15:25:20,996 +02:00 DEBUG LX-S-MED-GSP-01 P17488/T27 B2BUA/NioSelector-TCP-10.17.53.11/5060/SipStackLogger.logDebug Read sun.nio.ch.SelectionKeyImpl@388977e7
21.09.2017 15:25:20,996 +02:00 DEBUG LX-S-MED-GSP-01 P17488/T27 B2BUA/NioSelector-TCP-10.17.53.11/5060/SipStackLogger.logDebug Got something on nioTcpMessageChannel gov.nist.javax.sip.stack.NioTcpMessageChannel@593fd0f1 socket java.nio.channels.SocketChannel[connected local=/10.17.53.11:60258 remote=/10.17.53.43:5060]
21.09.2017 15:25:20,996 +02:00 DEBUG LX-S-MED-GSP-01 P17488/T27 B2BUA/NioSelector-TCP-10.17.53.11/5060/SipStackLogger.logDebug NioTcpMessageChannel::readChannel
21.09.2017 15:25:20,996 +02:00 DEBUG LX-S-MED-GSP-01 P17488/T27 B2BUA/NioSelector-TCP-10.17.53.11/5060/SipStackLogger.logDebug Read 426 from socketChannel
21.09.2017 15:25:20,997 +02:00 DEBUG LX-S-MED-GSP-01 P17488/T27 B2BUA/NioSelector-TCP-10.17.53.11/5060/SipStackLogger.logDebug Received CRLF
21.09.2017 15:25:20,997 +02:00 DEBUG LX-S-MED-GSP-01 P17488/T27 B2BUA/NioSelector-TCP-10.17.53.11/5060/SipStackLogger.logDebug Content Length parsed is 133
4. later there was an exception reported:
21.09.2017 15:25:22,011 +02:00 INFO LX-S-MED-GSP-01 P17488/T25 B2BUA/EventScannerThread/SipEventDistributor.processRequest processRequest RequestEventExt[remoteIpAddress=10.17.53.43,remotePort=5060,m_request=OPTIONS sip:[email protected] SIP/2.0, Via: SIP/2.0/TCP 10.17.53.11:5060branch=z9hG4bK-363332-193112260b0756b39fa8081e9b4f3d46received=10.17.53.43rport=5060, From: sip:[email protected]=5A36DCFD-F35B-4E67-A840-E87B6362FC27, To: sip:[email protected]=-712247862, Call-ID: [email protected], CSeq: 0 OPTIONS, Date: Thu, 21 Sep 2017 13:25:21 GMT, User-Agent: Recorder.SDP/400.00.001 libTPP/3.33.006, Content-Length: 133, , OPTIONS sip:[email protected] SIP/2.0, Via: SIP/2.0/TCP 10.17.53.11:5060 branch=z9hG4bK-363332-193112260b0756b39fa8081e9b4,m_transaction=gov.nist.javax.sip.stack.SIPServerTransactionImpl@8bbf3f41,m_dialog=gov.nist.javax.sip.stack.SIPDialog@32c2f2b2]
21.09.2017 15:25:22,011 +02:00 ERROR LX-S-MED-GSP-01 P17488/T25 B2BUA/EventScannerThread/SipStackLogger.logException If there is a message body the media type MUST be given by the Content-Type header field.
21.09.2017 15:25:22,011 +02:00 ERROR LX-S-MED-GSP-01 P17488/T25 B2BUA/EventScannerThread/SipStackLogger.logException java.lang.IllegalArgumentException: If there is a message body the media type MUST be given by the Content-Type header field.
The text was updated successfully, but these errors were encountered: