vnc viewers timing out on RPi3 (raspbian)
Posted: Tue Dec 27, 2016 9:01 pm
Greetings all,
This is an edited version of the original message, since a solution was found. This topic does not involve RealVNC, as I was trying to connect "directly", without having to create a third-party account somewhere. When the problem was noticed, I tried tightvnc, tigervnc, ultravnc and the server connection via finder on a mac. All of them timed out upon attempting to connect to the pi.
To summarize for those in this situation, check if there is a firewall running on the pi via the command iptables. As another post at stack exchange discusses, this problem is typically observed either because of a typo on the ip address or about packets being dropped. My problem was the latter.
I have a RPi3 with raspbian, connected via router to a windows pc. I could ping it and have no problem with ssh. Despite having server and viewer running in their respective platforms, the viewer connection timed out at every attempt. I have no extra monitor, keyboard or mouse, so I must connect headless.
The error I kept getting was:
Error in TightVNC Viewer: A connection attempt failed bacause the connected party did
not properly respond after a period of time, or established connection failed because
connected host has failed to respond.
Here is the sequence of events leading to observing the problem.
**********************
1) downloaded latest raspbian, made the necessary modifications to the image to
get wifi and ssh going. On the router, I use DHCP with a table tying MACs to IPs
(restrited IP address list on the router), so the IP never changes. All devices
are visible via advanced ip scanner (downloaded from the internet). I can ping the pi
from cygwin (on a pc) or from the command shell on a mac. SSH works fine via Putty between laptop pc and RPi3.
2) using raspi-config, changed password, enabled vnc, set to boot via graphic interface (later changed to command shell).
3) Installed tightvncserver, ran update and upgrade. **Mistakenly installed ufw**. Reboot. Logged back in via ssh.
4) Ran vncserver :1 -- at this point tried to connect. **there is not much sense in enabling vnc via raspi-config and trying to run tightvncserver. If one wants to run tightvnc server, one should have the vnc at boot from raspi-config disabled (you can likely have the two at different ports, but that is another story)..
On the PC side, installed tightvnc viewer. Later tried UltraVNC viewer as well. On a Mac, I tried tiger vnc and the built-in connection via finder. The viewers were attempted one at a time. They all time out on both PC and Mac. Meanwhile, ssh runs fine. This meant to me -- mistakenly -- that there was no firewall, since ssh was running fine all along.
5) I tried different ports for the server (except 0), to no avail. For the heck of it, I took the vnc job down via kill -9, and tried to run the command tightvncserver :1 instead. Tried to connect, timed out.
6) checking with ps axg | grep vnc -- output shows everything is running as it should. At this point used the same command to see if ufw (the firewall) was running. Nothing shown for the firewall, but it *was* running. Tried to connect, time out.
6) At this point I was attempting the rotating machine gun approach. Following a nice tutorial from xhantor (on this forum), which sets up vnc service upon power up. This makes sense by itself, not along everything else I was running.
I created a new file:
/etc/systemd/system/vncserver@.service with
----
[Unit]
Description=Remote desktop service (VNC)
After=syslog.target network.target
[Service]
Type=forking
User=pi
PAMName=login
PIDFile=/home/pi/.vnc/%H:%i.pid
ExecStartPre=-/usr/bin/vncserver -kill :%i > /dev/null 2>&1
ExecStart=/usr/bin/vncserver -depth 24 -geometry 1280x800 :%i
ExecStop=/usr/bin/vncserver -kill :%i
[Install]
WantedBy=multi-user.target
----
Ran systemctl daemon-reload
Ran systemctl enable vncserver@1.service
Reboot, log back in with ssh (fine)
7) checked the log file related to the port open, in .vnc -- log was complaining of the absence of .Xresources file. I created an empty one, rebooted and tried again, and the log file no longer showed complaint.
At this point, after hints of my mistakes, I took down the conflicting vnc services and checked whether there was a firewall running via command line --> iptables -L -nv (there was a firewall active) Took down the firewall via sudo ufw disable.
Connected and it worked.
Hopefully this will help someone else facing the same predicament. Thanks to @Milliways (stack exchange) for the clues that lead to the solution.
Cheers!
This is an edited version of the original message, since a solution was found. This topic does not involve RealVNC, as I was trying to connect "directly", without having to create a third-party account somewhere. When the problem was noticed, I tried tightvnc, tigervnc, ultravnc and the server connection via finder on a mac. All of them timed out upon attempting to connect to the pi.
To summarize for those in this situation, check if there is a firewall running on the pi via the command iptables. As another post at stack exchange discusses, this problem is typically observed either because of a typo on the ip address or about packets being dropped. My problem was the latter.
I have a RPi3 with raspbian, connected via router to a windows pc. I could ping it and have no problem with ssh. Despite having server and viewer running in their respective platforms, the viewer connection timed out at every attempt. I have no extra monitor, keyboard or mouse, so I must connect headless.
The error I kept getting was:
Error in TightVNC Viewer: A connection attempt failed bacause the connected party did
not properly respond after a period of time, or established connection failed because
connected host has failed to respond.
Here is the sequence of events leading to observing the problem.
**********************
1) downloaded latest raspbian, made the necessary modifications to the image to
get wifi and ssh going. On the router, I use DHCP with a table tying MACs to IPs
(restrited IP address list on the router), so the IP never changes. All devices
are visible via advanced ip scanner (downloaded from the internet). I can ping the pi
from cygwin (on a pc) or from the command shell on a mac. SSH works fine via Putty between laptop pc and RPi3.
2) using raspi-config, changed password, enabled vnc, set to boot via graphic interface (later changed to command shell).
3) Installed tightvncserver, ran update and upgrade. **Mistakenly installed ufw**. Reboot. Logged back in via ssh.
4) Ran vncserver :1 -- at this point tried to connect. **there is not much sense in enabling vnc via raspi-config and trying to run tightvncserver. If one wants to run tightvnc server, one should have the vnc at boot from raspi-config disabled (you can likely have the two at different ports, but that is another story)..
On the PC side, installed tightvnc viewer. Later tried UltraVNC viewer as well. On a Mac, I tried tiger vnc and the built-in connection via finder. The viewers were attempted one at a time. They all time out on both PC and Mac. Meanwhile, ssh runs fine. This meant to me -- mistakenly -- that there was no firewall, since ssh was running fine all along.
5) I tried different ports for the server (except 0), to no avail. For the heck of it, I took the vnc job down via kill -9, and tried to run the command tightvncserver :1 instead. Tried to connect, timed out.
6) checking with ps axg | grep vnc -- output shows everything is running as it should. At this point used the same command to see if ufw (the firewall) was running. Nothing shown for the firewall, but it *was* running. Tried to connect, time out.
6) At this point I was attempting the rotating machine gun approach. Following a nice tutorial from xhantor (on this forum), which sets up vnc service upon power up. This makes sense by itself, not along everything else I was running.
I created a new file:
/etc/systemd/system/vncserver@.service with
----
[Unit]
Description=Remote desktop service (VNC)
After=syslog.target network.target
[Service]
Type=forking
User=pi
PAMName=login
PIDFile=/home/pi/.vnc/%H:%i.pid
ExecStartPre=-/usr/bin/vncserver -kill :%i > /dev/null 2>&1
ExecStart=/usr/bin/vncserver -depth 24 -geometry 1280x800 :%i
ExecStop=/usr/bin/vncserver -kill :%i
[Install]
WantedBy=multi-user.target
----
Ran systemctl daemon-reload
Ran systemctl enable vncserver@1.service
Reboot, log back in with ssh (fine)
7) checked the log file related to the port open, in .vnc -- log was complaining of the absence of .Xresources file. I created an empty one, rebooted and tried again, and the log file no longer showed complaint.
At this point, after hints of my mistakes, I took down the conflicting vnc services and checked whether there was a firewall running via command line --> iptables -L -nv (there was a firewall active) Took down the firewall via sudo ufw disable.
Connected and it worked.
Hopefully this will help someone else facing the same predicament. Thanks to @Milliways (stack exchange) for the clues that lead to the solution.
Cheers!