Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Connection to a PLC not possible #9

Open
ar0707 opened this issue May 7, 2024 · 7 comments
Open

Connection to a PLC not possible #9

ar0707 opened this issue May 7, 2024 · 7 comments

Comments

@ar0707
Copy link

ar0707 commented May 7, 2024

I tried to run the example code, but the window remains black. Do you have any ideas what the problem could be?

[QVNCWidget]` DEBUG: backbuffer is None
[RFB Client <-] DEBUG: len: 12 | b'RFB 003.003\n'
[RFB Client] INFO: RFB from server: 3.3
[RFB -> Server] DEBUG: b'RFB 003.003\n'
[RFB Client] INFO: VNC connected
[RFB Client <-] DEBUG: len: 4 | b'\x00\x00\x00\x01'
[RFB -> Server] DEBUG: b'\x01'
[RFB Client <-] DEBUG: len: 24 | 
```b'\x02\x80\x01\xe0\x08\x08\x00\x00\x00\x07\x00\x07\x00\x03\x00\x03\x06\x00\x00\x00\x00\x00\x00\x11'
[RFB Client <-] DEBUG: len: 17 | b"VC Project 'Visu'"
[RFB Client] DEBUG: Connecting to "VC Project 'Visu'"
[RFB Client] DEBUG: Server Pixelformat: 8;8;0;0;7;7;3;0;3;6
[RFB Client] DEBUG: Resolution: 640x480
[RFB -> Server] DEBUG: b'\x02\x00\x00\x01'
[RFB -> Server] DEBUG: b'\x00\x00\x00\x00'
[QVNCWidget] INFO: VNC handshake done
[RFB -> Server] DEBUG: b'\x00\x00\x00\x00  \x00\x01\x00\xff\x00\xff\x00\xff\x10\x08\x00\x00\x00\x00'
[RFB -> Server] DEBUG: b'\x03\x00\x00\x00\x00\x00\x02\x80\x01\xe0'
Exception in thread Thread-1 (__start):
Traceback (most recent call last):
  File "C:\Users\test\AppData\Local\Programs\Python\Python311\Lib\threading.py", line 1038, in _bootstrap_inner
    self.run()
  File "C:\Users\test\AppData\Local\Programs\Python\Python311\Lib\threading.py", line 975, in run
    self._target(*self._args, **self._kwargs)
  File "C:\repo\venv\Lib\site-packages\qvncwidget\rfb.py", line 108, in __start
    self._handleInitial()
  File "C:\repo\venv\Lib\site-packages\qvncwidget\rfb.py", line 148, in _handleInitial
    self._handleAuth33(self.__recv(4))
  File "C:\repo\venv\Lib\site-packages\qvncwidget\rfb.py", line 163, in _handleAuth33
    self._doClientInit()
  File "C:\repo\venv\Lib\site-packages\qvncwidget\rfb.py", line 173, in _doClientInit
    self._handleServerInit(self.__recv(24))
  File "C:\repo\venv\Lib\site-packages\qvncwidget\rfb.py", line 200, in _handleServerInit
    self._mainRequestLoop()
  File "C:\repo\venv\Lib\site-packages\qvncwidget\rfb.py", line 269, in _mainRequestLoop
    self.onFatalError(e)
  File "C:\repo\venv\Lib\site-packages\qvncwidget\rfb.py", line 482, in onFatalError
    raise error
  File "C:\repo\venv\Lib\site-packages\qvncwidget\rfb.py", line 251, in _mainRequestLoop
    dType = self.__recv(1)
            ^^^^^^^^^^^^^^
  File "C:\repo\venv\Lib\site-packages\qvncwidget\rfb.py", line 92, in __recv
    buffer = self.connection.recv(expectedSize, socket.MSG_WAITALL)    
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ConnectionResetError: [WinError 10054] Eine vorhandene Verbindung wurde vom Remotehost geschlossen
[RFB Client] DEBUG: Closing connection

Process finished with exit code 0`
@zocker-160
Copy link
Owner

zocker-160 commented May 7, 2024

Thank you for reporting and the debug log, I am sadly currently a bit short on time, but I will take a look at it.
From a brief look, it seems like after the pixelformat request the server is simply closing the connection.

Do other VNC clients work with that server?

@ar0707
Copy link
Author

ar0707 commented May 8, 2024

Thank you for taking the time. The UltraVNC Viewer is used for the connection. It works without any problems.

@zocker-160
Copy link
Owner

Could you try connecting using the following settings:
Screenshot_20240508_154302

@zocker-160
Copy link
Owner

zocker-160 commented May 11, 2024

So I did investigate this a bit more today and the only explanation I could come up with, is that the server is not supporting the requested pixelformat.

From your log, after a successful handshake, the client is requesting the pixel format and then requesting a new frame (the first frame actually) at which point the server closes the connection.

What I find interesting is the pixel format offered by the server, which is 8;8;0;0;7;7;3;0;3;6 according to your log. This means the server offers 8 bpp und a color depth of 8 bit, true color is set to false and a max color value of 7.

This is a terrible format, the image must look really bad. My client is always requesting 32;32;0;1;255;255;255;16;8;0 but your server does not seem to like it.

Sadly there is not much I can do tbh, I would need a Wireshark capture to see how a successful connection looks like and how it differs.

UPDATE:

After doing some more testing, I found out that sending an unsupported pixel format does make many VNC server behave exactly this way.

So one simply needs to find out which pixel formats your PLC supports.

@ar0707
Copy link
Author

ar0707 commented May 14, 2024

I tried your suggested settings and it seems to be working without any issues. Thank you for your help. When I have time, I will try to debug it myself.
image

@zocker-160
Copy link
Owner

Would it be possible for you to share a Wireshark capture of the working connection (using the settings with RAW encoding and no compression)?

It would help me a lot to debug the problem.

@ar0707
Copy link
Author

ar0707 commented May 16, 2024

I will try it out soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants