I use PuTTY to control my pi a lot. Normally it works fine, but as of a few days ago my main computer will just stop receiving data from my pi and freeze, and I have to close PuTTY and open a new session, meaning that I lose connection with what I've been doing earlier. Sometimes it will do this on start-up and I can't connect until I reboot my pi manually(pulling the plug out). Any Suggestions?
4 Answers
This is not an answer to avoid freezing but about keeping the session running and available if ssh connection is lost:
You can try tmux
(or screen
) they are meant for that:
tmux allows one to switch easily between several programs in one terminal, detach them (they keep running in the background) and reattach them to a different terminal. And do a lot more.
Connect to the pi:
ssh pi@raspberrypi
Launch tmux:
tmux
You can now work safely.
In case you get disconnected for any reason, you can log back:
ssh pi@raspberrypi
List the running tmux sessions:
tmux ls
This should display the list of open tmux sessions. Example:
0: 1 windows (created Sun Jul 5 12:05:35 2015) [80x23]
1: 1 windows (created Sun Jul 5 12:05:44 2015) [80x23]
You can than select the desired session with the attach command:
tmux -t 1
I experienced a similar issue. It seemed that if executing a command over ssh that returned more than a few lines that ssh would freeze. sudo apt-get upgrade
would run fine, but ls -r
or ifconfig
would freeze after about 10 lines. Changing the MTU settings resolved the issue for me.
The following command resolved things. I was connected over wifi, so replace the interface name as necessary. Default MTU was 1500:
sudo ifconfig wlan0 mtu 500 up
Is the Pi connected via Wifi and a USB ethernet adaptor? You may find the USB Wifi NIC is going to sleep, I edited /etc/modprobe.d/8192cu.conf and added
options 8192cu rtw_power_mgnt=0 rtw_enusbss=0
and it solved the problem for me but this info depends on the chipset, I'm using the Edimax USB wifi adaptors so you may have to search for the solution for your chipset.
For me the problem was this: https://www.raspberrypi.org/forums/viewtopic.php?f=91&t=122601
So after commenting out this chunk of /etc/rsyslog.conf
the Pi is not doing unexpected rebootings anymore (which caused the broken pipe
ssh freeze):
daemon.*;mail.*;\
news.err;\
*.=debug;*.=info;\
*.=notice;*.=warn |/dev/xconsole
grep "oom-killer" /var/log/syslog
and if anything comes out with a timestamp in the window of your problem, edit it into your post.