开云体育

ctrl + shift + ? for shortcuts
© 2025 开云体育

Re: RealVNC loses connection


Mark Griffith
 

Carlos,

The first thing I would check is what is the signal strength from your Pi to the WiFi router.? You can do this with this simple command:

sudo iw wlan0 station dump | grep signal | awk '{print $2}'

This will print the dbm signal.? A -70 is the weakest you would want to go and have a reliable link.? -60 or better, with -20 being a super strong signal, would be good.

Another thing to check would be the number of WiFi failed data packets since the last reboot.

sudo iw wlan0 station dump | grep failed | awk '{print $3}'

A return of zero would of course be best.? If you have a lot of failed packets, there is something wrong.

The last thing to check would be the bit rate between the Pi and your WiFi router:

sudo iw wlan0 station dump | grep 'tx bitrate' | awk '{print $3}'

If you are using a 2.5GHz link, a rate of 61 would be the max.? Anything less would of course be less good.

These are values that are kept by the operating system, so they are the most accurate and relevant.

If you have a low signal, or low bit rate, it could be that at some point the link is just dropped for no apparent reason.? If so, then you'll need to move the Pi closer to the WiFi router, or get better antennas for the router, or look for interference on that frequency.? Microwave ovens and older cordless phones share the 2.5 GHz spectrum and have been in the past notorious for interference.

Hope this helps.

Mark
KD0QYN


On Sunday, August 15, 2021, 05:45:47 PM CDT, David Ranch <rpi4hamradio-groupsio@...> wrote:



Hello Carlos,

Since you're doing a connection from one internal host to another internal host, you are NOT going through your router or using it's port forward setting.
***Explain?? PC is ethernet and Pi is wireless, how is it not going thought the router?

Ah.. ok, I didn't remember hearing the Rpi was on wifi.? None the less, I bet the PC and the Rpi are still on the same LAN so while they are indeed using the router, they aren't going through any NAT / portforward functionality.?? My new suspect here is that your Rpi is periodically dropping it's Wifi connection.


This log entry is from your VNC Viewer and seems to indicate that the server isn't responding to keepalive packets.? Can you post some of the relevant logs from the VNC *Server* side of things?
***I am having trouble finding this file

-



Ping test.
***ping stopped when I lost connection running on cloud and on direct.

Right.. I bet you're loosing wifi connection on the Rpi side.? Do you have a HDMI monitor + USB keyboard connected on the Rpi?? If so, run a ping from the Rpi to the default gateway (aka your router) going.? See if that occasionally drops.? I bet it does.? If that's correct, you need to see what's going on here.? Here is a little script you can run on the Raspberry Pi to see what it think's it's Wifi signal strength is:

?/usr/local/bin/get-wifi-stats.sh
--
#!/bin/bash

# 05/25/21 - dranch - minor fixes
# 04/19/21 - dranch - original version

echo -en "\nWifi Signal strength: "
iw wlan0 station dump | grep signal | awk '{print $2}'?
echo -e "?? -70 dbm or less? : is a weak signal and the link will drop if it gets much weaker"
echo -e "?? -60 dbm to -50?? : is a good signal"
echo -e "?? -40 dbm or better: is a great signal"

echo -en "\nWifi RX speed: "
iw wlan0 station dump | grep 'rx bitrate' | awk '{print $3}'
echo -en "Wifi TX speed: "
iw wlan0 station dump | grep 'tx bitrate' | awk '{print $3}'
echo -en "Wifi session reconnects since last reboot (`uptime | awk '{print $3}'` days ago): "
iw wlan0 station dump | grep failed | awk '{print $3}'

echo " "
--


The output on one of my weakly connected Rpis is as follows:
--
Wifi Signal strength: -71
?? -70 dbm or less? : is a weak signal and the link will drop if it gets much weaker
?? -60 dbm to -50?? : is a good signal
?? -40 dbm or better: is a great signal

Wifi RX speed: 26.0
Wifi TX speed: 39.0
Wifi session reconnects since last reboot (35 days ago): 53
--

--David

Join [email protected] to automatically receive all group messages.