NetCoreServer icon indicating copy to clipboard operation
NetCoreServer copied to clipboard

Websocket closes after sending data from the server

Open juhani-honkala opened this issue 3 years ago • 1 comments

Please help.

I am trying to use wss websockets with NetCoreServer. I get the connection established ok and can receive and send data. However the connection closes immediately if sending data over 65535 bytes from the server to client (Chrome client disconnects with error 1006).

Is there something I can do in order to make NetCoreServer work better with larger packet sizes? I am using SendBinary(data, 0, data.Length) for sending the packet. I tried normal .NET websockets (non-SSL) and there data sizes over 65535 bytes work fine without client side disconnect.

Any help would be greatly appreciated!

juhani-honkala avatar Sep 05 '22 20:09 juhani-honkala

You can try to create a buffer so that your data is sliced into chunks no larger than 65535 bytes.

Something like:

if ( data.length() >= 65536 ) { data = buffer(data); }

You'll need to split the data at the 65535th byte and loop through the array in your buffer() method to send it in manageable packets.

I hope this helps point you in the right direction.

AmtechInnovarch avatar Nov 19 '22 22:11 AmtechInnovarch