OpenSmpp / opensmpp

OpenSmpp - Java library implementing the SMPP protocol, and allowing development of External Short Message Entities (ESMEs) and more.
http://opensmpp.org/
Other
188 stars 170 forks source link

Connection Timeout Issue #40

Closed puffyqi closed 4 years ago

puffyqi commented 5 years ago

Can anyone explain how does the below timeout works?

I try to make the connection expired in 6 seconds but the connection will hit more than 1 minutes for some of my transactions

paoloc0 commented 5 years ago

You could start by giving more detail. For example, are you talking about an SMPP server that you're writing, or a client? And what does "expired in 6 seconds" mean? Do you want the connection to close if no TCP response data has been received for the past 6 seconds?

If you're writing a client, this example may be useful: https://github.com/OpenSmpp/opensmpp/blob/247eb56cd38ba0055e72af87c3dcf371298e9306/core/src/test/java/org/smpp/ClientSessionUnbindIT.java#L99

puffyqi commented 5 years ago

Hi paoloc,

Thanks for replying my post.

Yes, I want to close the connection if no TCP response data has been received for the past 6 seconds on my SMPP client app.

I have set some timeout: connection.setCommsTimeout(5000) connection.setReceiveTimeout(5000) connection.setConnectionTimeout(5000) session.getReceiver().setReceiveTimeout(6000) session.getReceiver().setQueueWaitTimeout(6000)

I was doing a 20 transactions per second test. When I submit my message (calling session.submit(request)), it took some time to return a null response value.

paoloc0 commented 5 years ago

Hi. Within the statement "I want to close the connection if no TCP response data has been received for the past 6 seconds", we could further distinguish two possibilities:

  1. There is a network-level failure which has caused some TCP packets (not SMPP PDUs) sent by the client, to not be acknowledged by the server.
  2. The network layer is fine, but the server simply hasn't sent the PDUs you expect within 6 seconds.

For (1), clientConnection.setCommsTimeout() is useful, and an exception should be thrown to your calling code, which you could act upon.

For (2), no exception will be thrown, but rather, your calling code will have to decide for itself to act appropriately when, for example, calls to clientConnection.receive() produce no PDU within a certain amount of time. Other higher-level code such as Receiver.tryReceivePDU similarly lets you try to receive an expected PDU within a certain time.

If you don't find your answer somewhere above, please try to be very specific about the nature of your problem.