Uploaded image for project: 'Undertow'
  1. Undertow
  2. UNDERTOW-585

Memory / socket leak when closing a WebSocket in case receive setter is not explicitly overridden

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Major
    • 1.3.6.Final, 1.4.0.Beta1
    • None
    • None
    • None
    • Hide

      See attached project

      Show
      See attached project
    • Workaround Exists
    • Hide

      Override receive setter by calling channel.getReceiveSetter().set(...) where channel is an instance of WebSocketChannel.

      Show
      Override receive setter by calling channel.getReceiveSetter().set(...) where channel is an instance of WebSocketChannel .

    Description

      Undertow does not release memory associated with WebSocket connection after calling WebSockets.sendClose if receive setter is not explicitly overridden by the client code. Same happens if WebSocketChannel.sendClose is used. It leads to socket / file descriptor leak which in turn causes severe hiccup later on (hit in production several times and can be easily observed in a profiler).

      Attached project demonstrates this scenario. It leads to a leak with close listeners not being called / strong references to WebSocket-related objects being held / sockets and respective file descriptors being kept open (even though the client is already disconnected).

      It is very well understood that there is an easy fix to this by having receive setter always explicitly overridden (as Undertow example demonstrates), but:

      • IMO this is an unacceptable default. As a client developer I would expect receive setter to be there and reacting to ping / ping and close events at least.
      • It is not well documented.
      • It is easy to miss and then very hard to find out what is wrong, especially when code evolves and becomes more complex.

      Moreover, server won't react on client's call to disconnect if receive setter is not overridden.

      AFAIU this is relevant for all versions of Undertow.

      Attachments

        Activity

          People

            sdouglas1@redhat.com Stuart Douglas
            flush_dia Vladimir Tsukur (Inactive)
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: