sibson / vncdotool

A command line VNC client and python library
Other
451 stars 120 forks source link

Bug: Constant "Cannot connect" error messages #262

Open redphx opened 1 year ago

redphx commented 1 year ago

vncdotool version vncdotool 1.1.0, python 3.1.0

VNC server and version Unknown, but it uses protocol version 3.8

Steps to reproduce

from vncdotool import api
import logging
logging.basicConfig(level=logging.DEBUG)

with api.connect('<VNC_SERVER>', timeout=60) as cli:
    cli.captureScreen('vnc.png')

Expected result Screenshot captured successfully.

Which erroneous result did you get instead Note: I printed data param in rfb.RFBClient.dataReceived() to get additional info.

INFO:twisted:Starting factory <vncdotool.client.VNCDoToolFactory object at 0x10f82a7a0>
b'RFB 003.008\n'
INFO:twisted:Using protocol version 3.8
b'\x01\x01'
INFO:twisted:Offered <AuthTypes.NONE: 1>
b'\x00\x00\x00\x01\x00\x00\x00\x00\x04\x00\x03\x00\xff\xff\xff!'
INFO:twisted:Cannot connect b''
INFO:twisted:Cannot connect b''
INFO:twisted:Cannot connect b''
INFO:twisted:Cannot connect b''
INFO:twisted:Cannot connect b''
INFO:twisted:Cannot connect b''
INFO:twisted:Cannot connect b''
INFO:twisted:Cannot connect b''
INFO:twisted:Cannot connect b''
INFO:twisted:Cannot connect b''
INFO:twisted:Cannot connect b''
INFO:twisted:Cannot connect b''
INFO:twisted:Cannot connect b''
INFO:twisted:Cannot connect b''
INFO:twisted:Cannot connect b''
INFO:twisted:Cannot connect b''
INFO:twisted:Cannot connect b''
....

It didn't stop until timed out (60s later).

Additional information Since the waitfor variable in _handleAuthFailed is 0, it kepts reconnecting instantly until timed out.
This bug also occurs in version 0.13.0.

pmhahn commented 1 year ago

b'RFB 003.008\n'

Hello, I'm a RFB server talking protocol version 3.008.

b'\x01\x01'

I offer a single authentication mechanism, which is AuthTypes.NONE

b'\x00\x00\x00\x01\x00\x00\x00\x00\x04\x00\x03\x00\xff\xff\xff!'

And now I'm pissed because authentication failed (0x00000001). Here are no messages with an explanation (0x00000000). And I send you additional garbage for your convenience: \x04\x00\x03\x00\xff\xff\xff!'

Summary: to me it looks like your server is announcing RFB3.8, but does not follow the protocol. There's not much we can do expect fixing the logic to terminate the function earlier, so that you do not have to wait for your timeout. (self.transport.loseConnection() is called, but the API does not handle this correctly?)

Have you checked any other VNC viewer, if they can be used to connect to that serrver? (name and version of any working VNC viewer please).

It would also be of interest, what kind of server you're trying to connect to. Without access to it or at least some information on which software and version it is, there's very little we can do to help you.

redphx commented 1 year ago

I couldn't connect to it using TightVNC either.

If the server doesn't follow the protocol then I'd love vncdotool to drop the connection instantly instead of trying again and again. Maybe drop connection when waitfor == 0?

Thank you.