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

Server connect to client in listening mode #4

Closed
ucchino opened this issue Sep 5, 2021 · 12 comments
Closed

Server connect to client in listening mode #4

ucchino opened this issue Sep 5, 2021 · 12 comments

Comments

@ucchino
Copy link

ucchino commented Sep 5, 2021

Greetings

I am trying to use the server by connecting to a client in listen mode. The client is a tightvnc version 2.8.59.
I simply configured it to listen on port 5500 but when starting the service I have an error (screenshot attached).
Here is the code for connecting to my local network: service.connect ("192.168.178.21", 5500);

Server and client are in the same network and same pc.

I tried in direct mode (tightvnc client connect to server) and all works fine.

Immagine

Am I doing something trivial wrong?

@idelac3
Copy link
Owner

idelac3 commented Sep 6, 2021

did you try to capture packets with Wireshark on TCP port 5500 ?
That could show if all is ok on network layer(s), eg. no firewall is blocking etc.

@ucchino
Copy link
Author

ucchino commented Sep 6, 2021

Attached wireshark logs and client configuration (tried hextile also).

I tried connection client to server also but same error... hmmmm

tightvnc_client_listening_from_server_on_5500.zip
tight_conf
tightvnc_client_to_server_on_5900.zip

@ucchino
Copy link
Author

ucchino commented Sep 7, 2021

I'm adding tightvnc log also. Log of direct and reverse connection are equals:

[38932/37076] 2021-09-07 10:19:19 - Init WinSock 2.1
[38932/17916] 2021-09-07 10:19:21 - Protocol stage is "Connection establishing".
[38932/17916] 2021-09-07 10:19:21 - Protocol stage is "Handshake".
[38932/17916] 2021-09-07 10:19:21 - Server sent protocol version: RFB 003.008
[38932/17916] 2021-09-07 10:19:21 - Send to server protocol version: RFB 003.008
[38932/17916] 2021-09-07 10:19:21 - Protocol stage is "Authentication".
[38932/17916] 2021-09-07 10:19:21 - Security type is selected: 1
[38932/17916] 2021-09-07 10:19:21 - Authentication type accepted: None (1)
[38932/17916] 2021-09-07 10:19:21 - Protocol stage is "Initialization".
[38932/17916] 2021-09-07 10:19:21 - Setting share flag in on...
[38932/17916] 2021-09-07 10:19:21 - Frame buffer dimension: (1366, 768)
[38932/17916] 2021-09-07 10:19:21 - Frame buffer pixel format: [bits-per-pixel: 32, depth: 24, big-endian-flag: 0, true-color-flag: is set, red-max: 255, green-max: 255, blue-max: 255, red-shift: 16, green-shift: 8, blue-shift: 0]
[38932/17916] 2021-09-07 10:19:21 - Server remote name: GUCCHINOW\gucchino [Windows 10 amd64]
[38932/17916] 2021-09-07 10:19:21 - Protocol stage is "Is connected".
[38932/37076] 2021-09-07 10:19:21 - Process focus restoration in the RfbKeySym class
[38932/17916] 2021-09-07 10:19:21 - Protocol stage is "Encoding select".
[38932/17916] 2021-09-07 10:19:21 - Protocol stage is "Working phase".
[38932/17916] 2021-09-07 10:19:21 - Frame buffer dimension: (1366, 768)
[38932/17916] 2021-09-07 10:19:21 - Frame buffer pixel format: [bits-per-pixel: 8, depth: 8, big-endian-flag: 0, true-color-flag: is set, red-max: 7, green-max: 7, blue-max: 3, red-shift: 0, green-shift: 3, blue-shift: 6]
[38932/17916] 2021-09-07 10:19:21 - onDisconnect: Connection has been gracefully closed
[38932/37076] 2021-09-07 10:19:21 - Process focus loss in the RfbKeySym class
[38932/37076] 2021-09-07 10:19:22 - Process focus restoration in the RfbKeySym class
[38932/37076] 2021-09-07 10:19:22 - Process focus loss in the RfbKeySym class
[38932/37076] 2021-09-07 10:19:22 - Process focus restoration in the RfbKeySym class
[38932/37076] 2021-09-07 10:19:22 - Process focus loss in the RfbKeySym class
[38932/37076] 2021-09-07 10:19:22 - Process focus restoration in the RfbKeySym class
[38932/37076] 2021-09-07 10:19:22 - Process focus loss in the RfbKeySym class
[38932/37076] 2021-09-07 10:19:22 - Process focus restoration in the RfbKeySym class
[38932/37076] 2021-09-07 10:19:22 - Viewer collector: destroy all instances
[38932/37076] 2021-09-07 10:19:22 - Shutdown WinSock

@idelac3
Copy link
Owner

idelac3 commented Sep 7, 2021

Looks like a bug on RFB service side.

You could try changing preferred encoding (eg. from tight to raw) and possibly other params.
I'll try to analyze and fix it.

@ucchino
Copy link
Author

ucchino commented Sep 7, 2021 via email

@idelac3
Copy link
Owner

idelac3 commented Sep 7, 2021

try with other vnc clients. That would help to isolate the cause.

I've tested with some versions, there is a table in README file.

@ucchino
Copy link
Author

ucchino commented Sep 7, 2021

Attached a zip with various log by tightvnc and ultravnc and wireshark

I hope this can help you. if i can help you let me know, ask anything.

The only statement i use is the following:

try {
service.connect("192.168.178.21", 5500);
} catch (IOException ex) {
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
}

logs.zip

@idelac3
Copy link
Owner

idelac3 commented Sep 8, 2021

I have tried TightVNC viewver from
(ver. 2.8.59)

and it works.

Are you sure you are using latest source code of RFB service project ?

@ucchino
Copy link
Author

ucchino commented Sep 8, 2021

Perhaps solved...

One problem hides another

I had previously imported the project into mine but a conflict between ch.qos.logback and org.slf4j was causing problems.

So from now on I just launch the original RFBService project and the RFBServiceExample class.

For direct connection the problem appears to be due to a tightvnc 256 color support setting. With server listening i have that tightvnc at 256 colors it never works, in ultravnc yes. So the direct connection works avoiding tight256 :)

With the server calling the listening client instead ultravnc works well in raw, hextile, tight even at 256.

Tightvnc instead always gives as answer: "Error in tightvnc Viewer: Pseudo encoding -1 is not supported".

I think it is a problem of the viewer as every time the client exits the listening mode I always see the 256 colors flag active.
Maybe it's a bug in the gui so it keep 256 color flag active.

Infact during my test in tight I indicated hextile not 256 as the pixel model and in the rfb logs I see:

10: 34: 47.759 [ClientHandler- [localhost: 5500]] INFO com.scoreunit.rfb.service.ClientHandler - RFB protocol: 3.8
10: 34: 47.882 [FramebufferUpdater- [ClientHandler- [localhost / 127.0.0.1: 5500]]] INFO com.scoreunit.rfb.service.SelectEncoder - Selected encoder by client: 'RawEncoder'.
10: 34: 49.231 [ClientHandler- [localhost: 5500]] INFO com.scoreunit.rfb.service.ClientHandler - Client connection 'localhost / 127.0.0.1: 5500' closed.

The encoder is different from what I had set in the client.

I attach tightvnc log:

[7336/18900] 2021-09-08 10:37:05 - Init WinSock 2.1
[7336/18536] 2021-09-08 10:37:30 - Protocol stage is "Connection establishing".
[7336/18536] 2021-09-08 10:37:30 - Protocol stage is "Handshake".
[7336/18536] 2021-09-08 10:37:30 - Server sent protocol version: RFB 003.008
[7336/18536] 2021-09-08 10:37:30 - Send to server protocol version: RFB 003.008
[7336/18536] 2021-09-08 10:37:30 - Protocol stage is "Authentication".
[7336/18536] 2021-09-08 10:37:30 - Security type is selected: 1
[7336/18536] 2021-09-08 10:37:30 - Authentication type accepted: None (1)
[7336/18536] 2021-09-08 10:37:30 - Protocol stage is "Initialization".
[7336/18536] 2021-09-08 10:37:30 - Setting share flag in on ...
[7336/18536] 2021-09-08 10:37:30 - Frame buffer dimension: (1366, 768)
[7336/18536] 2021-09-08 10:37:30 - Frame buffer pixel format: [bits-per-pixel: 32, depth: 24, big-endian-flag: 0, true-color-flag: is set , red-max: 255, green-max: 255, blue-max: 255, red-shift: 16, green-shift: 8, blue-shift: 0]
[7336/18536] 2021-09-08 10:37:30 - Server remote name: GUCCHINOW \ gucchino [Windows 10 amd64]
[7336/18536] 2021-09-08 10:37:30 - Protocol stage is "Is connected".
[7336/18900] 2021-09-08 10:37:30 - Process focus restoration in the RfbKeySym class
[7336/18536] 2021-09-08 10:37:30 - Protocol stage is "Encoding select".
[7336/18536] 2021-09-08 10:37:30 - Protocol stage is "Working phase".
[7336/18536] 2021-09-08 10:37:30 - Frame buffer dimension: (1366, 768)
[7336/18536] 2021-09-08 10:37:30 - Frame buffer pixel format: [bits-per-pixel: 8, depth: 8, big-endian-flag: 0, true-color-flag: is set , red-max: 7, green-max: 7, blue-max: 3, red-shift: 0, green-shift: 3, blue-shift: 6]
[7336/18536] 2021-09-08 10:37:30! Pseudo encoding -1 is not supported
[7336/18536] 2021-09-08 10:37:30 + RemoteViewerCore. Exception: Pseudo encoding -1 is not supported
[7336/18900] 2021-09-08 10:37:30 - Process focus loss in the RfbKeySym class
[7336/18900] 2021-09-08 10:37:53 - Process focus restoration in the RfbKeySym class
[7336/18900] 2021-09-08 10:37:53 - Process focus loss in the RfbKeySym class
[7336/18900] 2021-09-08 10:37:53 - Process focus restoration in the RfbKeySym class
[7336/18900] 2021-09-08 10:37:53 - Process focus loss in the RfbKeySym class
[7336/18900] 2021-09-08 10:37:53 - Process focus restoration in the RfbKeySym class
[7336/18900] 2021-09-08 10:37:53 - Process focus loss in the RfbKeySym class
[7336/18900] 2021-09-08 10:37:53 - Process focus restoration in the RfbKeySym class

WIRESHARK tightvnc log hextile no 256 (in theory): vncviewer_listening_hextile.zip

Could we consider closed (as wrong opened) this issue?

Your vnc server is the first i see fully functional.

Using it with novnc could be a real opensource-multiplatform-portable alternative to other closed-source commercial products.

Sure vnc is an old protocol but is well defined and stable.

Do you plan to extend it? Ex. To bypass the corporate proxy problem, add a vnc over http tunnel (ports 80,8080,443) would be usefull?

@idelac3
Copy link
Owner

idelac3 commented Sep 8, 2021

Good that you have solved the problem.

I had some plans and ideas to continue developing this project. However, it's not easy to find enough time for it.

I've also tested with noVNC, I needed it in one of my Spring Boot MVC projects, where I had to provide clients ability to connect remotely to their desktops.
I had to use websockets, I remember.

@ucchino
Copy link
Author

ucchino commented Sep 8, 2021

I agree.
I also have little time between work and family... But I have always been interested in remote administration systems.
Many years ago i contributed to jremotedesktop for the video compression part, rmi and gui.
Your project is the first serious, orderly, working implementation of the vnc protocol in pure java.

The idea of ​​using novnc and websocket is excellent and guarantees usability from a simple browser, cool.
I don't know if there is support for file transfer, I need to investigate.

Spring boot is another great idea to have a self-contained and portable package of novnc.
I have just one doubt. Websockify (which is the novnc project that acts as a proxy websocket <-> tcp) seems does not supports listening mode (novnc/websockify#236) and maybe it will never support it .

For now novnc only supports direct mode and therefore if the vnc server is under nat (99%) it cannot be reachable.

It would be necessary to modify Novnc to add a Websockify independent listening websocket and rfbservice to add websocket support. I think...

@ucchino
Copy link
Author

ucchino commented Sep 13, 2021

Between novnc and guacamole you can think of using the latter.

Basically both should be put on a server.

Guacamole is more restrictive, it uses a tomcat (java, and guacd which must be compiled on the server) while novnc directly uses websockify (which currently does not support reverse connection but does not need to be compiled) in python. In both cases the hosting must be at least one vps.

I have read this comment: https://news.ycombinator.com/item?id=8168264 and I have to evaluate which one is actually more performing and complete.

Before modifying rfbservice for websocket support I would think about it.

It all depends on the product you are planning to make.

@ucchino ucchino closed this as completed Sep 20, 2021
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