Socket connection was forcibly closed by the remote host

F

Frederick

Hy everyone,

I have a little problem doing socket-programming.

I've made a console-application with a socket listening on a sertain port to
accept connections from other clients.

The only thing my application has to do is accept the incomming clients,
read the data and send it to a database.

Everything works fine, but now and then my socket server seems to
crash/hang.

When I check my error-handling I see that my application is throwing this
exception :

"An existing connection was forcibly closed by the remote host"

Restarting my application solves this problem.

I don't know the reason, nor how to solve it.

I've already surfed the internet al lot, but dit not come to an satisfying
answer.

Someone who can help me or who has experienced the same problem ?

Thanks,

Frederick R.
 
M

Murat Fidan

if there are too much connection at same time your servers socket may stops
working.
 
P

Peter Duniho

[...]
Everything works fine, but now and then my socket server seems to
crash/hang.

When I check my error-handling I see that my application is throwing this
exception :

"An existing connection was forcibly closed by the remote host"

[...]
Someone who can help me or who has experienced the same problem ?

I'm sure lots of people have experienced the same problem. It's not a
very specific description of the problem, and a TCP connection being
closed somehow isn't all that uncommon.

The most common reason this would happen is some problem at the remote
end, either a buggy client, or some issue going on with its network
connection. Depending on the context, it's actually possible you've got a
malicious ISP in the middle sending fake resets. There are all sorts of
reasons this could happen, most of them having nothing to do with the
actual code, but rather something to do with the network.

So, the first step is to fix your server code so that it can reliably and
gracefully handle errors, including this one. Then, if you believe that
the reset connection is a sign of a problem elsewhere, you can move on to
dealing with that.

But you need to be able to handle that error gracefully regardless.

Pete
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top