Uploaded image for project: 'WildFly'
  1. WildFly
  2. WFLY-6912

Socket leak when client doesn't read the entire response

    XMLWordPrintable

Details

    • Bug
    • Resolution: Obsolete
    • Major
    • None
    • 8.2.0.Final
    • Web (Undertow)
    • Hide

      //read an attachment from server, terminate after reading 4k chars.

      InputStreamReader in = new InputStreamReader(con.getInputStream());
      char[] outputByte=new char[4096];
      while(in.read(outputByte, 0, 4096) != -1)

      { break; }

      Exception stacktrace
      ================
      Caused by: java.io.IOException: Connection reset by peer
      at sun.nio.ch.FileDispatcherImpl.write0(Native Method) [rt.jar:1.8.0_45]
      at sun.nio.ch.SocketDispatcher.write(SocketDispatcher.java:47) [rt.jar:1.8.0_45]
      at sun.nio.ch.IOUtil.writeFromNativeBuffer(IOUtil.java:93) [rt.jar:1.8.0_45]
      at sun.nio.ch.IOUtil.write(IOUtil.java:51) [rt.jar:1.8.0_45]
      at sun.nio.ch.SocketChannelImpl.write(SocketChannelImpl.java:471) [rt.jar:1.8.0_45]
      at org.xnio.nio.NioSocketConduit.write(NioSocketConduit.java:152)
      at io.undertow.server.protocol.http.HttpResponseConduit.write(HttpResponseConduit.java:575)
      at io.undertow.conduits.AbstractFixedLengthStreamSinkConduit.write(AbstractFixedLengthStreamSinkConduit.java:106)
      at org.xnio.conduits.ConduitStreamSinkChannel.write(ConduitStreamSinkChannel.java:150)
      at io.undertow.channels.DetachableStreamSinkChannel.write(DetachableStreamSinkChannel.java:239)
      at io.undertow.server.HttpServerExchange$WriteDispatchChannel.write(HttpServerExchange.java:1850)
      at io.undertow.servlet.spec.ServletOutputStreamImpl.writeBufferBlocking(ServletOutputStreamImpl.java:567)
      at io.undertow.servlet.spec.ServletOutputStreamImpl.write(ServletOutputStreamImpl.java:220)

      Show
      //read an attachment from server, terminate after reading 4k chars. InputStreamReader in = new InputStreamReader(con.getInputStream()); char[] outputByte=new char [4096] ; while(in.read(outputByte, 0, 4096) != -1) { break; } Exception stacktrace ================ Caused by: java.io.IOException: Connection reset by peer at sun.nio.ch.FileDispatcherImpl.write0(Native Method) [rt.jar:1.8.0_45] at sun.nio.ch.SocketDispatcher.write(SocketDispatcher.java:47) [rt.jar:1.8.0_45] at sun.nio.ch.IOUtil.writeFromNativeBuffer(IOUtil.java:93) [rt.jar:1.8.0_45] at sun.nio.ch.IOUtil.write(IOUtil.java:51) [rt.jar:1.8.0_45] at sun.nio.ch.SocketChannelImpl.write(SocketChannelImpl.java:471) [rt.jar:1.8.0_45] at org.xnio.nio.NioSocketConduit.write(NioSocketConduit.java:152) at io.undertow.server.protocol.http.HttpResponseConduit.write(HttpResponseConduit.java:575) at io.undertow.conduits.AbstractFixedLengthStreamSinkConduit.write(AbstractFixedLengthStreamSinkConduit.java:106) at org.xnio.conduits.ConduitStreamSinkChannel.write(ConduitStreamSinkChannel.java:150) at io.undertow.channels.DetachableStreamSinkChannel.write(DetachableStreamSinkChannel.java:239) at io.undertow.server.HttpServerExchange$WriteDispatchChannel.write(HttpServerExchange.java:1850) at io.undertow.servlet.spec.ServletOutputStreamImpl.writeBufferBlocking(ServletOutputStreamImpl.java:567) at io.undertow.servlet.spec.ServletOutputStreamImpl.write(ServletOutputStreamImpl.java:220)
    • User Experience

    Description

      I'm facing an issue similar to UNDERTOW-427. If the client doesn't read the entire response sent by the server and terminates the connection before server does, then there is socket leak.

      Open files count
      =============
      [root@xyz apps]# lsof -p <jboss-pid> | wc -l
      1331

      [root@xyz apps]# lsof | wc -l
      12049

      After running around 1.5 k times.
      =========================
      [root@xyz apps]# lsof -p <jboss-pid> | grep "can't identify pro" | wc -l
      1539

      [root@xyz apps]# lsof -p <jboss-pid> | wc -l
      2998

      [root@xyz apps]# lsof | wc -l
      14831

      Attachments

        Issue Links

          Activity

            People

              sdouglas1@redhat.com Stuart Douglas
              www.sandeepkrishnan Sandeep Krishnan (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: