# connection reset by peer

## dsidelnikov

hi All

I'm a newbee in Linux. I've installed Gentoo Linux and everything is OK but ...

all network connections (ssh client for example) to my Gentoo Linux box are ok for a while, and then the error "connection reset by peer" occures ( approx. after 1- hours).

What can be wrong with Gentoo Linux box?

Please, help.

Best regards

Dmitry

----------

## smart

That gives little information...

Did you have a look in the logfiles, e.g. /var/log/messages et al to find sth. fishy ?

----------

## dsidelnikov

 *smart wrote:*   

> That gives little information...
> 
> Did you have a look in the logfiles, e.g. /var/log/messages et al to find sth. fishy ?

 

Yes, I did. But I found nothing. Everything is ok, I think.  It seems like my Gentoo Linux box drops inactive connections opened about 1 - 2 hours ago. For example, I open a tcp connection and send no data through. After 1-2 hours I try to send data and get "connection reset by peer"

Best regards

Dmitri

----------

## smart

That's not unlikely really. This behaviour actually is a good idea for any networking software as otherwise, dead clients/links would otherwise slowly drain the machines resources.

Depending on the software, you might have options to define this "assumed dead" delay (timeout), or otherwise, keepalive setups that would from time to time verify "alive" status towards each others and thus, keeping the connection up. 

So i'd verify the specific case and see how you can keep this from the fate of the usually correct behaviour.

----------

## trapperjohn

 *dsidelnikov wrote:*   

> "connection reset by peer" 

 

One day, I'll find this peer and reset HIS connection!

.. sorry, couldn't resist.

----------

## TheWitePony

Did you ever find out what was causing this? I am having the EXACT same problem. I login remotely using openssh to my school. 

I have to run simulations for a class on a number of my school's servers and I periodically get this error. You see some of these simulations take days to complete. Which of course requires me to be logged in for a long time. I've been over it with my schoold tech support and it doesn't appear to be anything on their end. It's becomig extremly annoying to have to restart these. 

If anybody has any ideas on how to fix this it would be very much apprieciated.

----------

## think4urs11

Firewall in between the path between you home pc and school pc?

Established connections with no transfer for lets say 3600 sec are considered 'dead' and are removed from the connection state table. Otherwise sooner or later the firewall tables would grow infinite.

As long as it's ssh the keepalive parameters in ssh(d)_config are what your're searching for.

HTH

T.

----------

## Doc7

 *TheWitePony wrote:*   

> Did you ever find out what was causing this? I am having the EXACT same problem. I login remotely using openssh to my school. 
> 
> I have to run simulations for a class on a number of my school's servers and I periodically get this error. You see some of these simulations take days to complete. Which of course requires me to be logged in for a long time. I've been over it with my schoold tech support and it doesn't appear to be anything on their end. It's becomig extremly annoying to have to restart these. 
> 
> If anybody has any ideas on how to fix this it would be very much apprieciated.

 if it's just about a shell, i recommend screen for this one.

----------

## robdd

TheWitePony wrote:

 *Quote:*   

> Did you ever find out what was causing this? I am having the EXACT same problem. I login remotely using openssh to my school....

 

You should be able to get around this by running the job on the school server so that it doesn't care about you logging out and back in again - try 'man nohup'.  It lets you run a job in the background, then log out.  If the simulation writes anything interesting back to you then just pipe the output into a file, and 'tail' the file when you log back in.

----------

## TheWitePony

 *Think4UrS11 wrote:*   

> Firewall in between the path between you home pc and school pc?
> 
> Established connections with no transfer for lets say 3600 sec are considered 'dead' and are removed from the connection state table. Otherwise sooner or later the firewall tables would grow infinite.
> 
> As long as it's ssh the keepalive parameters in ssh(d)_config are what your're searching for.
> ...

 

I looked at the man page for sshd and it says the TCPKeepAlive option is defaulted to "yes". Anyways, I put TCPKeepAlive yes in both the ssh_config and sshd_config files. I'll let know know if theres a difference.

----------

## TheWitePony

Well, it didn't work.  :Crying or Very sad: 

Anyone have any more ideas?????

----------

## Arno Nymous

Sorry to disturb:

You checked sshd, so  you are on the server side, and then you have to keep your clients alive.

 *Quote:*   

> from man-page sshd_config
> 
>  *Quote:*   ClientAliveInterval
> 
>              Sets a timeout interval in seconds after which if no data has
> ...

 

This is all about preventing the server to waste his "valuable" resources to dead clients. Objects in serverapplications could be locked forever for other clients, because the server assumes the first client is still alive. But, many server apps, for instance mysql, have options to keep their clients at base. In web-apps you can prevent a session timeout. All very nice for the client, but I am with @smart on this one. 

 *Quote:*   

> This behaviour actually is a good idea for any networking software

 

----------

## TheWitePony

 *robdd wrote:*   

> TheWitePony wrote:
> 
>  *Quote:*   Did you ever find out what was causing this? I am having the EXACT same problem. I login remotely using openssh to my school.... 
> 
> You should be able to get around this by running the job on the school server so that it doesn't care about you logging out and back in again - try 'man nohup'.  It lets you run a job in the background, then log out.  If the simulation writes anything interesting back to you then just pipe the output into a file, and 'tail' the file when you log back in.

 

After giving up on trying to stay logged in I tried running nohup and to my amazement the process continued running when I logged out! Thanks, I think this is the answer to my problems.

I have a new problem however. I'm trying to capture all the output that would be printed to the console. I'm doing this by following the command with &> ~/somefile. When I start the simulation and check the file with less I can see that the output is beginning to print to the file, but when the simulation is complete the file is empty. Do you know what might be causing this. I'm not very familier with redirecting output, what is this "tailing" you mentioned? Is this related to my problem?

----------

## robdd

That sounds a bit weird !  Once some data has been written to a file I can't quite see how it could be deleted ??  If it's something to do with the script somehow being restarted (and I know that seems unlikely ??) you could try appending the output with an '.. &>> yourfile' which will append rather than overwrite the file.

Try a 'man tail' - it's a simple utility to look at the end of a (possibly very big) file.  Where it's really useful is to watch a file that's being written to by some other process - e.g. if you're debugging some ssh login problem you can 'tail -f /var/log/messages' in one window, then try to login in another window, and watch any errors being logged as they happen.

One thing to watch out for is the buffering of output - to make writes more efficient the OS libraries will buffer data in memory, and only write when there's a sizeable chunk to write to disk. So your simulation may write several hundred lines before the whole lot is flushed to disk, and you can see it using tail/more/less. But that doesn't explain why first you see output, then you don't ??  So I'd try the file append thing first..

Good luck.

----------

