Hi, I'm trying to get Haproxy proxies to connect through socket.io
I read almost everything I can find on google and tried countless variations of haproxy.cfg, but no matter what I try to use socket.io, it always goes back to a lengthy poll.
It is worth noting that the ws connection works fine if I route the connection directly to the im socket server using.
So, I am using socket.io client and tornadio2 tornado web server server. my current haproxy.cfg taken from here is an example of haproxy conf
defaults
mode http
frontend all
bind 0.0.0.0:80
mode tcp
maxconn 200000
timeout client 86400000
default_backend www_backend
acl is_websocket path_beg /socket.io
acl is_websocket hdr(Upgrade) -i WebSocket
acl is_websocket hdr_beg(Host) -i ws
use_backend socket_backend_http if is_websocket
tcp-request inspect-delay 500ms
tcp-request content accept if HTTP
backend www_backend
option httplog
option httpclose
balance roundrobin
option forwardfor
timeout server 30000
timeout connect 4000
server nginx localhost:81 weight 1 maxconn 1024 check
backend socket_backend_http
mode http
option httplog
option http-server-close
option forceclose
no option httpclose
balance roundrobin
option forwardfor
timeout queue 5000
timeout server 86400000
timeout connect 86400000
timeout check 1s
server socket1 localhost:3012 weight 1 maxconn 1024 check
the websocket request is correctly routed to socket_backend_http, but the following error is always displayed in the browser console.
Unexpected response code: 400
socket.io .
, firefox .
, , , ! , .
, , haproxy 80, nginx 81, 3012. - , ,
haproxy.cfg
Traceback (most recent call last):
File "/home/mike/.virtual-envs/watchdog-app/local/lib/python2.7/site- packages/tornado/ioloop.py", line 399, in _run_callback
callback()
File "/home/mike/.virtual-envs/watchdog-app/local/lib/python2.7/site-packages/tornado/iostream.py", line 304, in wrapper
callback(*args)
File "/home/mike/.virtual-envs/watchdog-app/local/lib/python2.7/site-packages/tornado/httpserver.py", line 250, in _on_headers
self.request_callback(self._request)
File "/home/mike/.virtual-envs/watchdog-app/local/lib/python2.7/site-packages/tornado/web.py", line 1362, in __call__
handler._execute(transforms, *args, **kwargs)
File "/home/mike/.virtual-envs/watchdog-app/local/lib/python2.7/site-packages/tornado/web.py", line 992, in _execute
self._handle_request_exception(e)
File "/home/mike/.virtual-envs/watchdog-app/local/lib/python2.7/site-packages/tornado/web.py", line 1032, in _handle_request_exception
self.send_error(500, exc_info=sys.exc_info())
File "/home/mike/.virtual-envs/watchdog-app/local/lib/python2.7/site-packages/tornado/web.py", line 688, in send_error
self.finish()
File "/home/mike/.virtual-envs/watchdog-app/local/lib/python2.7/site-packages/tornado/web.py", line 669, in finish
self.request.finish()
File "/home/mike/.virtual-envs/watchdog-app/local/lib/python2.7/site-packages/tornado/httpserver.py", line 422, in finish
self.connection.finish()
File "/home/mike/.virtual-envs/watchdog-app/local/lib/python2.7/site-packages/tornado/httpserver.py", line 183, in finish
assert self._request, "Request closed"
UPDATE
, . , stunnel. nginx HTTP- https, , ssl stunnel, 8443, haproxy . , , , , id -, , ssl, http!!!