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

resumeReceives not always working for SSL-based WebSocketChannel

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • 2.0.0.Beta1, 1.4.22.Final
    • 1.4.21.Final
    • Core, SSL
    • None
    • Hide

      I have a test case that reproduces ~90% of the time, but it involves a lot of proprietary code, and I don't have time to reduce it to an MCVE. I'm happy to test any proposed fixes, however.

      FWIW, My test case involves connecting 5000+ clients via SSL WebSockets, each of which sends a short JSON message to the server every 5 seconds on average, and the server calls suspendReceives and resumeReceives before and after each message is processed, respectively.

      Show
      I have a test case that reproduces ~90% of the time, but it involves a lot of proprietary code, and I don't have time to reduce it to an MCVE. I'm happy to test any proposed fixes, however. FWIW, My test case involves connecting 5000+ clients via SSL WebSockets, each of which sends a short JSON message to the server every 5 seconds on average, and the server calls suspendReceives and resumeReceives before and after each message is processed, respectively.

      While load testing my Undertow-based application, I noticed that occasionally one of the WebSocket connections would stop receiving messages.

      On a hunch, I commented out the calls to suspendReceives and resumeReceives (which I was using to provide backpressure while a potentially long-running asynchronous message processor does its work), and the problem went away.

      Digging deeper, I examined the Undertow source code and theorized that the implementation of resumeReceives might not be correct for SSL channels, where during a handshake reads may require writes and vice-versa. So I came up with the attached hacky, heavy-handed patch (TL;DR: call wakeupReads and wakeupWrites unconditionally).

      AFAICT, that patch fixes the problem.

              sdouglas1@redhat.com Stuart Douglas (Inactive)
              dicej Joel Dice (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: