Skip to Main Content

Java APIs

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

java socket connection timeout taking more time when running in unix

902524Nov 28 2011 — edited Dec 1 2011
Hi

i have a code which uses Socket(ipaddress,port) constructor where we give ip and port.
when ever the ip port is not rechable its taking around 3 mins to time out when run in unix environment where as same thing is getting time out instantly in eclipse.

Please help me out with the same is there something explicitly mentioned in the unix env which takes more time to timout of socket connection

And just to add in the unix we have used glassfish server if the timeout not mentioned in unix then is it in the server level.

Comments

EJP
Is Eclipse running in the same environment? or is this really just a difference between the development environment and the Unix environment ... such as network connectivity? Can you ping the target from a shell in Unix?
902524
eclipse is run in windows environment and the other is unix. I want to know if ipaddress which is unreachable in both the environments(windows and unix). why in windows environment its socket getting timed out very fast where as the same code in unix its taking more time to get timed out. Is there anything related to unix environment which is resulting in the same and if yes can we decrease it in the unix level to get the time out faster
EJP
I say again. Can you ping the target from Unix?

Clearly the connectivity from Windows and Unix is different. Windows is getting an immediate response; Unix is not. This is not a Java issue.
902524
Can you please let me know if we are setting any default time out in unix level or can we find out anything related to unix level
i tried the ping test in unix and the ip is unrechable and 100% loss.
EJP
You can't get a connection timeout instantaneously, by definition. I conclude that you are getting a different error on Windows. Therefore the two systems must have different network connectivity.

I suspect that the Windows system is connected and has a route to the target so what you get is ConnectException 'connection refused', instantly, because the request gets through and the target system is able to send a response. Alternateively there is no route and you are getting NoRouteToHostException, also instantaneously. Or you are getting UnknownHostException instantaneously.

Conversely, as shown by 'ping', the Unix system isn't connected to or has no route to the target so the requests don't get through so there is no response so you get a ConnectionTimeoutException.

It has nothing to do with Java and nothing to do with the Unix system configuration either other than its network connectivity, which is determined by routers and routing tables.
handat
Your problem is not a java problem but a network stack configuration issue. When you say UNIX, I assume you mean Solaris? If that is the case, the ndd command can be used to view the various network settings including default timeout values. You can also use ndd to change the settings, eg: ndd -set /dev/tcp tcp_time_wait_interval 30000
1 - 6
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Dec 29 2011
Added on Nov 28 2011
6 comments
995 views