Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rustdesk not working when connected screen is turned off #7037

Closed
hatl opened this issue Feb 2, 2024 · 7 comments
Closed

Rustdesk not working when connected screen is turned off #7037

hatl opened this issue Feb 2, 2024 · 7 comments
Labels
bug Something isn't working invalid This doesn't seem right

Comments

@hatl
Copy link

hatl commented Feb 2, 2024

Bug Description

When connecting to a Linux PC with which has a monitor attached that's powered-off, I get: "Remote Error" "No Display"

How to Reproduce

Start rustdesk.
Remove power cable from monitor.
Try to connect --> error

Expected Behavior

Connection is working

Operating system(s) on local side and remote side

Ubuntu 23.10 -> Ubuntu 23.10

RustDesk Version(s) on local side and remote side

1.2.3 -> 1.2.3

Screenshots

Error message:
image

Working connection via x11vnc:
image

Additional Context

The corresponding X11 screen exists and should be used by rustdesk.

xrandr output:

Screen 0: minimum 8 x 8, current 3840 x 2160, maximum 32767 x 32767
DVI-D-0 disconnected (normal left inverted right x axis y axis)
HDMI-0 disconnected primary (normal left inverted right x axis y axis)
DP-0 disconnected (normal left inverted right x axis y axis)

The same use case works, when using x11vnc - while using the existing screen :0 (see screenshot)
You can even see that rustdesk is running when connecting via vnc

@hatl hatl added the bug Something isn't working label Feb 2, 2024
@rustdesk rustdesk closed this as completed Feb 2, 2024
@rustdesk rustdesk added the invalid This doesn't seem right label Feb 2, 2024
@rustdesk
Copy link
Owner

rustdesk commented Feb 2, 2024

This is not vnc

@rustdesk
Copy link
Owner

rustdesk commented Feb 2, 2024

#7032

@hatl
Copy link
Author

hatl commented Feb 2, 2024

I know that this is not VNC - the hint was just for reference.

This is not a duplicate of #4296
The main difference is, that in 4296 the screen won't be updated.

This is also not a headless system as described in #7032
There is a monitor connected initially and is powered-off afterwards.
So the whole desktop environment + X11 screen are running.

In my case, the screen is updated because the X11 screen still exists and can be interacted with.
For some reason rustdesk doesn't find/use the existing screen.

@hatl
Copy link
Author

hatl commented Feb 2, 2024

I did some analysis:
seems like the screen should be part of the iterator:

let mut outer = xcb_setup_roots_iterator(server.setup());

I've created a minimum example to show that the screen is actually available:

#include <stdio.h>
#include <stdlib.h>
#include <xcb/xcb.h>

int main(void) {
    /* Establish a connection to the X server */
    xcb_connection_t *connection = xcb_connect(NULL, NULL);
    if (xcb_connection_has_error(connection)) {
        fprintf(stderr, "Error: Cannot open display\n");
        exit(1);
    }

    /* Retrieve the setup data */
    const xcb_setup_t *setup = xcb_get_setup(connection);
    if (!setup) {
        fprintf(stderr, "Error: Cannot retrieve setup information\n");
        xcb_disconnect(connection);
        exit(1);
    }

    /* Use xcb_setup_roots_iterator to iterate through screens */
    xcb_screen_iterator_t iter = xcb_setup_roots_iterator(setup);
    int screen_num = 0;

    for (; iter.rem; xcb_screen_next(&iter), screen_num++) {
        xcb_screen_t *screen = iter.data;
        printf("Screen %d: %dx%d\n", screen_num, screen->width_in_pixels, screen->height_in_pixels);
    }

    /* Clean up and close the connection */
    xcb_disconnect(connection);
    return 0;
}

compile using:

gcc -o list_screens list_screens.c $(pkg-config --cflags --libs xcb)

this prints:
Screen 0: 3840x2160


Maybe the issue is somewhere here?

let mut displays = x11::Server::displays(server);
let mut best = displays.next();
if best.as_ref().map(|x| x.is_default()) == Some(false) {
best = displays.find(|x| x.is_default()).or(best);
}

@aki42
Copy link

aki42 commented Apr 7, 2024

Thanks a lot for your bug report - otherwise I never would have thought that the (sort of) solution to this problem really can be to turn on the monitor of the machine I want to control remotely. Of course this is no real solution because that monitor now consumes power without any use than to avoid the "Remote Error"/"No Display" errors. But the connection works at least. Really astonishing this bug got closed though you even provided demo code and a hint regarding where the code looking for displays might fail. 🤷

@hatl
Copy link
Author

hatl commented Apr 7, 2024

I was also quite surprised.
I still think this should be easily fixable (without turning the monitor on).

@cubicYYY
Copy link

#6682

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working invalid This doesn't seem right
Projects
None yet
Development

No branches or pull requests

4 participants