0

I am trying to tunnel websockets over TCP. I know how to tunnel HTTPS - "Connect URL:port" is where I start. From there, one opens a socket to the target and then just pipe between the client and the target. Where do I start with websockets? is there something similar to a "Connect url:port" to begin with, which I can catch in my http server and then do some upgrade processing?

1 Answers1

0

You sure you want to tunnel WebSocket over TCP? WebSocket runs over TCP.

I think you mean you want to tunnel TCP traffic with WebSocket, i.e., take an existing, traditional Socket-based application and make it work over the web. If that's what you mean, you essentially put your TCP data in a WebSocket frame and on the receiving end you read the WebSocket frame and extract the data. Of course this is easier said than done. You have to make sure you create the WebSocket frame correctly on the sender side (also handling the TCP data stream, which also may be tricky), encrypt the data (its going over the web, right?) and on the receiving side read the WebSocket frame, extract the data from the right parts of the frame. And also you need to check to see if all the data is in one WebSocket frame or multiple frames.

As I said, its not dead simple.

There are several WebSocket libraries out there that may (or may) not handle all of this for you (many do not handle the multiple WebSocket frame situation).

FrankG
  • 515
  • 2
  • 3
  • My exact requirement - To proxy websocket connection. The proxy is written by me. I proxy https and http and that was easy to implement, thanks to Node's http and net modules. But I am not sure how to proxy wss. I can live with the proxy only working for wss and not ws. Cannot upvote... not enough votes. – CyrusDCosta Dec 23 '15 at 04:29
  • Does this Node WebSocket module help? https://www.npmjs.com/package/nodejs-websocket – FrankG Dec 29 '15 at 20:49