max-mapper / websocket-stream

websockets with the node stream API
BSD 2-Clause "Simplified" License
665 stars 113 forks source link

How to forward one client connection to another? #121

Closed danxn closed 7 years ago

danxn commented 7 years ago

Hello!

I'm learning websocket-stream module not for a long time yet, so may be my question is a bit stupid - sorry for this.

I need to forward one client websocket connection with VNC stream (https://github.com/novnc/noVNC) to another client websocket connection on one websocket server. Now I'm doing such thing for JSON and Base64 encoded images "manually" - by resending messages with JSON and Base64 data between previosly binded with id's clients connections. But I need to do this for streams like VNC or webcams.

I need this to make possible to use webcam and VNC servers via simple 3G connection worldwide.

Could you please tell me - is it possible to convert one clients connection to stream and redirect it to another client connection with help of your module?

Best, Dan.

mcollina commented 7 years ago

Hi Dan,

What you want to achieve is probably possible, but it is not simple to achieve it in a scalable manner. How many connections are you planning to support?

As for a technical pointer, if you are sending a stream of binary data, converting them to JSON or base64 is probably slow.

Matteo Il giorno dom 7 mag 2017 alle 12:19 danxn notifications@github.com ha scritto:

Hello!

I'm learning websocket-stream module not a long time yet, so may be my question is a bit stupid - sorry for this.

I need to forward one client websocket connection with VNC stream ( https://github.com/novnc/noVNC) to another client websocket connection on one websocket server. Now I'm doing such thing for JSON and Base64 encoded images "manually" - by resending messages with JSON and Base64 data between previosly binded with id's clients connections. But I need to do this for streams like VNC or webcams.

I need this to make possible to use webcam and VNC servers via simple 3G connection worldwide.

Could you please tell me - is it possible to convert one clients connection to stream and redirect it to another client connection with help of your module?

Best, Dan.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/maxogden/websocket-stream/issues/121, or mute the thread https://github.com/notifications/unsubscribe-auth/AADL4_Duy9i4mTvGDYlPMtwUQPRC3jZAks5r3ZqogaJpZM4NTF2L .

danxn commented 7 years ago

Hello, Matteo!

Understood, thank you very much for answer.

Well, for now I need this for few "tunnels": 1-4. I'm working on IoT/Embeddable network electronic systems for home/local area automation. It is very interesting possibility to use for this purpouse few webcams, connected to some kind of single-board mini-computer (RaspberryPI, OrangePI, BananaPI, NanoPI, Odroid, Cubieboard etc) - to use computer vision with help of this cameras and mini-PC's. And it is usefull to have stream access to this cameras via internet with very simple setup, like connecting this computers to internet via WiFi hotspot created with smartphone with 3G internet connection. But with stream data these are some problems. I can get photos with high enought frequency (1-0,3fps, ie 1 frame in 1-3 seconds), but it would be great to get videostream with help of this kind of connection like on YouTube. May be I should look in this direction. But I think it is possible to make "tunnel" for stream data between two users websocket connection. For JSON and Base64 this is not very difficult - I'm initialising binding between two users connection with special messages, by setting special binding id's to this connections objects and retranslating messages from one connection to another with help of this binding. So, I think it is possible for streams inside this connections, but I don't know how to do this yet.

Could you please tell me - how difficult to implement this? I think this is very usefull feature - no need difficult network setup for creating webcam application available via internet worldwide.

Best regards, Dan

UPD. I think even if solution will support only 1 "tunnel" it is possible to scale it in nodeJS with help of some kind of clusterization. It will be not so efficient as only one WS server with multiply tunnels, but I think it will be acceptible solution. But I think it will be good, if tunneling will be implemented without converting binary stream to base64 because it may slow down connection significantly.

mcollina commented 7 years ago

You can try http://npm.im/multiplex or http://npm.im/tentacoli.

danxn commented 7 years ago

Thank you very much.