Hi there.
What is the timeout after which you see the disconnects? Does it happen only when there are no transactions or also when there are?
--
--
jPOS is licensed under AGPL - free for community usage for your open-source project. Licenses are also available for commercial usage. Please support jPOS, contact: sa...@jpos.org
---
You received this message because you are subscribed to the Google Groups "jPOS Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jpos-users+...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/jpos-users/0b234979-3a01-4dc4-bf89-0d4bf3a339f1n%40googlegroups.com.
The 5-second timeout you’ve configured is used to set the socket’s soTimeout. This defines how long the socket will wait for data to arrive during a read operation before throwing a SocketTimeoutException.
A good way to understand how this works is to look at the logs and trace it in the jPOS source code. All channel implementations in jPOS extend BaseChannel, which contains the relevant logic:
BaseChannel.java – lines 393–400
If your application sends periodic network message request responses (like ECHOs), that traffic will keep the connection active. You can also adjust the timeout value based on your understanding of expected message frequency — it’s perfectly fine to set it higher if needed.
When soTimeout is set, the channel blocks while reading bytes in the getMessageLength() method ( in the channel implementation of your configured channel). If no data arrives within the timeout window (e.g., 5 seconds), a SocketTimeoutException is thrown. Internally, this is caught as an InterruptedIOException, and you’ll see it logged as an “io-timeout” message.
-chhil
Thank You Chhil for your explanation.
As the server does not recommend sending echo messages to keep the connection active, and also expects the connection to be held once established, we are planning the following approach:
Channel timeout is set to 2 hours to maintain the connection for a longer duration:
Request timeout is set to 30 seconds:
This approach helps us by maintaining the connection for longer period. If there is no activity, the connection times out after 2hrs and reconnects to the server. Additionally, individual requests will timeout after 30 seconds if no response is received from the server.
Is this a good approach?
To view this discussion visit https://groups.google.com/d/msgid/jpos-users/ab4e19d8-da29-49cd-bb09-ef0291ee8a91n%40googlegroups.com.
Hi Apr.
I think car is confused and has swapped to revising connection-timeout instead of
<property name="timeout" value="5000" />
@csr ch ge the right value, but speak to the central server and ask for some form of keep-alive so both they and you can know about and recover any outage.
Failing that perhaps generate some traffic that won't approve but you can send within the timeout period sonthatbifbthe connection does break you can eal with it sooner instead of when you have a request to deliver.
--
Mark
To view this discussion visit https://groups.google.com/d/msgid/jpos-users/CAAgSK%3DkDWaPSf6%3D%3D7Vx8d_x5DfKgAJSXf2OtuQogpiUmC5y4SQ%40mail.gmail.com.
Apologies for the earlier confusion, what I mentioned was incorrect.
<property name="connection-timeout" value="5000" />
The connect-timeout property specifies the maximum amount of time, in milliseconds, that the channel will wait to establish a TCP/IP connection to the remote host.
If the connection is successfully established within this time, the process continues.
If
the remote host doesn't respond within this time (e.g., the server is
down, a firewall is blocking the port, or the network is very slow), a java.net.SocketTimeoutException is thrown, and the connection attempt fails. The ChannelAdaptor will then typically wait for its reconnect-delay and try again.
// org.jpos.iso.BaseChannel
public void setConfiguration (Configuration cfg)
throws ConfigurationException
{
// ...
try {
// First, the socket read timeout is set (defaults to 300000ms)
setTimeout (cfg.getInt ("timeout", DEFAULT_TIMEOUT));
// Then, connect-timeout is set.
// *** IMPORTANT: If not specified, it defaults to the value of 'timeout' ***
connectTimeout = cfg.getInt ("connect-timeout", timeout);
} catch (SocketException e) {
throw new ConfigurationException (e);
}
}
You need to figure out what value is good for your "timeout". You do not need to worry about "connect-timeout", and if you do want to set it it can be a very small value.
// org.jpos.iso.BaseChannel