سؤال

I'm reading up on SockJS node server. Documentation says:

Often WebSockets don't play nicely with proxies and load balancers. Deploying a SockJS server behind Nginx or Apache could be painful. Fortunately recent versions of an excellent load balancer HAProxy are able to proxy WebSocket connections. We propose to put HAProxy as a front line load balancer and use it to split SockJS traffic from normal HTTP data.

I'm curious if anyone can expand on the problem that is being solved by HAProxy in this case? Specifically:

  1. Why websockets don't play nice with proxies and load balancers?
  2. Why deploying Sockjs sever behind Apache is painful?
هل كانت مفيدة؟

المحلول

1. Why websockets don't play nice with proxies and load balancers?

I'd recommend you read this article on How HTML5 Web Sockets Interact With Proxy Servers by Peter Lubbers. It should cover everything you need to know about WebSocket and proxies - and thus, load balancers.

2. Why deploying Sockjs sever behind Apache is painful?

There is a module for handling WebSocket connections but at present Apache doesn't natively support WebSocket, nor does it look like it will any time soon based on this bug filed on apache - HTML5 Websocket implementation. The suggestion is that it actually fits the module pattern better.

So, it's "painful" simply because it's not easy - there's no official support and therefore it doesn't have the community use that it otherwise may have.

There may also be other pains in the SockJS has HTTP-based fallback transports. So you need to proxy both the WebSocket connections (using the apache-websocket module) and also HTTP requests when fallback is used.

Related to this: Nginx v1.3 was released in February with WebSocket support.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top