Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Redirecting websocket communication from client to a server to another websocket server

Tags:

I already have a SimpleBrokerWebsocket implementation. Now I am migrating towards microservices based architecture and trying to create messaging as a separate microservice.

To avoid breaking existing client deployments and to gradually move towards a complete microservice based architecture, I want my old socket end points to redirect to the new socket end points provided by the microservice.

So I need some idea on, how to deal with the authentication and sending messages to correct users.

Also I would like to know how to go about the architecture for this requirement . I would like to use StompBrokerRelay for microservice.

like image 865
Vivek Avatar asked Sep 01 '16 15:09

Vivek


People also ask

Can you proxy WebSocket?

An explicit forward proxy is a forward proxy which the client is configured to use. The client is aware of the presence of this proxy. In these situations it is easier for the client to establish a WebSocket connection with the server for reasons outlined in the section WebSocket Delivery Mode.

Can WebSockets be spoofed?

If you build your websocket over HTTP, then yes, it is completely possible for a third party to spoof the connection (and also to eavesdrop). If your HTTPS/WSS system does not properly validate certificates, then that also can be spoofed.

How do I connect to a WebSocket server?

In order to communicate using the WebSocket protocol, you need to create a WebSocket object; this will automatically attempt to open the connection to the server. The URL to which to connect; this should be the URL to which the WebSocket server will respond.

Is WebSocket two way communication?

The WebSocket API is an advanced technology that makes it possible to open a two-way interactive communication session between the user's browser and a server. With this API, you can send messages to a server and receive event-driven responses without having to poll the server for a reply.


1 Answers

Generally when you deploy web applications you run them behind a reverse proxy.
In a service oriented architecture this is even more common.
NGINX can perform reverse proxying of websocket connections.
So you can run your application behind NGINX pointing to your original application, then when you are ready to deploy your new websocket microservice, you can configure NGINX to proxy all requests for that particular websocket URL to your new service.
You could also try implementing your own reverse websocket proxy in Java by using a websocket client from your socket handler, but this would be difficult, error prone and slower than using a specialized tool like NGINX.

like image 111
Magnus Avatar answered Oct 11 '22 10:10

Magnus