sidorares / node-rfb2

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

Error: read ECONNRESET #27

Closed cvhariharan closed 5 years ago

cvhariharan commented 5 years ago

While I try to connect to TightVNC server using the example code provided in the README, I get this error { Error: read ECONNRESET at TCP.onStreamRead (internal/stream_base_commons.js:111:27) errno: 'ECONNRESET', code: 'ECONNRESET', syscall: 'read' } This could be a simple issue but any help would be appreciated.

sidorares commented 5 years ago

difficult to tell just from the error. Can you double check ip / port values are correct? Can you connect with some other client?

cvhariharan commented 5 years ago

I am able to connect with RealVNC viewer, the port and IP all seem to be correct.

sidorares commented 5 years ago

is this the only connection? Some vnc servers try to close all existing connections whenever new connection is made

cvhariharan commented 5 years ago

I think I may have found out the issue. Seems like a problem with calling requestUpdate. Commenting it out, the connection is successful.

sidorares commented 5 years ago

hm, updates are not sent automatically, usually a send 'requestUpdate' command immediately after receiving update. Do you receive any data after commenting this out?

cvhariharan commented 5 years ago

I am able to receive clipboard and resize events.

sidorares commented 5 years ago

I think requestUpdate is for screen rectangles, resize & clipboard sent automatically ( but I might be wrong here and could be server specific )

cvhariharan commented 5 years ago

I don't think I am able to receive any screen updates after commenting out requestUpdate

sidorares commented 5 years ago

Is there an easy way to replicate your issue? What's your os?

cvhariharan commented 5 years ago

OS: Windows 10 64 bit VNC server: TightVNC 2.8.11 with localhost connection enabled Node v10.16.0 Rfb2 0.2.0 NPM 6.9.0

var rfb = require('rfb2');
var r = rfb.createConnection({
  host: 'localhost',
  port: 5900,
  password: 'password'
});

r.on('connect', function() {
  console.log('successfully connected and authorised');
  console.log('remote screen name: ' + r.title + ' width:' + r.width + ' height: ' + r.height);
});

r.on('error', function(error) {
  console.error(error);
});

r.on('rect', function(rect) {
   console.log(rect.encoding)
});

r.on('resize', function(rect) {
  console.log('window size has been resized! Width: %s, Height: %s', rect.width, rect.height);
});

r.on('clipboard', function(newPasteBufData) {
  console.log('remote clipboard updated!', newPasteBufData);
});

r.on('bell', console.log.bind(null, 'Bell!!'));
// r.requestUpdate(false, 0, 0, r.width, r.height);
sidorares commented 5 years ago

you can only do requestUpdate after client is connected, otherwise you write this command before connection handshake is finished

cvhariharan commented 5 years ago

Oh, that fixed the issue. Thanks a lot!

sidorares commented 5 years ago

just tried on windows laptop and not I'm getting any screen updates, did you have any luck?

Note that requestUpdate is sent after connection automatically - https://github.com/sidorares/node-rfb2/blob/822d0eafc3604abad57996faa208aaa1acb9a4cb/rfbclient.js#L241

sidorares commented 5 years ago

I should really update readme, the code is just a list of supported methods, not a working example

cvhariharan commented 5 years ago

No, I don't seem to receive any updates

just tried on windows laptop and not I'm getting any screen updates, did you have any luck?

Note that requestUpdate is sent after connection automatically -

https://github.com/sidorares/node-rfb2/blob/822d0eafc3604abad57996faa208aaa1acb9a4cb/rfbclient.js#L241

No, I don't seem to receive any updates

sidorares commented 5 years ago

you need to pass non empty list of supported encodings:

var r = rfb.createConnection({
  host: 'localhost',
  port: 5900,
  password: 'password',
  encodings: [rfb.encodings.raw]
});
sidorares commented 5 years ago

actually, it's set bu default to [raw, copyRect, pseudoDesktopSize] but for some reasons I only get updates when set it to raw only

cvhariharan commented 5 years ago

The event, rect would be triggered whenever there is a screen update right? If that's the case, I am still not receiving the update events after the initial one.

sidorares commented 5 years ago

I'm getting updates now with [rfb.encodings.raw]

cvhariharan commented 5 years ago

Do we have to call requestUpdatein the callback for rect?

sidorares commented 5 years ago

yes