https://bz.apache.org/bugzilla/show_bug.cgi?id=64951

            Bug ID: 64951
           Summary: Websocket connection to unresolvable host causes fd
                    leaks
           Product: Tomcat 8
           Version: 8.5.37
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: WebSocket
          Assignee: dev@tomcat.apache.org
          Reporter: maurizio.ad...@gmail.com
  Target Milestone: ----

Created attachment 37583
  --> https://bz.apache.org/bugzilla/attachment.cgi?id=37583&action=edit
patch for WsWebSocketContainer.java 8.5.37 fd leaks

An attempt to create a new websocket connection with
WebSocketContainer.connectToServer to an unresolvable host raises
java.nio.channels.UnresolvedAddressException, but leaves some socket resources
allocated. This can be verified by putting the above connect method in a loop
and monitoring the open files of the java process.
On linux this can be done with e.g. lsof: the number of socket fd increase on
every iteration up to the OS limit, then "Too many open files" IOExceptions are
raised.

Browsing the
org.apache.tomcat.websocket.WsWebSocketContainer.connectToServerRecursive()
code
I found that the call

        // Open the connection
        Future<Void> fConnect = socketChannel.connect(sa);

raises the UnresolvedAddressException, leaving the socketChannel object opened.

I think the same problem could arise with a proxy server that return a status
code != 200, handled in lines 313-317.

I tried to solve extending the try block to include the above call, changing
the corresponding finally block to cover extra cases.

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to