Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

TCP NetworkStream problem

Status
Not open for further replies.

ClarkKent101

Programmer
Jul 19, 2006
48
DE
Hi Everyone,

I've currently got 3 applications which communicate with each other via TCP, the way in which it's set up is practically identical to the way a chat application would work where you've got multiple client applications talking to each other via a server application. I've based my TCP implementation on the following article:
So to clarify with an example so it's easier to illustrate where my problem is happening: Client-A tries to send a message to Client-B via TCP, in order to do that Client-A would need to connect to the server application sending the message it wants to pass on to Client-B, the port Client-A uses to communicate with the server is port 3000. When the server passes on the TCP message to Client-B it does so on port 6000. So communication between Client-A and the server is done on port 3000 (send and receive), and communication from the server to Client-B is on port 6000 (also send and receive).

For the most part everything works great, up until about 2-3 days of usage. The problem I'm experiencing is after having the server application run for around 2-3 days, when Client-A connects to the server all is fine but when the server then tries to connect to Client-B to relay the message it gets disconnected immediately after connecting to Client-B. I can see the server application successfully connecting to Client-B but immediately afterwards it gets disconnected. Technically I'm getting 0 bytes being returned from the network stream between the server application and Client-B directly after connecting. The connection between Client-A and the server is fine though. And the only way to resolve this issue is to completely reboot the entire server (not just the app, but the server machine itself). I tried restarting the server application by simply terminating its process and starting it back up again and Client-A is still able to connect fine to the server but I still get the same problem when the server tries to connect to Client-B to relay messages to it.

I get the feeling that the reason why I need to restart the server machine itself to get the tcp server app to work correctly again is because of perhaps being limited in being able to communicate on port 6000 to Client-B after a certain period of time depending on the amount of traffic, but I can't be sure.

Any help on this would be greatly appreciated.

Thanks a bunch.

- Tony
 
to get a more definitive idea of what's happening
1. add logging to key points in the system to ensure it's working as expected.
2. run the application through a profiler like dotTrace or Ants Profiler to ensure the memory is properly managed.
3. use perfmon to log how the server operates while the application is running.

after that you should be able to pinpoint where the problem is. as a general rule I would start by looking for resources that are not properly disposed of. restarting the application can usually take care of this. since you are dealing with out of process services (TCP/Sockets etc) this could be the reason you need to reboot the machine, not just the app.


Jason Meckley
Programmer
Specialty Bakers, Inc.

faq855-7190
faq732-7259
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top