LabVIEW-WebSockets-API icon indicating copy to clipboard operation
LabVIEW-WebSockets-API copied to clipboard

Single Message Sent is received as multiple Messages

Open christandlg opened this issue 1 year ago • 3 comments

I have observed that occasionally (depending on message length) a single message sent by either server or client is received as multiple messages by the other party.

Steps to reproduce:

  1. add waveform chart indicators to Client Single Connection and Server Single Connection examples to display received string length
  2. build .exe from examples and run server and client on separate machines (issue also exists when both are running on the same machine, but much less frequent)
  3. send a large payload (in my case, 8 MBs of 'a')
  4. observe that waveform chart displays multiple received string lengths: grafik

christandlg avatar Aug 16 '24 09:08 christandlg

wireshark reports correct number of bytes transmitted: grafik

christandlg avatar Aug 16 '24 09:08 christandlg

Hi @christandlg - thanks for raising the issue. There are a couple of things this could be:

  • The 'read' is timing out and returning the partial data/message (the timeout error is dropped in the example VIs)
  • There is known limit on a single frame of 2048MB but we're probably not hitting that here
  • Some other bug/issue that I'm not aware of

For large messages, the use of WS framing is recommended but the implementation of it in my library is not extensively tested.

Testing locally (i.e. localhost with the client running on the same machine as the server), I can do 60MB no problem (but it start to take a long time): image

It would perhaps make sense to distinguish (e.g. with a different error code) between 'no data received' and 'data received but did not complete within timeout period'.

samsharp99 avatar Aug 16 '24 10:08 samsharp99

* The 'read' is timing out and returning the partial data/message (the timeout error is dropped in the example VIs)

I think this may be the core issue. It would explain the inconsistency in received message length and also explain !15, if in WebSocket.lvclass:Low-Level Read.vi a byte is parsed as opcode that actually is part of the message payload. grafik

For large messages, the use of WS framing is recommended

How can I try that? Do I need to control the Finished? input of WebSocket.lvclass:Low-Level Write.vi ?

christandlg avatar Aug 17 '24 10:08 christandlg