0

I try to run AutoReconnectGateway example from jsmpp library. My main task is to keep smpp session always connected to smpp server.

Submit and Deliver functions works good, i can send and get messages but after some time (~ 1 minute) whthout activity connection is terminated.

10:20:49.117 [ActiveMQ Session Task-1] INFO  org.jsmpp.session.SMPPSession - Connected

10:20:49.132 [Thread-4] INFO  org.jsmpp.session.SMPPSession - Starting PDUReaderWorker with processor degree:3 ...

10:20:49.888 [Thread-5] INFO  org.jsmpp.session.SMPPSession - Starting EnquireLinkSender

10:20:50.284 [pool-2-thread-1] INFO  ru.ts.oss.alertsmanager.SmsProcessorThread - SMS f46e6945 sent to 79663256299 with Message=Test Message - 1

10:20:55.634 [pool-3-thread-3] INFO  ru.ts.oss.alertsmanager.SmsMessageReceiverListenerImpl - Receiving delivery receipt for message 'F46E6945 ' from xxx to yyy : id:4100876613 sub:001 dlvrd:001 submit date:1504181220 done date:1504181121 stat:DELIVRD err:000 text:Test Message - 1

10:21:49.926 [Thread-4] INFO  ru.ts.oss.alertsmanager.gateway.SmsGateway - Session closed

10:21:49.927 [Thread-6] INFO  ru.ts.oss.alertsmanager.gateway.SmsGateway - Schedule reconnect after 5000 millis

10:21:49.927 [Thread-4] INFO  org.jsmpp.session.SMPPSession - PDUReaderWorker stop

10:21:51.675 [Thread-5] INFO  org.jsmpp.session.SMPPSession - EnquireLinkSender stop

For debug I put "e.printStackTrace();" in SMPPSession class line 586

        } catch (SocketTimeoutException e) {
            notifyNoActivity();
        } catch (IOException e) {
            logger.warn("IOException while reading: {}", e.getMessage());
            e.printStackTrace(); // God please don't forget about me!
            close();
        }
    }

This get from Stacktrace

3706 [PDUReaderWorker: org.jsmpp.session.SMPPSession@71f250e8] WARN org.jsmpp.session.SMPPSession - IOException while reading: null

java.io.EOFException
    at java.io.DataInputStream.readInt(DataInputStream.java:392)
    at org.jsmpp.DefaultPDUReader.readPDUHeader(DefaultPDUReader.java:40)
    at org.jsmpp.session.SMPPSession$PDUReaderWorker.readPDU(SMPPSession.java:619)
    at org.jsmpp.session.SMPPSession$PDUReaderWorker.run(SMPPSession.java:602)

Also i tried to change EnquireLinkTimer and TransactionTimer parameters, sniff traffic with tcpdumper, change versions of jsmpp library, read stackoverflow :) but had no luck, I still get same exception when no activity.

A lot of thanks.

Vaporizer
  • 1
  • 1
  • 1
  • You should include the code where you suspect that your exception raises. – Stephen Reindl Apr 18 '15 at 07:11
  • @StephenReindl I use standard code example from jsmpp lib. [https://code.google.com/p/jsmpp/source/browse/trunk/src/java/examples/org/jsmpp/examples/gateway/AutoReconnectGateway.java] – Vaporizer Apr 19 '15 at 06:13

1 Answers1

0

In 2.2.1 this has been fixed. But if for some reason you need to use 2.2.0-SNAPSHOT where the problem exists you can do the below

Go to the offending class OptionalParameters and added a check for parameters in the get method as seen below:

@SuppressWarnings("unchecked")
public static <U extends OptionalParameter> U get(Class<U> tagClass, OptionalParameter[] parameters) {
    if (parameters != null) { **//THIS IS THE CHANGE**
        for (OptionalParameter i : parameters) {

                if (i.getClass() == tagClass) {
                    return (U) i;
                }
            }
    }   
    logger.info("optional tag " + tagClass + " not found");
    return null;
}

I am not sure this is the best fix but it does let you use the examples correctly.

idipous
  • 2,868
  • 3
  • 30
  • 45