tags:

views:

117

answers:

1

I am facing a wierd socket connection problem in .net windows application.I am using socket from .net to asynchonously communicate to a legacy intersystems cache database.

I have a specific timeout value in the application, when the timeout occurs, user is prompted to stay connected to the application. When I say stay connected, socket is not being reset.
I set timeout to 30 mins and say stay connected for first idle time.Then when I navigate the application it works fine. If with out navigating in the application and say stay connected second time, and navigate in the app I am getting socket "host refused" connection error. This I can assume may be socket is terminated.

But the wierd part is if I set the application timeout to 10 mins, then also I am getting socket error second time. When I check the sockets connected property, it is still true. I am not catching exception when I call sockets Send method. But the data is not passed from the socket.I have checked the other .net code. it is fine. This problem also occurs rarely, only 1 in 10 times. Any suggestions will be greatly helpful.

+1  A: 

This sounds like a typical issue resulting from firewalls or other TCP settings.
Firewalls might silently disconnect the connection if it is idle more than x seconds.
As the TCP protocol does not generate an event in such a case (similar like just removing the network cable), it is highly recommended to send ping message every x seconds, so that the firewall stays open and that you can be sure to be connected. if the ping is missed, the server disconnects the client.

weismat
BUt I have checked the firewall and it is off. Are there other TCP setting which may effect
AvidProgrammer
Avid - I am not talking about the firewall on your machine - I am talking about corporate firewalls/switches inside your company's network. As said before there also other reasons why you should consider to use a ping protocol - it is a best practice to ensure a working socket with keeping things simple.
weismat