pidaemon
Posts: 4
Joined: Fri May 31, 2013 4:34 am

Problem with RPi to connect to SSH

Sat Jun 15, 2013 2:25 am

Hi, I am using a RPi, with all latest updates of Raspian + firmware updates. I am running into this strange problem while connecting to SSH.

My SSH connection gets dropped out after a random time interval (ranging from a few seconds to a few minutes). What makes this problem bizarre is that, if I set up a continuos ping from another terminal window from my MBP it never drops out.

I am using a powered USB hub for the wifi adapter, and an iPad adapter to power my RPi. I also tried setting up a continuos ping from the pi to my home router but that didn't work. So the only scenario in which I get continuos SSH session is when I am pinging from my laptop and having SSH session from the same machine. Any one running into a similar issue or have a solution to this? This seems to point that there is some mismatch in the software, but what can it be?

User avatar
rpdom
Posts: 18733
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: Problem with RPi to connect to SSH

Sat Jun 15, 2013 5:53 am

You don't seem to say what software you are using to make the ssh connection from your laptop.

Some ssh terminals have a "keep alive" option where they will send an empty message every now and then to prevent the connection from timing out and assuming you have disconnected. It might be an idea to check if yours has that setting.

tvoverbeek
Posts: 101
Joined: Mon Feb 04, 2013 9:50 am
Location: Fieberbrunn, Austria

Re: Problem with RPi to connect to SSH

Sat Jun 15, 2013 6:12 am

Mac has the full-fledged unix ssh client. Look at the TCPKeepAlive option (man 5 ssh_config).
If you want to use ServerAlive you have to set it up on the Pi (ssh server) and adjust parameters on your Mac.

But dropping the connection after a few seconds is strange ...

pidaemon
Posts: 4
Joined: Fri May 31, 2013 4:34 am

Re: Problem with RPi to connect to SSH

Sat Jun 15, 2013 9:54 am

Thanks guys! I read somewhere on the forum (or may be the Internet), where they ruled it out to be a power supply problem. But I can't see how pinging continuously would help in that case.

I tried both options but didn't work, tried static ips too. May be I will try with a different OS on a different computer to rule out if there is any problem with my MBP. I don't believe my RPi is disconnecting from WiFi, since ping to any external website succeeds all the time. Some how it looks to be a configuration issue on either side. I am not so good with SSH options nor have I ever changed the defaults on both machines before, but I did see my laptop dropping some packets that might be the cause of it (I don't know. Just thinking).

pidaemon
Posts: 4
Joined: Fri May 31, 2013 4:34 am

Re: Problem with RPi to connect to SSH

Sat Jun 15, 2013 7:40 pm

Searching more on the Internet, I found a solution to a similar problem, where the WiFi adapter chip (Realtek in my case) was having some power saving feature (why?? :P ). So I too verified, if that was the case the with me and turns out (fortunately) yes!

So here is what I have done
cat /sys/module/8192cu/parameters/rtw_power_mgnt
Here:
0 = Disbabled
1 = Min
2 = Max

You have to create a file:

sudo nano /etc/modprobe.d/8192cu.conf
and add this line:

# Disable power saving
options 8192cu rtw_power_mgnt=0
save and reboot.

you can check the status if it is off:

cat /sys/module/8192cu/parameters/rtw_power_mgnt
it should be 0 now.

This has been working convincingly so far and I don't see any problem. I will update if more is required. Additionally, I added a ping to my home router periodically.

My source: http://svay.com/blog/setting-up-a-wifi- ... spberrypi/

--------------------------------------------------------------------------------------------------------
Update: It is still up and running. So I think my problem is resolved. :)

Return to “Troubleshooting”