sibson / vncdotool

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

vncdotool can't capture screen from an unknown server whereas UltraVNC Viewer can #283

Closed occoder closed 6 months ago

occoder commented 6 months ago

vncdotool version: vncdotool 1.3.0

VNC server and version: Local desktop: UltraVNC server 1.4.3.6, Instrument: unknown

Steps to reproduce Run vncdo -vvv -s 127.0.0.1::5900 capture screen1.png and vncdo -vvv -s 192.168.153.2::5900 capture screen2.png respectively. Where the local PC @ 127.0.0.1 and an instrument with built-in VNC server @192.168.153.2

Expected result Both should be able to get the screenshot saved. Which erroneous result did you get instead Only the local PC works with following logs

INFO:root:connecting to 127.0.0.1:5900
INFO:twisted:Starting factory <vncdotool.command.VNCDoCLIFactory object at 0x00000174028F0050>
INFO:twisted:Using protocol version 3.8
INFO:twisted:Offered <AuthTypes.ULTRA: 17>
INFO:twisted:Offered '<AuthTypes.UNKNOWN: 75>'
INFO:twisted:Offered <AuthTypes.VNC_AUTHENTICATION: 2>
INFO:twisted:Native PixelFormat(bpp=32, depth=24, bigendian=False, truecolor=True, redmax=255, greenmax=255, bluemax=255, redshift=16, greenshift=8, blueshift=0) bytes=4
INFO:twisted:Offering <Encoding.RAW: 0>
INFO:twisted:Offering <Encoding.PSEUDO_DESKTOP_SIZE: -223>
INFO:twisted:Offering <Encoding.PSEUDO_LAST_RECT: -224>
INFO:twisted:Offering <Encoding.PSEUDO_QEMU_EXTENDED_KEY_EVENT: -258>
INFO:root:connected to b'desktop-123abc ( 200.100.20.10 ) - application mode'
DEBUG:vncdotool.client:captureScreen screen.png
INFO:twisted:x=0 y=0 w=1680 h=1050 <Encoding.RAW: 0>
DEBUG:vncdotool.client:captureSave screen.png
INFO:twisted:Stopping factory <vncdotool.command.VNCDoCLIFactory object at 0x00000174028F0050>
INFO:twisted:Main loop terminated.

The instrument did not response with any screenshot data

INFO:root:connecting to 192.168.153.2:5900
INFO:twisted:Starting factory <vncdotool.command.VNCDoCLIFactory object at 0x00000133E34077D0>
INFO:twisted:Using protocol version 3.8
INFO:twisted:Offered <AuthTypes.NONE: 1>
INFO:twisted:Native PixelFormat(bpp=16, depth=16, bigendian=False, truecolor=True, redmax=31, greenmax=63, bluemax=31, redshift=11, greenshift=5, blueshift=0) bytes=2
INFO:twisted:Offering <Encoding.RAW: 0>
INFO:twisted:Offering <Encoding.PSEUDO_DESKTOP_SIZE: -223>
INFO:twisted:Offering <Encoding.PSEUDO_LAST_RECT: -224>
INFO:twisted:Offering <Encoding.PSEUDO_QEMU_EXTENDED_KEY_EVENT: -258>
INFO:root:connected to b'Instrument'
DEBUG:vncdotool.client:captureScreen screen2.png
INFO:twisted:Stopping factory <vncdotool.command.VNCDoCLIFactory object at 0x00000133E34077D0>
INFO:twisted:Main loop terminated.

Additional information However, when UltraVNC Viewer was used to connect the instrument, the live screen of the instrument can be displayed without any issue. P.S. The above log from the instrument only appears when the very first time it is connected. Afterwards, the connection is refused by executing any other operation.

INFO:root:connecting to 192.168.153.2:5900
INFO:twisted:Starting factory <vncdotool.command.VNCDoCLIFactory object at 0x000001BBE3C41D50>
CRITICAL:root:Connection was refused by other side: 10061: Connection refused.
INFO:twisted:Stopping factory <vncdotool.command.VNCDoCLIFactory object at 0x000001BBE3C41D50>
INFO:twisted:Main loop terminated.
occoder commented 6 months ago

I tried to tweak the encoder setting of UltraVNC Viewer. It turned out that ONLY setting with RAW encoder leads to the similar case that was encountered when using vncdotool. It's should not be surprising as the RAW encoder seems to be the ONLY encoder that vncdotool supports. uvnc And I got following blank screenshot screen Likewise, thereafter, UltraVNC Viewer is not able to reconnect to the VNC server unless the server is rebooted.

I also tried

vncdotool.client.VNCDoToolClient.encoding = vncdotool.rfb.Encoding.ZRLE
client = api.connect("192.168.153.2::5900")

but it did not work.

pmhahn commented 6 months ago

I also tried vncdotool.client.VNCDoToolClient.encoding = vncdotool.rfb.Encoding.ZRLE but it did not work.

Only RAW is implemented, nothing else.