Skip to content
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

Receiver stops after a few hours with no traffic #34

Open
TomasMorecom opened this issue May 21, 2014 · 4 comments
Open

Receiver stops after a few hours with no traffic #34

TomasMorecom opened this issue May 21, 2014 · 4 comments

Comments

@TomasMorecom
Copy link

Hi. I am using SMPSession.connectAndBind() to set up a receiver (using BindType.BIND_RX). I have also sender class which binds using BIND_TX. The sender class seems to work ok all the time but after a few hours with no active sending from my side it seems like the receiver stops. After adding the pull request #25 I get some additional logging. AbstractSession.close() called. Does anyone know if there is a timeout setting which takes down the connection actively? Or may this be a result of some error?
I can set up additional logging and start debugging but would be grateful if anyone have experienced anything similar and know why.

10:29:01.898 INFO [MyClass.java:403] - Last logging from my app
16:51:24.364 INFO [AbstractSession.java:203] - AbstractSession.close() called
16:51:24.864 INFO [AbstractSession.java:203] - AbstractSession.close() called

Thanks.
Tomas

@SurfVaporizer
Copy link

Hello Toms, did you solve this problem? If yes, plz share the solution.

@TomasAndersen
Copy link

Hi, yes I did. I located two different things. First of all the shutdown some times caused a deadlock. I therefore wrote a patch to JSMPP to gracefully shut down the JSMPP threads to avoid deadlock. Sometimes the two threads (enquirelink and pdusender) seemed to wait for eachother. This patch is included in the updated JSMPP release on this page: http://jsmpp.org/

In addition I wrote my own watchdog. This watchdog is using the SMPPSession object to check if the sessionstate equals SessionState.CLOSED. In the case of a clean shutdown or if the connection to the SMSC somehow is down I found that the SessionState always was CLOSED. When this happens I create a new SMPPSession object and let the old one go out of scope.

Let me know if you have any more questions.

@SurfVaporizer
Copy link

Hello Tomas, thank you for quick response!
I tried to use last version of jsmpp 2.2.1 but still get same errors

This i get when i run AutoReconnect example

[main] INFO org.jsmpp.session.SMPPSession - Connected
[PDUReaderWorker: org.jsmpp.session.SMPPSession@3253be7c] INFO
org.jsmpp.session.SMPPSession - Starting PDUReaderWorker
Exception in thread "main" java.lang.NullPointerException
at org.jsmpp.bean.OptionalParameters.get(OptionalParameters.java:238)
at org.jsmpp.bean.BindResp.getOptionalParameter(BindResp.java:61)
at org.jsmpp.session.SMPPSession.sendBind(SMPPSession.java:297)
at org.jsmpp.session.SMPPSession.connectAndBind(SMPPSession.java:234)
at org.jsmpp.session.SMPPSession.connectAndBind(SMPPSession.java:201)
at org.jsmpp.session.SMPPSession.(SMPPSession.java:140)
at
org.jsmpp.examples.gateway.AutoReconnectGateway.newSession(AutoReconnectGateway.java:102)
at
org.jsmpp.examples.gateway.AutoReconnectGateway.(AutoReconnectGateway.java:68)
at
org.jsmpp.examples.gateway.AutoReconnectGateway.main(AutoReconnectGateway.java:174)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:134)
[PDUReaderWorker: org.jsmpp.session.SMPPSession@3253be7c] WARN
org.jsmpp.session.SMPPSession - IOException while reading: null
[PDUReaderWorker: org.jsmpp.session.SMPPSession@3253be7c] INFO
org.jsmpp.session.AbstractSession - AbstractSession.close() called
[PDUReaderWorker: org.jsmpp.session.SMPPSession@3253be7c] INFO
org.jsmpp.session.AbstractSession - AbstractSession.close() done
[PDUReaderWorker: org.jsmpp.session.SMPPSession@3253be7c] INFO
org.jsmpp.session.AbstractSession - AbstractSession.close() called
[PDUReaderWorker: org.jsmpp.session.SMPPSession@3253be7c] INFO
org.jsmpp.session.AbstractSession - AbstractSession.close() done
[PDUReaderWorker: org.jsmpp.session.SMPPSession@3253be7c] INFO
org.jsmpp.session.SMPPSession - PDUReaderWorker stop

Process finished with exit code 1

After ~1 minute connection is terminated with IOException while reading:
null
I use connection string like this

Gateway gateway = new AutoReconnectGateway("localhost", 5555,
new BindParameter(BindType.BIND_TRX, "xxx", "yyy", "",
TypeOfNumber.UNKNOWN, NumberingPlanIndicator.ISDN, ""));

On Mon, Apr 20, 2015 at 11:59 AM, Tomas Andersen [email protected]
wrote:

Hi, yes I did. I located two different things. First of all the shutdown
some times caused a deadlock. I therefore wrote a patch to JSMPP to
gracefully shut down the JSMPP threads to avoid deadlock. Sometimes the two
threads (enquirelink and pdusender) seemed to wait for eachother. This
patch is included in the updated JSMPP release on this page:
http://jsmpp.org/

In addition I wrote my own watchdog. This watchdog is using the
SMPPSession object to check if the sessionstate equals SessionState.CLOSED.
In the case of a clean shutdown or if the connection to the SMSC somehow is
down I found that the SessionState always was CLOSED. When this happens I
create a new SMPPSession object and let the old one go out of scope.

Let me know if you have any more questions.


Reply to this email directly or view it on GitHub
#34 (comment).

Best Regards

@TomasAndersen
Copy link

I havent tried running the example. Are you trying to set up a client or a server? I have successfully communicated with an SMSC as a client using this setup (deleted some private code and added some pseudocode but will give you an idea). I have a service object and a listener object. The service object has an additional method for sending text messages, the listener checks for incoming messages.

I do not know why your example fails and unfortunately I have no time to check it out. Try to ask on this github page instead: https://github.com/opentelecoms-org/jsmpp
(which is the new place)

public class MySmppListener implements MessageReceiverListener
...

public class MySmppService
{

public void start()
{
....

SmppGatewayConfig config; // POJO storing host, port, username, password for the smpp
                                              // connection
MyMessageHandler messageHandler = new MyMessageHandler();
..
session = new SMPPSession();
session.setMessageReceiverListener(new MySmppListener(messageHandler));
connectAndBind()
}

private void connectAndBind()
{
try
{
BindType bindType = BindType.BIND_TRX;
TypeOfNumber addrTon = TypeOfNumber.UNKNOWN;
NumberingPlanIndicator addrNpi = NumberingPlanIndicator.UNKNOWN;
String addressRange = null;
log.debug("Connect and bind (bindType = BindType.BIND_TRX)");
String result = session.connectAndBind(
gateway.host,
gateway.port,
new BindParameter(
bindType,
gateway.systemId,
gateway.password,
systemType,
addrTon,
addrNpi,
addressRange));
log.debug("Connect and bind result: {}", result);
}
catch (IOException e)
{
session.unbindAndClose();
throw new MySmppException("Failed connect and bind to host", e);
}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants