Link to home
Start Free TrialLog in
Avatar of basil365
basil365Flag for Ireland

asked on

TCP Client Side Exception

Hi guys,

We have a Windows Service hosting a TCP server which sends updates out to clients every few minutes.

The vast majority of the time there are no issues on either side. However, recently every so often we've started seeing the following exceptions:

SerializationException: The input stream is not a valid binary format. The starting contents (in bytes) are: ...

SocketException (0x80004005): An operation on a socket could not be performed because the system lacked sufficient buffer space or because a queue was full

I am using Message Framing to send the size of the data, which I thought would prevent the first exception from happening.

I've no idea about the second exception. Appears to be completely random. It doesn't affect the server, only the client. After it appears the client that received the error stops receiving messages.

Any suggestions would be much appreciated.

Thanks
Avatar of Aaron Jabamani
Aaron Jabamani
Flag of United Kingdom of Great Britain and Northern Ireland image

From the error looks like the client input buffer is overflowing.  The server is sending more data at some point of time , the client can handle.  Either server should slow down, or client should process the incoming data as soon as possible.
Avatar of basil365

ASKER

On the client side I am using an AsyncCallback to receive messages as they are sent:

socket.BeginReceive(state.buffer, 0, //offset
                                 state.buffer.Length, //how much data can be read
                                 SocketFlags.None, new AsyncCallback(OnReceive), state);

Is there a better way of doing this?

On the server side objects are getting updated on seperate threads and sent to clients as soon as the updates are completed.

Is it necessary to have a queuing system to send these updates sequentially?
ASKER CERTIFIED SOLUTION
Avatar of Aaron Jabamani
Aaron Jabamani
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks for the advice, I will implement this and see if the issue persists.