Bosse_B
Posts: 966
Joined: Thu Jan 30, 2014 9:53 am

VNC cannot login to desktop on RPi4B, why?

Tue Feb 04, 2020 10:25 am

My RPi4 is set to show a user login before starting the desktop on the monitor.

Now I have tried to use VNC to interact with the RPi4 but all I get is a message in a small black box:
"Cannot currently show the desktop"
I am using a Windows 10 laptop with RealVNC Viewer ver 6.19.1115 (r42122) x64

I thought that if the RPi was newly rebooted one would get to the logon screen and could enter the user/password combination, but apparently not so.

How can I fix this?
Must there be a monitor attached by cable to the HDMI connector on the RPi4?
Currently my monitor is connected to my Windows laptop...
Bo Berglund
Sweden

User avatar
HawaiianPi
Posts: 5710
Joined: Mon Apr 08, 2013 4:53 am
Location: Aloha, Oregon USA

Re: VNC cannot login to desktop on RPi4B, why?

Tue Feb 04, 2020 10:39 am

If you have no monitor connected to a Pi4 the GUI does not load, and there is no desktop to log into. Older models would switch to composite video with no HDMI, but the Pi4 doesn't do that because it requires adjusting the clock speed and reducing performance.

To use RealVNC with the Pi4 you must set a manual resolution in the raspi-config utility (or the GUI equivalent, when connected to a screen). Run sudo raspi-config from an SSH session and configure the resolution, reboot, and VNC should work.
My mind is like a browser. 27 tabs are open, 9 aren't responding,
lots of pop-ups...and where is that annoying music coming from?

Bosse_B
Posts: 966
Joined: Thu Jan 30, 2014 9:53 am

Re: VNC cannot login to desktop on RPi4B, why?

Tue Feb 04, 2020 11:08 am

CONFIRMED!
Thank you, now I got to log in.
But I set the resolution in raspi-config to 1920x1080 and still the screen came out at 1024x768.
But using Preferences/Screen Configuration inside the GUI I could set it to 1920x1080 and it resized OK.

I am trying to nail down a problem with VNC right now involving the handling of special chars like {}[]\$£ etc.
All of these must be entered using the AltGr key on my Swedish keyboard.

But when I am programming (using FreePascal and the Lazarus IDE) on the RPi4 via VNC on a virtual desktop (address rpi-gui:1) then whenever I hit the AltGr key the IDE switches to the previous tab and then drops the resulting character into a different source file than intended.

It does not happen when working directly on the RPi itself, but that is an annoyance due to the switching of HDMI cables and the lack of cut-and-paste between the Windows laptop and the RPi4. So now I wanted to check if working through VNC directly to the base GUI on the RPi4 would be any different.
I can now say that the problem does not happen when VNC mirrors the base screen, only when I use a virtual desktop created in /etc/rc.local as follows:

Code: Select all

#Start VNC server with virtual desktop
#Access via RealVNC application through address <hostname>:1
#Size of desktop can be adjusted here.
sudo -u pi /usr/bin/vncserver -randr=1680x1040
This is accessed using hostname:1 in VNC and works very well except for the issue with the special characters....
Bo Berglund
Sweden

User avatar
FTrevorGowen
Forum Moderator
Forum Moderator
Posts: 5590
Joined: Mon Mar 04, 2013 6:12 pm
Location: Bristol, U.K.
Contact: Website

Re: VNC cannot login to desktop on RPi4B, why?

Tue Feb 04, 2020 12:13 pm

Bosse_B wrote:
Tue Feb 04, 2020 11:08 am
...
I can now say that the problem does not happen when VNC mirrors the base screen, only when I use a virtual desktop created in /etc/rc.local as follows:

Code: Select all

#Start VNC server with virtual desktop
#Access via RealVNC application through address <hostname>:1
#Size of desktop can be adjusted here.
sudo -u pi /usr/bin/vncserver -randr=1680x1040
This is accessed using hostname:1 in VNC and works very well except for the issue with the special characters....
Do things change if you don't "auto-start" the virtual server but just SSH in first and start it manually without using sudo! like I do here:
https://www.cpmspectrepi.uk/raspberry_p ... uster.html ?
Trev.
Still running Raspbian Jessie or Stretch on some older Pi's (an A, B1, 2xB2, B+, P2B, 3xP0, P0W, 2xP3A+, P3B+, P3B, B+, and a A+) but Buster on the P4B's. See: https://www.cpmspectrepi.uk/raspberry_pi/raspiidx.htm

Bosse_B
Posts: 966
Joined: Thu Jan 30, 2014 9:53 am

Re: VNC cannot login to desktop on RPi4B, why?

Tue Feb 04, 2020 3:34 pm

FTrevorGowen wrote:
Tue Feb 04, 2020 12:13 pm
Bosse_B wrote:
Tue Feb 04, 2020 11:08 am
...
I can now say that the problem does not happen when VNC mirrors the base screen, only when I use a virtual desktop created in /etc/rc.local as follows:

Code: Select all

sudo -u pi /usr/bin/vncserver -randr=1680x1040
This is accessed using hostname:1 in VNC and works very well except for the issue with the special characters....
Do things change if you don't "auto-start" the virtual server but just SSH in first and start it manually without using sudo! like I do here:
https://www.cpmspectrepi.uk/raspberry_p ... uster.html ?
Trev.
Please note that I am running the server started from /etc/rc.local as user pi!

Code: Select all

sudo -u pi /usr/bin/vncserver -randr=1680x1040
The -u argument sets the user context.

In any way I used to go in with PuTTY and start the vnc server manually some years ago, but I soon found it to be a drag so instead I put it into the startup script so it would be there as soon as the RPi had started....
And the AltGr problem is not apparent in Raspbian standard applications like the text editor etc. Not even in some dialogs like property setters in Lazarus, here AltGr works correctly. It is only inside the IDE code editor this happens. I have tried to explain it to the Lazarus developers but so far there has been no way to really show how it happens. Until today...

Now that I found a way to use the standard desktop instead of the virtual one I will try that out and see if it has other quirks.
My noticed problems with the virtual desktop have been:
  • Lazarus IDE does not pick up the AltGr key properly, so composed characters wind up in the editor tab to the left of the current file. This is solved using the standard desktop. Verified today.
  • Lazarus crashed on me (disappearing from screen) while I was editing inside of it losing all unsaved code changes. :( This happened infrequently but several times a day, so it forced me to move my coding to my Windows laptop. I do not know if it will still crash, but I will test with the new VNC connection and see if I am now OK or not. Hard to say it is working, easy to tell if not....
Bo Berglund
Sweden

Return to “General discussion”