langtuandroid / jdiameter

Automatically exported from code.google.com/p/jdiameter
0 stars 0 forks source link

Jdiameter SCTP automatic reconnection #72

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago

I have been running some client server tests with the jdiameter stack (Version 
1.6.0-FINAL).

The client sends a S6A request to the server which responds with a S6A answer. 
If I run the tests over the TCP protocol I can stop and start the server with 
the client still running and the client automatically reconnects to the server. 
If I repeat the tests over the SCTP protocol then the client does not reconnect 
with the client. In the client application log file I see exceptions of the 
form:

21 Jan 2015 15:03:47,882 [Thread-2] INFO  
org.mobicents.protocols.sctp.SelectorThread  - Association=cookie.ei.lan.3730 
connected to=[/10.7.3.65:3868]
21 Jan 2015 15:03:47,882 [Thread-2] INFO  
org.mobicents.protocols.sctp.AssociationHandler  - New association setup for 
Association=cookie.ei.lan.3730 with 32 outbound streams, and 10 inbound streams.

21 Jan 2015 15:03:47,883 [Thread-2] INFO  
org.mobicents.protocols.sctp.AssociationHandler  - 
Association=cookie.ei.lan.3730 SHUTDOWN
21 Jan 2015 15:03:47,884 [Thread-2] ERROR 
org.mobicents.protocols.sctp.AssociationImpl  - IOException while trying to 
write to underlying socket for Association=cookie.ei.lan.3730 IOError count=1
java.net.SocketException: Socket is shutdown for writing
    at sun.nio.ch.SctpChannelImpl.send0(Native Method)
    at sun.nio.ch.SctpChannelImpl.sendFromNativeBuffer(SctpChannelImpl.java:1039)
    at sun.nio.ch.SctpChannelImpl.send(SctpChannelImpl.java:991)
    at sun.nio.ch.SctpChannelImpl.send(SctpChannelImpl.java:971)
    at org.mobicents.protocols.sctp.AssociationImpl.doSendSctp(AssociationImpl.java:680)
    at org.mobicents.protocols.sctp.AssociationImpl.doSend(AssociationImpl.java:674)
    at org.mobicents.protocols.sctp.AssociationImpl.write(AssociationImpl.java:593)
    at org.mobicents.protocols.sctp.SelectorThread.write(SelectorThread.java:436)
    at org.mobicents.protocols.sctp.SelectorThread.run(SelectorThread.java:157)
    at java.lang.Thread.run(Thread.java:745)
21 Jan 2015 15:03:47,885 [Thread-2] ERROR 
org.mobicents.protocols.sctp.AssociationImpl  - IOException while trying to 
write to underlying socket for Association=cookie.ei.lan.3730 IOError count=2
java.net.SocketException: Socket is shutdown for writing
    at sun.nio.ch.SctpChannelImpl.send0(Native Method)
    at sun.nio.ch.SctpChannelImpl.sendFromNativeBuffer(SctpChannelImpl.java:1039)
    at sun.nio.ch.SctpChannelImpl.send(SctpChannelImpl.java:991)
    at sun.nio.ch.SctpChannelImpl.send(SctpChannelImpl.java:971)
    at org.mobicents.protocols.sctp.AssociationImpl.doSendSctp(AssociationImpl.java:680)
    at org.mobicents.protocols.sctp.AssociationImpl.doSend(AssociationImpl.java:674)
    at org.mobicents.protocols.sctp.AssociationImpl.write(AssociationImpl.java:593)
    at org.mobicents.protocols.sctp.SelectorThread.write(SelectorThread.java:436)
    at org.mobicents.protocols.sctp.SelectorThread.run(SelectorThread.java:157)
    at java.lang.Thread.run(Thread.java:745)
21 Jan 2015 15:03:47,885 [Thread-2] ERROR 
org.mobicents.protocols.sctp.AssociationImpl  - IOException while trying to 
write to underlying socket for Association=cookie.ei.lan.3730 IOError count=3
java.net.SocketException: Socket is shutdown for writing
    at sun.nio.ch.SctpChannelImpl.send0(Native Method)
    at sun.nio.ch.SctpChannelImpl.sendFromNativeBuffer(SctpChannelImpl.java:1039)
    at sun.nio.ch.SctpChannelImpl.send(SctpChannelImpl.java:991)
    at sun.nio.ch.SctpChannelImpl.send(SctpChannelImpl.java:971)
    at org.mobicents.protocols.sctp.AssociationImpl.doSendSctp(AssociationImpl.java:680)
    at org.mobicents.protocols.sctp.AssociationImpl.doSend(AssociationImpl.java:674)
    at org.mobicents.protocols.sctp.AssociationImpl.write(AssociationImpl.java:593)
    at org.mobicents.protocols.sctp.SelectorThread.write(SelectorThread.java:436)
    at org.mobicents.protocols.sctp.SelectorThread.run(SelectorThread.java:157)
    at java.lang.Thread.run(Thread.java:745)
21 Jan 2015 15:03:47,886 [Thread-2] ERROR 
org.mobicents.protocols.sctp.AssociationImpl  - IOException while trying to 
write to underlying socket for Association=cookie.ei.lan.3730 IOError count=4
java.net.SocketException: Socket is shutdown for writing
    at sun.nio.ch.SctpChannelImpl.send0(Native Method)
    at sun.nio.ch.SctpChannelImpl.sendFromNativeBuffer(SctpChannelImpl.java:1039)
    at sun.nio.ch.SctpChannelImpl.send(SctpChannelImpl.java:991)
    at sun.nio.ch.SctpChannelImpl.send(SctpChannelImpl.java:971)
    at org.mobicents.protocols.sctp.AssociationImpl.doSendSctp(AssociationImpl.java:680)
    at org.mobicents.protocols.sctp.AssociationImpl.doSend(AssociationImpl.java:674)
    at org.mobicents.protocols.sctp.AssociationImpl.write(AssociationImpl.java:593)
    at org.mobicents.protocols.sctp.SelectorThread.write(SelectorThread.java:436)
    at org.mobicents.protocols.sctp.SelectorThread.run(SelectorThread.java:157)
    at java.lang.Thread.run(Thread.java:745)
21 Jan 2015 15:03:47,887 [Thread-2] WARN  
org.mobicents.protocols.sctp.AssociationImpl  - Clearig txQueue for 
Association=cookie.ei.lan.3730. 1 messages still pending will be cleared

Using Wireshark I can see the client connecting but the server immediately 
responds with a SHUTDOWN message. The following is written in the server log:

21 Jan 2015 15:54:28,523 [Thread-0] ERROR 
org.mobicents.protocols.sctp.SelectorThread  - Received connect request for 
Association=10.7.3.79:3730 but not started yet. Droping the connection! 

After stopping the server if I delete the server SCTP persist file 
(<host>_<port>_sctp.xml) then when the server is restarted the client and 
server successfully reconnect.

It looks like the server reads the persist file and loads the association that 
the client was using before it was stopped. It does not however start the 
association. When the client tries to connect to the server it fails as the 
association is not started.

Note that the server was stopped with control-c to simulate a hard crash.

Original issue reported on code.google.com by dpalmer...@gmail.com on 26 Feb 2015 at 2:48