简体   繁体   中英

Apache CXF Could not send message caused by: java.net.SocketException: Connection reset

I am running tomcat server and trying to consume .NET SOAP WS. Doing that with apache.cxf.

The .NET WS has cluster on it's side, and when restart has performed on one of the machines, I get

javax.xml.ws.WebServiceException: Could not send Message.
at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:148)
...
Caused by: java.net.SocketException: Connection reset

To avoid this, I want to work with connection=close header only for this WS consuming.

So, on creating SOAP messages, I send

HTTPConduit conduit = (HTTPConduit) iMyFlowWSClient.getConduit();
    conduit.getClient().setConnection(ConnectionType.CLOSE);

And I see on wireshark that the header get the right value:

Connection: close\r\n

But, when first call to WS is performed(looks like import of xsd's) on initializating of wsdl url by constractor of java.xml.ws.Service:

protected Service(java.net.URL wsdlDocumentLocation, QName serviceName) {
    delegate = Provider.provider().createServiceDelegate(wsdlDocumentLocation,
            serviceName,
            this.getClass());
}

I see on Wireshark the next headers:

Hypertext Transfer Protocol
    GET /MyFlow.svc?wsdl HTTP/1.1\r\n
    Content-Type: text/xml\r\n
    Accept: */*\r\n
    User-Agent: Apache CXF 3.0.0\r\n
    Cache-Control: no-cache\r\n
    Pragma: no-cache\r\n
    Host: 123.123.12.34\r\n
    Connection: keep-alive\r\n
    \r\n
    [Full request URI: http://123.123.12.34/MyFlow.svc?wsdl]

And that I believe what keeps alive this connection to WS.

Is there any solution to configure apache.cxf headers to send connection=close on all requests that performed on HTTP level?

No, and it looks to me that you will only be able to reduce the problem, not eliminate it. The problem seems to be on the .NET side; closing down the connections is somehow not done right.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM