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

  • WebServiceTemplate: I/O error, Connection reset.

    Hello,

    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] com.mycompany.notifier.observer.LoggingNotificatio nObserver.update(56) - A notification was triggered: [Exception - WebServiceIOException - stackTrace: org.springframework.ws.client.WebServiceIOExceptio n: I/O error: Connection reset; nested exception is java.net.SocketException: Connection reset
    at org.springframework.ws.client.core.WebServiceTempl ate.sendAndReceive(WebServiceTemplate.java:543)
    at org.springframework.ws.client.core.WebServiceTempl ate.marshalSendAndReceive(WebServiceTemplate.java: 384)
    at org.springframework.ws.client.core.WebServiceTempl ate.marshalSendAndReceive(WebServiceTemplate.java: 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.
Working...
X