Avatar of basil365
basil365
Flag 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
TCP/IPC#

Avatar of undefined
Last Comment
basil365

8/22/2022 - Mon
Aaron Jabamani

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.
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
Aaron Jabamani

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
basil365

ASKER
Thanks for the advice, I will implement this and see if the issue persists.
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes