sidorares / node-rfb2

rfb wire protocol client and server

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Server doesn't receive key events or pointer events

ChrisEineke opened this issue · comments

I've a VNC server running on a KVM switch here. rfb2 prints

3.003 security type: 2

but the server seems to ignore any and all key events and pointer events. No error event is emitted, so I'm wondering what's going on here. ._.

Difficult to tell from your description :(
What server are you using? I only tested it with x11vnc, OSX server and windowd+tightvnc
Maybe tcpdump would help

The manufacturer states that a TightVNC client would have the best compatibility with the embedded VNC server, and VNC works as expected if I use xtightvncviewer, xvncviewer, or Remmina. Wireshark correctly interprets the client->server packet as a mouse down/up and key down/up, but doesn't decode the response packet.

Is it necessary to call requestUpdate at any point in time? I'm only interested in using mouse and keyboard.

No, requestUpdate is for screen rectangles only and should be optional

I called requestUpdate for experimentation. It throws a TypeError because foregroundColor is undefined (in drawRect). I added a return to the function, simply short-circuiting the code in drawRect. rfb2 now prints unsopported server message: 96. Like you're indicating, this may be another bug.

Can you show your code?

Okay, I can confirm that I have to call requestUpdate periodically, or else the input won't show up on the server.

rfb2 = require("rfb2");
util = require("util");

var device = rfb2.createConnection({
        host : "xxx",
        port : "xxx",
        password : "xxx"
});

function pressKey(keysym) {
    setTimeout(
        function () {
            device.keyEvent(keysym, 1);
            console.log(util.format("%d key pressed", keysym));
        },
        100);
    setTimeout(
        function () {
            device.keyEvent(keysym, 0);
            console.log(util.format("%d key released", keysym));
        },
        200);
}

device.on("error", function (error) {
    console.log("errored");
    console.log(error);
});

device.on("connect", function () {
    setTimeout(
        function () {
            pressKey(0x0061);
        },
        2000);
    setTimeout(
        function () {
            pressKey(0x0062);
        },
        2500);
    setTimeout(
        function () {
            pressKey(0x0063);
        },
        3000);

    setInterval(
        function () {
            device.requestUpdate(true, 0, 0, 1, 1);
        },
        10);
});

Without the setInterval calling requestUpdate repeatedly, keypresses and mouseclick will not get registered on the server.

Just tried your example from OSX to control virtualbox (x11vnc) - works fine without requestUpdate.

What version of node are you using? (v0.10.22)

same. There is very little node-specific code, I think I used library from version 0.4 without having compatibility issues during upgrades. Right now it's v0.10.22

Just realised that your server sends hextile-encoded rectangles and hextile is not really supported. I suggest to set list of supported encodings to be only raw + copyRect - just set 'encodings' array when you create connection. hextile is currently set by default, I should remove it - see code here https://github.com/sidorares/node-rfb2/blob/master/rfbclient.js#L235

Just realised I posted exactly the same comment 6 month ago :)

It would be great if you could merge a fix :)

hextile is no longer on by default since v0.0.10