Ok, just to clarify, now I'm using only TCP on both legs, so the scenario is just a basic B2BUA over TCP. I've done some more testing, and it looks like there is some kind of timeout after a period of no calls which breakes the functionality of sending requests over new tcp connections.
After restarting the server I was setting up test calls, one after another with several seconds of pause between them. Everything was working fine. After about 8 minutes I stopped making calls. After next 2 minutes I tried to setup another call and it failed. MSS didn't send out the INVITE to B even though the new tcp session was up. Log output looked exactly the same (except for the ports of course).
I've tried changing logging to DEBUG in logging.properties, but i don't see anything new. Adding BasicConfiguration.configure() at servlet init resulted in printing stdouts(and doubling some logs). You can find the current log output below. It is interesting that the INVITE which isn't send out is printed as a regular message. Some more ideas?
11:46:22,802 INFO [stdout] (SIP-TCP-Core-PipelineThreadpool-12) 326611 [SIP-TCP-Core-PipelineThreadpool-12] WARN gov.nist.javax.sip.stack.NioTcpMessageChannel - [2] Old socket different than new socket on channel tcp:<scscf_ip>:5060java.nio.channels.SocketChannel[closed] java.nio.channels.SocketChannel[connected local=/<mss_ip>:43950 remote=<scscf_url>/<scscf_ip>:5060]
11:46:22,802 WARN [gov.nist.javax.sip.stack.NioTcpMessageChannel] (SIP-TCP-Core-PipelineThreadpool-12) [2] Old socket different than new socket on channel tcp:<scscf_ip>:5060java.nio.channels.SocketChannel[closed] java.nio.channels.SocketChannel[connected local=/<mss_ip>:43950 remote=<scscf_url>/<scscf_ip>:5060]
11:46:22,805 INFO [stdout] (SIP-TCP-Core-PipelineThreadpool-12) 326614 [SIP-TCP-Core-PipelineThreadpool-12] WARN gov.nist.javax.sip.stack.NioTcpMessageChannel - Old socket local ip address null
11:46:22,805 WARN [gov.nist.javax.sip.stack.NioTcpMessageChannel] (SIP-TCP-Core-PipelineThreadpool-12) Old socket local ip address null
11:46:22,805 INFO [stdout] (SIP-TCP-Core-PipelineThreadpool-12) 326614 [SIP-TCP-Core-PipelineThreadpool-12] WARN gov.nist.javax.sip.stack.NioTcpMessageChannel - Old socket remote ip address null
11:46:22,805 WARN [gov.nist.javax.sip.stack.NioTcpMessageChannel] (SIP-TCP-Core-PipelineThreadpool-12) Old socket remote ip address null
11:46:22,806 INFO [stdout] (SIP-TCP-Core-PipelineThreadpool-12) 326615 [SIP-TCP-Core-PipelineThreadpool-12] WARN gov.nist.javax.sip.stack.NioTcpMessageChannel - New socket local ip address /<mss_ip>:43950
11:46:22,806 WARN [gov.nist.javax.sip.stack.NioTcpMessageChannel] (SIP-TCP-Core-PipelineThreadpool-12) New socket local ip address /<mss_ip>:43950
11:46:22,806 INFO [stdout] (SIP-TCP-Core-PipelineThreadpool-12) 326615 [SIP-TCP-Core-PipelineThreadpool-12] WARN gov.nist.javax.sip.stack.NioTcpMessageChannel - New socket remote ip address <scscf_url>/<scscf_ip>:5060
11:46:22,806 WARN [gov.nist.javax.sip.stack.NioTcpMessageChannel] (SIP-TCP-Core-PipelineThreadpool-12) New socket remote ip address <scscf_url>/<scscf_ip>:5060
11:46:22,807 INFO [stdout] (SIP-TCP-Core-PipelineThreadpool-12) 326616 [SIP-TCP-Core-PipelineThreadpool-12] WARN gov.nist.javax.sip.stack.NioTcpMessageChannel - There was no exception for the retry mechanism so we keep going tcp:<scscf_ip>:5060
11:46:22,807 WARN [gov.nist.javax.sip.stack.NioTcpMessageChannel] (SIP-TCP-Core-PipelineThreadpool-12) There was no exception for the retry mechanism so we keep going tcp:<scscf_ip>:5060
11:46:22,811 INFO [stdout] (SIP-TCP-Core-PipelineThreadpool-12) 326620 [SIP-TCP-Core-PipelineThreadpool-12] INFO gov.nist.javax.sip.stack.SIPTransactionStack - <message
11:46:22,811 INFO [stdout] (SIP-TCP-Core-PipelineThreadpool-12) from="<mss_ip>:5060"
11:46:22,811 INFO [stdout] (SIP-TCP-Core-PipelineThreadpool-12) to="<scscf_ip>:5060"
11:46:22,811 INFO [stdout] (SIP-TCP-Core-PipelineThreadpool-12) time="1360665982799"
11:46:22,811 INFO [stdout] (SIP-TCP-Core-PipelineThreadpool-12) isSender="true"
11:46:22,812 INFO [stdout] (SIP-TCP-Core-PipelineThreadpool-12) transactionId="z9hg4bk1d40cd22-4712-43e3-b9e4-9344389e1859_56e6eb3b_2423630489896848"
11:46:22,812 INFO [stdout] (SIP-TCP-Core-PipelineThreadpool-12) callId="5af01d475e894614ca5f1a49eed517dd@<mss_ip>"
11:46:22,812 INFO [stdout] (SIP-TCP-Core-PipelineThreadpool-12) firstLine="INVITE sip:<user>@<scscf_url>;user=phone;transport=tcp SIP/2.0"
11:46:22,812 INFO [stdout] (SIP-TCP-Core-PipelineThreadpool-12) >