SimpleWebTransport icon indicating copy to clipboard operation
SimpleWebTransport copied to clipboard

"Operation on non-blocking socket would block" on Fishnet bayou

Open celojevic opened this issue 1 year ago • 2 comments

Hello there,

I'm getting this error quite often in my project. Im using FishNet's Bayou transport which is just a wrapper for this git.

2024-08-25T09:03:25.360622052Z Rethrow as IOException: Unable to read data from the transport connection: Operation on non-blocking socket would block.

2024-08-25T09:03:25.360627003Z   at System.Net.Sockets.NetworkStream.Read (System.Byte[] buffer, System.Int32 offset, System.Int32 size) [0x000ac] in <68069378c72d45228fc9d977cd8eee2c>:0

2024-08-25T09:03:25.360633291Z   at JamesFrowen.SimpleWeb.ReadHelper.Read (System.IO.Stream stream, System.Byte[] outBuffer, System.Int32 outOffset, System.Int32 length) [0x00004] in <856293134615445bb2bef1c6207332cf>:0

2024-08-25T09:03:25.360638866Z   at JamesFrowen.SimpleWeb.ReceiveLoop.ReadHeader (JamesFrowen.SimpleWeb.ReceiveLoop+Config config, System.Byte[] buffer, System.Boolean opCodeContinuation) [0x0002a] in <856293134615445bb2bef1c6207332cf>:0

2024-08-25T09:03:25.360644081Z   at JamesFrowen.SimpleWeb.ReceiveLoop.ReadOneMessage (JamesFrowen.SimpleWeb.ReceiveLoop+Config config, System.Byte[] buffer) [0x0002c] in <856293134615445bb2bef1c6207332cf>:0

I'm not sure what it means or how to fix it honestly. The only googling i could do says it has to do with threads. Would using Tasks instead of Threads help?

Any help or advice would be appreciated!

celojevic avatar Aug 25 '24 13:08 celojevic

I think that error is thrown when a socket is set to non-blocking mode. but I dont think we change the Blocking property anywhere, and it should default to true.

for some background: the Read call should block the current thread until there is new data, which is why there are many side threads. Using tasks for read/write calls in unity has much worse performance.

FishNet's Bayou has some modifications to the source code, so it is possible those changes are causing issues.

James-Frowen avatar Aug 25 '24 17:08 James-Frowen

I cant seem to find the Blocking property anywhere so I can probably assume its also not being changed. And at least my FN package has no modifications to your source code since i also tried updating SWT to the latest 2.2.1.

I am hosting on Playflow, not sure if that makes a difference.

I'm also having other issues with the web transport. Have asked in the FN discord as well but still can't figure out what's going on with any of this. I'm wondering if we can talk on Discord about it? Would gladly pay you for your time as well.

celojevic avatar Aug 26 '24 11:08 celojevic