Linux – Ubuntu custom server after some time: Connection reset by peer

connectionlinuxresetUbuntu

I have a linux server program. I notice that after 2 or 3 days some time, the server stops responding. When I look into the server log, I find "connection reset by peer" messages.

I have to restart the server. All works fine and then after 2 or 3 days some time, the same problem occurs.

Any help would be appreciated.

Edit: Sorry for the little description.

It is a simple server I have written that accepts TCP connections. It is in C# and I use mono. I start the server as follows:
nohup mono StartServer.exe &

A file called nohup.out is created in the same directory which acts as the log. After 2-3 days some time, I find that the mono process is still alive. But clients (silverlight clients) cannot connect to the server: they get an 'accessdenied' message. Actually, even when the server is down, 'accessdenied' messages are obtained. So I guess, the server is not responding.

When I look in nohup.out file, I find error messages 'connection reset by peer'.

Actually, I initially planned to host it on a windows server but finds it works fine on a linux server as well. Since I am not very experienced with linux, I was thinking if I have missed an obvious configuration.

What puzzles me is that everything works properly until exactly around 3 days.

I was load testing it making one client having multiple connections to the server and found I get the same error within one day. The number of connections is around 30.

Best Answer

I would've run

# netstat -anp

and

# lsof -n

To see if there's a connection or filehandle-leak going on. I would suspect that the connections or files aren't closed properly, and that it has passed 1024 open files after a while (which is the default limit of open files at once, unless changed with ulimit) - which again would prevent it from creating new connections.