spring-integration-extensions
spring-integration-extensions copied to clipboard
SMPP: Autoreconnect doesn't work
I try to see if the reconnection to the server works, so I kill my smpp server and restart it. the client never manage to restore the connection.
see the log :
17:52:57 INFO o.j.s.AbstractSession - executeSendCommand
17:52:57 INFO o.j.s.AbstractSession - commandID:80000015 status:00000000 sequence:16
17:53:02 INFO o.j.s.AbstractSession - EnquireLinkSender.run() send
17:53:02 INFO o.j.s.AbstractSession - executeSendCommand
17:53:02 INFO o.j.s.AbstractSession - commandID:80000015 status:00000000 sequence:17
17:53:07 INFO o.j.s.AbstractSession - EnquireLinkSender.run() send
17:53:07 INFO o.j.s.AbstractSession - executeSendCommand
17:53:07 INFO o.j.s.AbstractSession - commandID:80000015 status:00000000 sequence:18
17:53:09 WARN o.j.s.SMPPSession - IOException while reading: null
17:53:09 WARN o.j.s.AbstractSession - closing enquireLinkSender Thread[EnquireLinkSender: org.jsmpp.session.SMPPSession@7b3dd80d,5,main]
17:53:09 WARN o.j.s.AbstractSession - closing enquireLinkSender alive:true daemon:true interrupted:false
17:53:09 INFO o.j.s.AbstractSession - JOINED!!!
17:53:09 WARN o.j.s.AbstractSession - closing enquireLinkSender Thread[EnquireLinkSender: org.jsmpp.session.SMPPSession@7b3dd80d,5,]
17:53:09 WARN o.j.s.AbstractSession - closing enquireLinkSender alive:false daemon:true interrupted:false
17:53:09 INFO o.j.s.SMPPSession - PDUReaderWorker stop
17:53:16 ERROR o.s.i.s.s.SmppSessionFactoryBean$AutoReconnectLifecycle - Error happened when trying to connect to localhost:20775. Cause: Failed connecting
17:53:23 ERROR o.s.i.s.s.SmppSessionFactoryBean$AutoReconnectLifecycle - Error happened when trying to connect to localhost:20775. Cause: Failed connecting
17:53:46 ERROR o.s.i.s.s.SmppSessionFactoryBean$AutoReconnectLifecycle - Error happened when trying to connect to localhost:20775. Cause: Failed connecting
17:53:53 ERROR o.s.i.s.s.SmppSessionFactoryBean$AutoReconnectLifecycle - Error happened when trying to connect to localhost:20775. Cause: Failed connecting
17:54:16 ERROR o.s.i.s.s.SmppSessionFactoryBean$AutoReconnectLifecycle - Error happened when trying to connect to localhost:20775. Cause: Failed connecting
17:54:23 ERROR o.s.i.s.s.SmppSessionFactoryBean$AutoReconnectLifecycle - Error happened when trying to connect to localhost:20775. Cause: Failed connecting
17:54:46 ERROR o.s.i.s.s.SmppSessionFactoryBean$AutoReconnectLifecycle - Error happened when trying to connect to localhost:20775. Cause: Failed connecting
17:54:53 ERROR o.s.i.s.s.SmppSessionFactoryBean$AutoReconnectLifecycle - Error happened when trying to connect to localhost:20775. Cause: Failed connecting
17:55:16 ERROR o.s.i.s.s.SmppSessionFactoryBean$AutoReconnectLifecycle - Error happened when trying to connect to localhost:20775. Cause: Failed connecting
17:55:23 ERROR o.s.i.s.s.SmppSessionFactoryBean$AutoReconnectLifecycle - Error happened when trying to connect to localhost:20775. Cause: Failed connecting
17:55:46 ERROR o.s.i.s.s.SmppSessionFactoryBean$AutoReconnectLifecycle - Error happened when trying to connect to localhost:20775. Cause: Failed connecting
17:55:53 ERROR o.s.i.s.s.SmppSessionFactoryBean$AutoReconnectLifecycle - Error happened when trying to connect to localhost:20775. Cause: Failed connecting
17:56:16 ERROR o.s.i.s.s.SmppSessionFactoryBean$AutoReconnectLifecycle - Error happened when trying to connect to localhost:20775. Cause: Failed connecting
17:56:23 ERROR o.s.i.s.s.SmppSessionFactoryBean$AutoReconnectLifecycle - Error happened when trying to connect to localhost:20775. Cause: Failed connecting
Can you show your configuration? I just tested (using the TestSmppConnection
test case and it worked fine for me...
13:26:32.955 INFO [Thread-0][org.springframework.integration.smpp.session.SmppSessionFactoryBean$AutoReconnectLifecycle] Session to localhost:11111 has been closed. Try to reconnect later
13:26:32.955 INFO [Thread-2][org.springframework.integration.smpp.session.SmppSessionFactoryBean$AutoReconnectLifecycle] Session to localhost:11111 has been closed. Try to reconnect later
13:26:37.961 INFO [pool-2-thread-1][org.springframework.integration.smpp.session.SmppSessionFactoryBean$AutoReconnectLifecycle] Reconnecting attempt #1 ...
13:26:37.961 INFO [pool-4-thread-1][org.springframework.integration.smpp.session.SmppSessionFactoryBean$AutoReconnectLifecycle] Reconnecting attempt #1 ...
13:26:37.963 ERROR [pool-4-thread-1][org.springframework.integration.smpp.session.SmppSessionFactoryBean$AutoReconnectLifecycle] Error happened when trying to connect to localhost:11111. Cause: Connection refused
13:26:37.963 ERROR [pool-2-thread-1][org.springframework.integration.smpp.session.SmppSessionFactoryBean$AutoReconnectLifecycle] Error happened when trying to connect to localhost:11111. Cause: Connection refused
...
13:27:02.981 INFO [pool-2-thread-1][org.springframework.integration.smpp.session.SmppSessionFactoryBean$AutoReconnectLifecycle] Reconnecting attempt #6 ...
13:27:02.981 INFO [pool-4-thread-1][org.springframework.integration.smpp.session.SmppSessionFactoryBean$AutoReconnectLifecycle] Reconnecting attempt #6 ...
13:27:03.347 INFO [pool-4-thread-1][org.springframework.integration.smpp.session.SmppSessionFactoryBean$AutoReconnectLifecycle] Successfully reconnect at attempt #6
13:27:03.347 INFO [pool-2-thread-1][org.springframework.integration.smpp.session.SmppSessionFactoryBean$AutoReconnectLifecycle] Successfully reconnect at attempt #6
If you enable DEBUG logging, you'll get more information about the "error happened" exception.
to do the test reconnection I "kill -9" my smmp server so I have this with debug trace level :
08:59:04 DEBUG o.j.s.SMPPSession - No activity notified, sending enquireLink 08:59:04 INFO o.j.s.AbstractSession - EnquireLinkSender.run() send 08:59:04 INFO o.j.s.AbstractSession - executeSendCommand 08:59:04 DEBUG o.j.DefaultPDUSender - Sending SMPP message 00 00 00 10 00 00 00 15 00 00 00 00 00 00 00 07 08:59:04 DEBUG o.j.s.PDUProcessTask - Received SMPP message PDUHeader(16, 80000015, 00000000, 7) 08:59:04 DEBUG o.j.s.AbstractSession - enquire_link response received 08:59:04 INFO o.j.s.AbstractSession - commandID:80000015 status:00000000 sequence:7 08:59:08 WARN o.j.s.SMPPSession - IOException while reading: null 08:59:08 DEBUG o.j.s.AbstractSession - AbstractSession.close() called Exception in thread "PDUReaderWorker: org.jsmpp.session.SMPPSession@7ab042ba" java.lang.AbstractMethodError at org.jsmpp.session.AbstractSessionContext.fireStateChanged(AbstractSessionContext.java:79) at org.jsmpp.session.SMPPSessionContext.changeState(SMPPSessionContext.java:61) at org.jsmpp.session.AbstractSessionContext.close(AbstractSessionContext.java:62) at org.jsmpp.session.AbstractSession.close(AbstractSession.java:208) at org.jsmpp.session.SMPPSession$PDUReaderWorker.readPDU(SMPPSession.java:626) at org.jsmpp.session.SMPPSession$PDUReaderWorker.run(SMPPSession.java:582) 08:59:09 DEBUG o.j.s.AbstractSession - EnquireLinkSender stop 08:59:17 ERROR o.s.i.s.s.SmppSessionFactoryBean$AutoReconnectLifecycle - Error happened when trying to connect to localhost:20775. Cause: Failed connecting 08:59:24 ERROR o.s.i.s.s.SmppSessionFactoryBean$AutoReconnectLifecycle - Error happened when trying to connect to localhost:20775. Cause: Failed connecting
may It can be an effect : I replace the version of the deprecated jsmpp (see https://code.google.com/archive/p/jsmpp/) by the new one. To do this I have change the pom like this :
<dependency>
<groupId>org.springframework.integration</groupId>
<artifactId>spring-integration-smpp</artifactId>
<version>1.0.0.RELEASE</version>
<exclusions>
<exclusion>
<groupId>com.googlecode.jsmpp</groupId>
<artifactId>jsmpp</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.jsmpp</groupId>
<artifactId>jsmpp</artifactId>
<version>2.2.3</version>
</dependency>
the SessionListener interface has change : from : public void onStateChange(SessionState newState, SessionState oldState, Object arg2) to public void onStateChange(SessionState newState, SessionState oldState, Session source)
We don't currently support that version of the client; we'll use this issue to update to it when we get some spare time - of course, contributions are always welcome.
I'll try to do this contribution but I'm not yet familiar with gradle environment I usually use maven ;-)
This quick hack seems to work (at least all the tests pass). Note that I didn't provide implementations (yet) for the new methods on the session.