Loading
SocketTimeoutException

Java Quick Notes

Refresh Your Java - Before Java Interview

We are Agile, believe in less Documentation - Only Quick notes (Java Interview Questions) of Java/J2ee Read more....


Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet

Go to SiteMap

Q)  How to solve SocketTimeoutException ?


Ans)

Socket Timeout would occur if the Client Socket (may be Tcp/Http/Soap clients) does not get
the response in configured timeframe for any given request, in order to avoid this you need
to change the Client Socket Timeout settings as shown below.

If you encounter this issue while making a Web Service call, the APIs like Axis, CFX etc.,
have some default Socket Timeout settings, you may need to override those.

If you create your own HTTP you need to have that set up on your own.

Either way setting SocketTimeout is really important, if not the Client may wait for an
undefined amount of time for the response which may hung your applications.

HTTP Client:
httpclient.getParams().setParameter("http.socket.timeout", new Integer(1000));

In Axis 1.4
Override the Default Value as shown below in the ServicePort class.

AxisProperties.setProperty(org.apache.axis.components.net.
   DefaultCommonsHTTPClientProperties.CONNECTION_DEFAULT_SO_TIMEOUT_KEY, '10000');
 

AxisProperties.setProperty(org.apache.axis.components.net.
        DefaultCommonsHTTPClientProperties. CONNECTION_DEFAULT_CONNECTION_TIMEOUT_KEY,

10000');


Please note if this Timeout happens due to network issues or Performance issue , you may need
to handle them separately.



Back to top

------------------------- We hope you got necessary Info On -----------------------------------------

SocketTimeoutException


SocketTimeoutException

-------------------------------------------------------------------------------------------------------



Face Book
Request for a Mock Interview/Training

Get a PDF

Face Book
Same look (Read) on any device, this is Ads free