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

WebSockets not thread safe

XMLWordPrintable

    • Hide

      When called concurrently from several threads following code will not work without explicit synchronization on channel:

      synchronized (channel) {
      WebSockets.sendText("

      {'some': 'json'}

      ", channel, null);
      }

      No exception is thrown, but channel stops delivering frames to a browser.

      It is trivial to reproduce, just start ~100 threads sending about a message per second to a channel without synchronization.

      Show
      When called concurrently from several threads following code will not work without explicit synchronization on channel: synchronized (channel) { WebSockets.sendText(" {'some': 'json'} ", channel, null); } No exception is thrown, but channel stops delivering frames to a browser. It is trivial to reproduce, just start ~100 threads sending about a message per second to a channel without synchronization.
    • Documentation (Ref Guide, User Guide, etc.), User Experience
    • High

      Using io.undertow.websockets.core.Websockets.send*() methods is thread unsafe.

      My guess would be it's some race with suspend/resumeWrites() calls.

      If Websockets API calls must be externally synchronized it should be stated clearly at least in javadoc. I hope it's not so, as it would force us to use thread-per-client just for websockets writes.

              sdouglas1@redhat.com Stuart Douglas (Inactive)
              vnesek_jira Vjekoslav Nesek (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: