Reputation: 211
What might be the cause of:
org.apache.cxf.interceptor.Fault: Could not send Message.
Caused by: java.net.SocketTimeoutException: SocketTimeoutException invoking https://xxx.xxx.xxx.xxx:8443/services/test: Read timed out
It usually occurs after I send a soap request to the ws
. I'm using apache cxf
. I'm completely sure that the ws
is up and running because before the time out occur the client will send 2 more request. The timeout happens in the third soap request.
Upvotes: 17
Views: 77794
Reputation: 2896
I have encountered this error as well for my webservice client. The solution that worked for me is to configure the http client in the CXF config file (cxf.xml).
As documented in Apache CXF document:
1.Add the http-conduit namespace and xsd:
<beans ... xmlns:http-conf="http://cxf.apache.org/transports/http/configuration ... xsi:schemaLocation="... http://cxf.apache.org/transports/http/configuration http://cxf.apache.org/schemas/configuration/http-conf.xsd ...">
2.Add the http-conduit tag/element and set the ReceiveTimeout/ConnectionTimeout to 300000 ms:
<http-conf:conduit name="*.http-conduit"> <http-conf:client ConnectionTimeout="300000" ReceiveTimeout="300000"/> </http-conf:conduit>
Upvotes: 17
Reputation: 5441
Another approche to config timeouts (programmatically):
JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
Object serviceClass = factory.create();
defineTimeouts(serviceClass);
static void defineTimeouts(Object serviceClass) {
Client cxfClient = ClientProxy.getClient(serviceClass);
HTTPConduit httpConduit = (HTTPConduit) cxfClient.getConduit();
HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy();
httpClientPolicy.setConnectionTimeout(DEFAULT_CLIENT_CONNECTION_TIMEOUT);
httpClientPolicy.setReceiveTimeout(DEFAULT_CLIENT_RECEIVE_TIMEOUT);
httpConduit.setClient(httpClientPolicy);
}
Upvotes: 5
Reputation: 2347
You might want to change the receiveTimeout setting from Apache CXF src and replace the existing cxf-rt-transports-http-version.jar in your server.
Brief instructions: (Got the instructions from Wildfly 8.2/undertow read time out)
This should resolve the SocketTimeoutException caused by the underlying Apache CXF used in the server.
Upvotes: 0
Reputation: 23415
The error message means that your web service client was trying to receive data from a remote web service over the network, but no data was received for a specific period of time, so the web service client stopped waiting for the data to be received.
One of the possible causes might be that the timeout
property is too low. Defaults to cxf default values of 30000 and 60000 ms respectively. These can be changed depending how you are creating your client.
If you are creating a client using java code you can use:
//1 minute for connection
((BindingProvider) wsPort).getRequestContext().put("com.sun.xml.ws.connect.timeout", 1 * 60 * 1000);
//3 minutes for request
((BindingProvider) wsPort).getRequestContext().put("com.sun.xml.ws.request.timeout", 3 * 60 * 1000);
If you are using Spring, you can use a map like this:
<util:map id="jaxwsProperties">
<entry key="com.sun.xml.internal.ws.request.timeout">
<value type="java.lang.Integer">120000</value>
</entry>
<entry key="com.sun.xml.internal.ws.connect.timeout">
<value type="java.lang.Integer">60000</value>
</entry>
</util:map>
Then set that map into your <jaxws:client.../>
configuration.
Upvotes: 15