sidorares / node-rfb2

rfb wire protocol client and server
MIT License
139 stars 27 forks source link

Server doesn't receive key events or pointer events #3

Open ChrisEineke opened 10 years ago

ChrisEineke commented 10 years ago

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. ._.

sidorares commented 10 years ago

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

ChrisEineke commented 10 years ago

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.

ChrisEineke commented 10 years ago

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

sidorares commented 10 years ago

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

ChrisEineke commented 10 years ago

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.

sidorares commented 10 years ago

Can you show your code?

ChrisEineke commented 10 years ago

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

ChrisEineke commented 10 years ago
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);
});
ChrisEineke commented 10 years ago

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

sidorares commented 10 years ago

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

ChrisEineke commented 10 years ago

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

sidorares commented 10 years ago

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

sidorares commented 10 years ago

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

sidorares commented 10 years ago

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

ChrisEineke commented 10 years ago

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

sidorares commented 10 years ago

hextile is no longer on by default since v0.0.10