Hi Hsaka,
The buffer that overflowed is the TCP write buffer for a connection.
This buffer holds serialized objects that are waiting to be written to
the connection's socket. Normally objects are written to this buffer,
then immediately written to the socket. Sometimes the socket isn't
writable, in which case the bytes stay in the buffer until the socket
becomes writable.
That is how it is *supposed* to work.
If for some reason, quite possibly a valid reason, the connection's
socket isn't writable for a while, the write buffer could overflow.
Did your server crash when this happened? I'll make sure that it
doesn't crash the server and that it just closes the connection, since
this situation can occur under valid (but poor) conditions. If this is
the case, then when you create the server, you can specific a larger
buffer size. The default is 2048, which in hindsight is probably a bit
small. I'll increase the default buffer size on the server.
However, it is possible something else went wrong. From your
exception, the write that failed was the first byte for an object. For
this is happen, the buffer would have to become *exactly* full after
the previous object was written. This is possible, but not likely.
Maybe there is some code path that causes the write buffer to not get
flipped. If the limit is being left at the position then the next
write would cause an overflow. I'll trace through the code and look
for anything suspicious. When I add handling to make sure a valid
buffer overflow doesn't crash the server, I'll also add some logging
for the current state of the buffer (position, limit, etc). If the
exception happens again, we'll be better prepared.
How large is a serialized ConstantMessage after blowfish encryption?
Should show in the logs if you enable the debug level. The encryption
seems a bit excessive, especially for something sent so often. I
assume the key for decryption is provided inside your game code
somewhere, so the blowfish is not really providing any security.
If you are sending a message very often, you could do some
optimization. Eg, you could remember the first time sent, then just
send deltas. The deltas could be int. If the delta is < 16384 then it
will only take 2 bytes to send, versus the long which will always take
8 bytes. When a new client connects, send a long to everyone, then you
can go back to sending deltas. Then again, this optimization may not
be worth the effort/complexity. :)
-Nate