jkulubya / SoupBinTCP.NET

Implementation of the SoupBinTCP network protocol for .NET
Apache License 2.0
12 stars 8 forks source link

Connection seems to timeout #1

Closed BrianARice closed 3 years ago

BrianARice commented 3 years ago

I have successfully connected to a server that sends streaming price information and I am receiving messages.

However, it seems to timeout every time after 30 seconds and disconnects.

I have tried to set the timeouts to be ignored with pipeline.AddLast(new IdleStateHandler(0, 0, 0));

In the DotNetty function FinishRead, it eventually gets to this code with a LastBytesRead of -1 and this ultimately seems to close the channel...

                    allocHandle.LastBytesRead = ch.DoReadBytes(byteBuf);
                    if (allocHandle.LastBytesRead <= 0)
                    {
                        // nothing was read -> release the buffer.
                        byteBuf.Release();
                        byteBuf = null;
                        close = allocHandle.LastBytesRead < 0;
                        break;
                    }
BrianARice commented 3 years ago

Ok... so the IdleStateHandler was the problem... I needed to set the write idle timeout to some reasonable value (say 1) in order for the system to send out heartbeat packets.