dvelopp
dvelopp

Reputation: 4315

Dealing with node shutdown when using WebSocket with nginx

I use Spring WebSocket in my application. Like this:

https://spring.io/guides/gs/messaging-stomp-websocket/

The application will be run behind nginx on multiple nodes. What happens if the node where connection is created is shutdown?

Is there a way nginx could deal with that and use another node to keep connection?

I also consider creating a new connection if the target node is down, but it's only applicable if nginx does not do it.

Upvotes: 1

Views: 106

Answers (1)

Matan Hafuta
Matan Hafuta

Reputation: 605

If you are running multiple nodes and one is going down the client will need to reconnect to a new node, you can configure multiple websocket servers (processes on different ports) in the Nginx upstream, Nginx will just do an health check so it will forward traffic only to active nodes.

Upvotes: 1

Related Questions