Announcement Announcement Module
No announcement yet.
WebServiceTemplate: I/O error, Connection reset. Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • WebServiceTemplate: I/O error, Connection reset.


    We migrated from metro to spring's webservice framework and seeing a connection reset error on WebServiceTemplate.marshalSendAndReceive (stack trace below) every alternate request. Inspecting network packets, it seems the web server which our code is communicating with doesn't like the connection being open (which is persistent connection set through http header, "Connection: keep-alive").

    15-Feb-2013 10:23:01,737 INFO [scheduler_Worker-8] nObserver.update(56) - A notification was triggered: [Exception - WebServiceIOException - stackTrace: n: I/O error: Connection reset; nested exception is Connection reset
    at ate.sendAndReceive(
    at ate.marshalSendAndReceive( 384)
    at ate.marshalSendAndReceive( 374)

    I have seen finally block containing calls "TransportUtils.closeConnection" in WebserviceTemplate.sendAndReceive method. This in the test environment doesn't send a Finish (tcp packet with Flag "F") packet. Also, I was not able to find a way to set a "Connection:close" in the http header through WebServiceTemplate.

    Hence as a workaround, we extended HttpComponentsMessageSender (below is the extension). Now in the test environment we are seeing a finish packet (tcp packet with "F" flag set). Is there a way in spring-ws to close http connections explicitly? The work around seems to work (atleast in the test env) but adding custom code like this is not our first preference. Any suggestions?

    public class NonPersistentConnectionHttpComponentsMessageSender extends HttpComponentsMessageSender {

    public WebServiceConnection createConnection(URI uri) throws IOException {
    HttpComponentsConnection httpComponentsConnection = (HttpComponentsConnection)super.createConnection(u ri);
    httpComponentsConnection.getHttpPost().addHeader(" Connection","close");
    return httpComponentsConnection;


    Thanks a ton in advance.