How so I fix java.net.SocketTimeoutException: Read timed out
<p>I am using Axix2 for web service, I am using jboss 5.1.
my application was running fine, but Now every time i am getting </p>

<blockquote>
  <p>java.net.SocketTimeoutException: Read timed out</p>
</blockquote>

<p>Bellow is the stack trace</p>

<p><div class="snippet" data-lang="js" data-hide="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code>Caused by: java.net.SocketTimeoutException: Read timed out
17:00:36,231 ERROR [STDERR]  at java.net.SocketInputStream.socketRead0(Native Method)
17:00:36,231 ERROR [STDERR]  at java.net.SocketInputStream.read(SocketInputStream.java:129)
17:00:36,231 ERROR [STDERR]  at com.sun.net.ssl.internal.ssl.InputRecord.readFully(InputRecord.java:422)
17:00:36,231 ERROR [STDERR]  at com.sun.net.ssl.internal.ssl.InputRecord.read(InputRecord.java:460)
17:00:36,231 ERROR [STDERR]  at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:863)
17:00:36,231 ERROR [STDERR]  at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readDataRecord(SSLSocketImpl.java:820)
17:00:36,231 ERROR [STDERR]  at com.sun.net.ssl.internal.ssl.AppInputStream.read(AppInputStream.java:75)
17:00:36,231 ERROR [STDERR]  at java.io.BufferedInputStream.fill(BufferedInputStream.java:218)
17:00:36,231 ERROR [STDERR]  at java.io.BufferedInputStream.read(BufferedInputStream.java:237)
17:00:36,231 ERROR [STDERR]  at org.apache.commons.httpclient.HttpParser.readRawLine(HttpParser.java:78)
17:00:36,231 ERROR [STDERR]  at org.apache.commons.httpclient.HttpParser.readLine(HttpParser.java:106)
17:00:36,231 ERROR [STDERR]  at org.apache.commons.httpclient.HttpConnection.readLine(HttpConnection.java:1116)
17:00:36,231 ERROR [STDERR]  at org.apache.commons.httpclient.MultiThreadedHttpConnectionManager$HttpConnectionAdapter.readLine(MultiThreadedHttpConnectionManager.java:1413)
17:00:36,231 ERROR [STDERR]  at org.apache.commons.httpclient.HttpMethodBase.readStatusLine(HttpMethodBase.java:1973)
17:00:36,231 ERROR [STDERR]  at org.apache.commons.httpclient.HttpMethodBase.readResponse(HttpMethodBase.java:1735)
17:00:36,231 ERROR [STDERR]  at org.apache.commons.httpclient.HttpMethodBase.execute(HttpMethodBase.java:1098)
17:00:36,231 ERROR [STDERR]  at org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:398)
17:00:36,231 ERROR [STDERR]  at org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:171)
17:00:36,231 ERROR [STDERR]  at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:397)
17:00:36,231 ERROR [STDERR]  at org.apache.axis2.transport.http.AbstractHTTPSender.executeMethod(AbstractHTTPSender.java:621)
17:00:36,241 ERROR [STDERR]  at org.apache.axis2.transport.http.HTTPSender.sendViaPost(HTTPSender.java:193)</code></pre>
</div>
</div>
</p>

<p>I searched on the net, and figured it out that i need to increase socket time out.</p>

<p>so this is the solution i got from <a href="https://axis.apache.org/axis2/java/core/docs/http-transport.html#timeout_config" rel="nofollow">Apache foundation</a></p>

<p><div class="snippet" data-lang="js" data-hide="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code>Timeout Configuration

Two timeout instances exist in the transport level, Socket timeout and Connection timeout. These can be configured either at deployment or run time. If configuring at deployment time, the user has to add the following lines in axis2.xml.

For Socket timeout:

&lt;parameter name="SO_TIMEOUT"&gt;some_integer_value&lt;/parameter&gt;

For Connection timeout:

 &lt;parameter name="CONNECTION_TIMEOUT"&gt;some_integer_value&lt;/parameter&gt;


For runtime configuration, it can be set as follows within the client stub:

...
Options options = new Options();
options.setProperty(HTTPConstants.SO_TIMEOUT, new Integer(timeOutInMilliSeconds));
options.setProperty(HTTPConstants.CONNECTION_TIMEOUT, new Integer(timeOutInMilliSeconds));

// or
options.setTimeOutInMilliSeconds(timeOutInMilliSeconds);
...</code></pre>
</div>
</div>
</p>

<p><strong>The First thing i tried is this.</strong></p>

<p><code>options.setTimeOutInMilliSeconds(timeOutInMilliSeconds);</code></p>

<p>After doing this still I get bellow error.</p>

<blockquote>
  <p>java.net.SocketTimeoutException: Read timed out</p>
</blockquote>

<p><strong>Second Approach I try to do that is to modify my axis2.xml</strong> </p>

<p>So,I checked out <code>axis2-1.6.2.jar</code> and looked for axis2.xml.</p>

<p>and try to find out bellow parameter in my <code>axis2.xml</code></p>

<pre><code>&lt;parameter name="SO_TIMEOUT"&gt;some_integer_value&lt;/parameter&gt;
&lt;parameter name="CONNECTION_TIMEOUT"&gt;some_integer_value&lt;/parameter&gt;
</code></pre>

<p>Bellow is content of my <code>axis2.xml</code> but i do not see any parameter as above.</p>

<p>I have remove all the comment form <code>axis2.xml</code> to shorten he length of question.<br>
<div class="snippet" data-lang="js" data-hide="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;axisconfig name="AxisJava2.0"&gt;
  
    &lt;parameter name="hotdeployment"&gt;true&lt;/parameter&gt;
    &lt;parameter name="hotupdate"&gt;false&lt;/parameter&gt;
    &lt;parameter name="enableMTOM"&gt;false&lt;/parameter&gt;
    &lt;parameter name="enableSwA"&gt;false&lt;/parameter&gt;
    &lt;parameter name="EnableChildFirstClassLoading"&gt;false&lt;/parameter&gt;
    &lt;parameter name="exposeServiceMetadata"&gt;true&lt;/parameter&gt;
    &lt;parameter name="ConfigContextTimeoutInterval"&gt;30000&lt;/parameter&gt;
    &lt;parameter name="sendStacktraceDetailsWithFaults"&gt;false&lt;/parameter&gt;
    &lt;parameter name="DrillDownToRootCauseForFaultReason"&gt;false&lt;/parameter&gt;
    &lt;parameter name="userName"&gt;admin&lt;/parameter&gt;
    &lt;parameter name="password"&gt;axis2&lt;/parameter&gt;
    &lt;parameter name="disableREST" locked="false"&gt;false&lt;/parameter&gt;
    &lt;parameter name="disableSOAP12" locked="true"&gt;false&lt;/parameter&gt;
    &lt;deployer extension=".class" directory="pojo" class="org.apache.axis2.deployment.POJODeployer"/&gt;
    &lt;deployer extension=".jar" directory="servicejars"
              class="org.apache.axis2.jaxws.framework.JAXWSDeployer"/&gt;
    &lt;deployer extension=".jar" directory="transports"
              class="org.apache.axis2.deployment.TransportDeployer"/&gt;
    &lt;parameter name="useGeneratedWSDLinJAXWS"&gt;false&lt;/parameter&gt;
    &lt;threadContextMigrators&gt;
        &lt;threadContextMigrator listId="JAXWS-ThreadContextMigrator-List"
                               class="org.apache.axis2.jaxws.addressing.migrator.EndpointContextMapMigrator"/&gt;
    &lt;/threadContextMigrators&gt;

    &lt;messageReceivers&gt;
        &lt;messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-only"
                         class="org.apache.axis2.receivers.RawXMLINOnlyMessageReceiver"/&gt;
        &lt;messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-out"
                         class="org.apache.axis2.receivers.RawXMLINOutMessageReceiver"/&gt;
        &lt;messageReceiver mep="http://www.w3.org/2006/01/wsdl/in-only"
                         class="org.apache.axis2.receivers.RawXMLINOnlyMessageReceiver"/&gt;
        &lt;messageReceiver mep="http://www.w3.org/2006/01/wsdl/in-out"
                         class="org.apache.axis2.receivers.RawXMLINOutMessageReceiver"/&gt;
        &lt;messageReceiver mep="http://www.w3.org/ns/wsdl/in-only"
                         class="org.apache.axis2.receivers.RawXMLINOnlyMessageReceiver"/&gt;
        &lt;messageReceiver mep="http://www.w3.org/ns/wsdl/in-out"
                         class="org.apache.axis2.receivers.RawXMLINOutMessageReceiver"/&gt;
    &lt;/messageReceivers&gt;
    &lt;messageFormatters&gt;
        &lt;messageFormatter contentType="application/x-www-form-urlencoded"
                          class="org.apache.axis2.transport.http.XFormURLEncodedFormatter"/&gt;
        &lt;messageFormatter contentType="multipart/form-data"
                          class="org.apache.axis2.transport.http.MultipartFormDataFormatter"/&gt;
        &lt;messageFormatter contentType="application/xml"
                          class="org.apache.axis2.transport.http.ApplicationXMLFormatter"/&gt;
        &lt;messageFormatter contentType="text/xml"
                          class="org.apache.axis2.transport.http.SOAPMessageFormatter"/&gt;
        &lt;messageFormatter contentType="application/soap+xml"
                          class="org.apache.axis2.transport.http.SOAPMessageFormatter"/&gt;
    &lt;/messageFormatters&gt;
    &lt;messageBuilders&gt;
        &lt;messageBuilder contentType="application/xml"
                        class="org.apache.axis2.builder.ApplicationXMLBuilder"/&gt;
        &lt;messageBuilder contentType="application/x-www-form-urlencoded"
                        class="org.apache.axis2.builder.XFormURLEncodedBuilder"/&gt;
        &lt;messageBuilder contentType="multipart/form-data"
                        class="org.apache.axis2.builder.MultipartFormDataBuilder"/&gt;
    &lt;/messageBuilders&gt;

  
    &lt;transportReceiver name="http"
                       class="org.apache.axis2.transport.http.SimpleHTTPServer"&gt;
        &lt;parameter name="port"&gt;8080&lt;/parameter&gt;
     
    &lt;/transportReceiver&gt;

    &lt;transportSender name="local"
                     class="org.apache.axis2.transport.local.LocalTransportSender"/&gt;
    &lt;transportSender name="http"
                     class="org.apache.axis2.transport.http.CommonsHTTPTransportSender"&gt;
        &lt;parameter name="PROTOCOL"&gt;HTTP/1.1&lt;/parameter&gt;
        &lt;parameter name="Transfer-Encoding"&gt;chunked&lt;/parameter&gt;

    &lt;/transportSender&gt;

    &lt;transportSender name="https"
                     class="org.apache.axis2.transport.http.CommonsHTTPTransportSender"&gt;
        &lt;parameter name="PROTOCOL"&gt;HTTP/1.1&lt;/parameter&gt;
        &lt;parameter name="Transfer-Encoding"&gt;chunked&lt;/parameter&gt;
    &lt;/transportSender&gt;

    &lt;module ref="addressing"/&gt;
    &lt;clustering class="org.apache.axis2.clustering.tribes.TribesClusteringAgent" enable="false"&gt;
        &lt;parameter name="AvoidInitiation"&gt;true&lt;/parameter&gt;
        &lt;parameter name="membershipScheme"&gt;multicast&lt;/parameter&gt;
        &lt;parameter name="domain"&gt;wso2.carbon.domain&lt;/parameter&gt;
        &lt;parameter name="synchronizeAll"&gt;true&lt;/parameter&gt;
        &lt;parameter name="maxRetries"&gt;10&lt;/parameter&gt;
        &lt;parameter name="mcastAddress"&gt;228.0.0.4&lt;/parameter&gt;
        &lt;parameter name="mcastPort"&gt;45564&lt;/parameter&gt;
        &lt;parameter name="mcastFrequency"&gt;500&lt;/parameter&gt;
        &lt;parameter name="memberDropTime"&gt;3000&lt;/parameter&gt;
        &lt;parameter name="mcastBindAddress"&gt;127.0.0.1&lt;/parameter&gt;
        &lt;parameter name="localMemberHost"&gt;127.0.0.1&lt;/parameter&gt;
        &lt;parameter name="localMemberPort"&gt;4000&lt;/parameter&gt;
        &lt;parameter name="preserveMessageOrder"&gt;true&lt;/parameter&gt;
        &lt;parameter name="atmostOnceMessageSemantics"&gt;true&lt;/parameter&gt;
        &lt;parameter name="properties"&gt;
            &lt;property name="backendServerURL" value="https://${hostName}:${httpsPort}/services/"/&gt;
            &lt;property name="mgtConsoleURL" value="https://${hostName}:${httpsPort}/"/&gt;
        &lt;/parameter&gt;
        &lt;members&gt;
            &lt;member&gt;
                &lt;hostName&gt;127.0.0.1&lt;/hostName&gt;
                &lt;port&gt;4000&lt;/port&gt;
            &lt;/member&gt;
            &lt;member&gt;
                &lt;hostName&gt;127.0.0.1&lt;/hostName&gt;
                &lt;port&gt;4001&lt;/port&gt;
            &lt;/member&gt;
        &lt;/members&gt;
        &lt;groupManagement enable="false"&gt;
            &lt;applicationDomain name="apache.axis2.application.domain"
                               description="Axis2 group"
                               agent="org.apache.axis2.clustering.management.DefaultGroupManagementAgent"/&gt;
        &lt;/groupManagement&gt;
        &lt;nodeManager class="org.apache.axis2.clustering.management.DefaultNodeManager"
                         enable="true"/&gt;
        &lt;stateManager class="org.apache.axis2.clustering.state.DefaultStateManager"
                      enable="true"&gt;
            &lt;replication&gt;
                &lt;defaults&gt;
                    &lt;exclude name="local_*"/&gt;
                    &lt;exclude name="LOCAL_*"/&gt;
                &lt;/defaults&gt;
                &lt;context class="org.apache.axis2.context.ConfigurationContext"&gt;
                    &lt;exclude name="local_*"/&gt;
                &lt;/context&gt;
                &lt;context class="org.apache.axis2.context.ServiceGroupContext"&gt;
                    &lt;exclude name="local_*"/&gt;
                &lt;/context&gt;
                &lt;context class="org.apache.axis2.context.ServiceContext"&gt;
                    &lt;exclude name="local_*"/&gt;
                &lt;/context&gt;
            &lt;/replication&gt;
        &lt;/stateManager&gt;
    &lt;/clustering&gt;
    &lt;phaseOrder type="InFlow"&gt;
        &lt;!--  System predefined phases       --&gt;
        &lt;phase name="Transport"&gt;
            &lt;handler name="RequestURIBasedDispatcher"
                     class="org.apache.axis2.dispatchers.RequestURIBasedDispatcher"&gt;
                &lt;order phase="Transport"/&gt;
            &lt;/handler&gt;
            &lt;handler name="SOAPActionBasedDispatcher"
                     class="org.apache.axis2.dispatchers.SOAPActionBasedDispatcher"&gt;
                &lt;order phase="Transport"/&gt;
            &lt;/handler&gt;
        &lt;/phase&gt;
        &lt;phase name="Addressing"&gt;
            &lt;handler name="AddressingBasedDispatcher"
                     class="org.apache.axis2.dispatchers.AddressingBasedDispatcher"&gt;
                &lt;order phase="Addressing"/&gt;
            &lt;/handler&gt;
        &lt;/phase&gt;
        &lt;phase name="Security"/&gt;
        &lt;phase name="PreDispatch"/&gt;
        &lt;phase name="Dispatch" class="org.apache.axis2.engine.DispatchPhase"&gt;
            &lt;handler name="RequestURIBasedDispatcher"
                     class="org.apache.axis2.dispatchers.RequestURIBasedDispatcher"/&gt;
            &lt;handler name="SOAPActionBasedDispatcher"
                     class="org.apache.axis2.dispatchers.SOAPActionBasedDispatcher"/&gt;
            &lt;handler name="RequestURIOperationDispatcher"
                     class="org.apache.axis2.dispatchers.RequestURIOperationDispatcher"/&gt;
            &lt;handler name="SOAPMessageBodyBasedDispatcher"
                     class="org.apache.axis2.dispatchers.SOAPMessageBodyBasedDispatcher"/&gt;
            &lt;handler name="HTTPLocationBasedDispatcher"
                     class="org.apache.axis2.dispatchers.HTTPLocationBasedDispatcher"/&gt;
            &lt;handler name="GenericProviderDispatcher"
                     class="org.apache.axis2.jaxws.dispatchers.GenericProviderDispatcher"/&gt;
            &lt;handler name="MustUnderstandValidationDispatcher"
                     class="org.apache.axis2.jaxws.dispatchers.MustUnderstandValidationDispatcher"/&gt;
        &lt;/phase&gt;
        &lt;phase name="RMPhase"/&gt;
        &lt;phase name="OperationInPhase"&gt;
            &lt;handler name="MustUnderstandChecker"
                     class="org.apache.axis2.jaxws.dispatchers.MustUnderstandChecker"&gt;
                &lt;order phase="OperationInPhase"/&gt;
            &lt;/handler&gt;
        &lt;/phase&gt;
        &lt;phase name="soapmonitorPhase"/&gt;
    &lt;/phaseOrder&gt;
    &lt;phaseOrder type="OutFlow"&gt;
    
        &lt;phase name="soapmonitorPhase"/&gt;
        &lt;phase name="OperationOutPhase"/&gt;
        &lt;!--system predefined phase--&gt;
        &lt;!--these phase will run irrespective of the service--&gt;
        &lt;phase name="RMPhase"/&gt;
        &lt;phase name="PolicyDetermination"/&gt;
        &lt;phase name="MessageOut"/&gt;
        &lt;phase name="Security"/&gt;
    &lt;/phaseOrder&gt;
    &lt;phaseOrder type="InFaultFlow"&gt;
        &lt;phase name="Addressing"&gt;
            &lt;handler name="AddressingBasedDispatcher"
                     class="org.apache.axis2.dispatchers.AddressingBasedDispatcher"&gt;
                &lt;order phase="Addressing"/&gt;
            &lt;/handler&gt;
        &lt;/phase&gt;
        &lt;phase name="Security"/&gt;
        &lt;phase name="PreDispatch"/&gt;
        &lt;phase name="Dispatch" class="org.apache.axis2.engine.DispatchPhase"&gt;
            &lt;handler name="RequestURIBasedDispatcher"
                     class="org.apache.axis2.dispatchers.RequestURIBasedDispatcher"/&gt;
            &lt;handler name="SOAPActionBasedDispatcher"
                     class="org.apache.axis2.dispatchers.SOAPActionBasedDispatcher"/&gt;
            &lt;handler name="RequestURIOperationDispatcher"
                     class="org.apache.axis2.dispatchers.RequestURIOperationDispatcher"/&gt;
            &lt;handler name="SOAPMessageBodyBasedDispatcher"
                     class="org.apache.axis2.dispatchers.SOAPMessageBodyBasedDispatcher"/&gt;
            &lt;handler name="HTTPLocationBasedDispatcher"
                     class="org.apache.axis2.dispatchers.HTTPLocationBasedDispatcher"/&gt;
            &lt;handler name="GenericProviderDispatcher"
                     class="org.apache.axis2.jaxws.dispatchers.GenericProviderDispatcher"/&gt;
            &lt;handler name="MustUnderstandValidationDispatcher"
                     class="org.apache.axis2.jaxws.dispatchers.MustUnderstandValidationDispatcher"/&gt;
        &lt;/phase&gt;
        &lt;phase name="RMPhase"/&gt;
        &lt;!--      user can add his own phases to this area  --&gt;
        &lt;phase name="OperationInFaultPhase"/&gt;
        &lt;phase name="soapmonitorPhase"/&gt;
    &lt;/phaseOrder&gt;
    &lt;phaseOrder type="OutFaultFlow"&gt;
        &lt;!--      user can add his own phases to this area  --&gt;
        &lt;phase name="soapmonitorPhase"/&gt;
        &lt;phase name="OperationOutFaultPhase"/&gt;
        &lt;phase name="RMPhase"/&gt;
        &lt;phase name="PolicyDetermination"/&gt;
        &lt;phase name="MessageOut"/&gt;
        &lt;phase name="Security"/&gt;
    &lt;/phaseOrder&gt;
&lt;/axisconfig&gt;</code></pre>
</div>
</div>
</p>

<p>Can Anyone help me configure axis2.xml to increase the <code>socket time out</code> and <code>connection time out</code> </p>