Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-125874

QTcpSocket readyRead not emitted for first received data

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P2: Important P2: Important
    • 6.8.1, 6.9.0 FF
    • 6.7.0
    • Network: Sockets
    • None
    • WebAssembly
    • 9b01f1bdb (dev), b56e959d6 (6.8)

      It appears that QTcpSocket may not emit the readyRead signal on the WebAssembly target in the following circumstance:

      • Client running on WebAssembly creates a QTcpSocket and connects to a server QWebSocketServer running on x64.
      • The server, on the QWebSocketServer::newConnection signal, immediately sends a binary or text message to the client that is less than around 3700 bytes. (Exact size appears to depend on socket name).
      • Client will get QTcpSocket::connected signal, but appears not to get readyRead signal, unless server transmits more data (which for the protocol I'm working on, never happens, as server is waiting for a response from client).

      Some observations:

      • If the server transmits a bit more data (such that the first packet of data transmitted is bigger than 4096 bytes), then the readyRead signal is emitted.
      • If the server has a bit of a time delay after newConnection before it sends the small amount of data, then readyRead is emitted.
      • In the case that readyRead is not emitted, the data is definitely received by the client. handleMessage in library_sockfs.js is called and QEventDispatcherWasm::socketMessage is called.

      It appears as though there may be a race condition. It seems in the failing case, when QEventDispatcherWasm::socketMessage is called, the notifier hasn't been set up yet.. i.e. QEventDispatcherWasm::registerSocketNotifier hasn't yet been called. In the working cases, registerSocketNotifier is called before socketMessage.

        1. sockettestcase.zip
          13 kB
          Jon Beniston
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            lopotter-ext Lorn Potter
            srcejon Jon Beniston
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes