1

I need to connect websockets with normal sockets, websockify looks seem the answer, but I don´t really understand what do I need to do whit this info: https://www.npmjs.com/package/node-websockify, do I need to create a Node js server, or only run into my page??

IIXIII
  • 21
  • 2
  • What does "connect webSockets with normal sockets" mean? What are the environments on your two endpoints? Do you control both endpoints? Or is one already fixed and you're trying to connect to it? If so, please describe the endpoint you are trying to connect to. – jfriend00 May 09 '17 at 22:48
  • Websockets from a js page, the other is a server that I dont have access to, only the ip and the port of a TCP socket, it sees websockify is the answer, but I cant run the project, the docs aren´t enough to me – IIXIII May 10 '17 at 13:35
  • 1
    A webSocket cannot be connected to a normal TCP socket. webSocket is its own protocol and must be connected to a webSocket server. If your server is just a plain TCP socket, then you can use just a plain TCP socket in node.js to connect to it. The [NET module in nodejs](https://nodejs.org/api/net.html) contains code for creating a plain TCP connection. You will, of course, have to manage exactly what is sent or read from the server you are connecting to yourself. A browser cannot connect to a plain TCP server, only to a webSocket server. – jfriend00 May 10 '17 at 16:10

1 Answers1

4

The websockify people were nice enough to create a node js version located here -

  1. enter the command node websockify.js [--web web_dir] [--cert cert.pem [--key key.pem]] [source_addr:]source_port target_addr:target_port

so the command:

node websockify.js --web web 127.0.0.1:9988 192.168.1.40:5432

would start a "relay" from the target address (the server you don't have access to) to your own proxy server (server you do have access to - where you are proxying the websockets from the vnc server to TCP, which enables you to view the connection via web browser. With this proxy comes a built-in web server to "serve" the view. so the web option is the location of said HTML, CSS, and JS files to display. If you copy the files from the app directory css-files and the vnc file from the root with all dependencies, you can then view the files by navigating to the source IP address and port and that should take care of it.

romeski
  • 96
  • 4