ryanb / private_pub

Handle pub/sub messaging through private channels in Rails using Faye.
MIT License
864 stars 228 forks source link

Websocket is connecting, GET requests failing (Switching Protocols?) #62

Closed natew closed 11 years ago

natew commented 11 years ago

I'm using nginx with the tcp_proxy module.

I can curl it just fine:

# curl http://now.2u.fm:9200/faye\?message\=%5B%7B%22channel%22%3A%22%2Fmeta%2Fhandshake%22%2C%22version%22%3A%221.0%22%2C%22supportedConnectionTypes%22%3A%5B%22callback-polling%22%5D%2C%22id%22%3A%221%22%7D%5D\&jsonp\=__jsonp6__
__jsonp6__([{"id":"1","channel":"/meta/handshake","successful":true,"version":"1.0","supportedConnectionTypes":["long-polling","cross-origin-long-polling","callback-polling","websocket","eventsource","in-process"],"clientId":"jls0srprht51xb368yrojft3h4drgu0","advice":{"reconnect":"retry","interval":0,"timeout":45000}}]);#

But in my website the GET requests for that same URL are failing after a long time waiting. Any idea what's going on?

It shows HTTP1.1 and that it's "switching protocols"? http://cl.ly/image/2Z1f2809222b

I've posted more details and screenshots on StackOverflow.

My tcp setup:

tcp {
  timeout 1d;
  websocket_read_timeout 1d;
  websocket_send_timeout 1d;

  upstream websockets {
    server 127.0.0.1:9292;
    check interval=3000 rise=2 fall=5 timeout=1000;
  }

  server {
    server_name now.2u.fm;
    listen 199.36.105.34:9200;

    timeout 64000;

    so_keepalive on;
    tcp_nodelay on;

    websocket_pass websockets;
    websocket_buffer 1k;
  }
}

I've tried with proxy_pass instead of websocket_pass but that actually causes the whole page to hang while loading.

natew commented 11 years ago

This was because the tcp module must bind to a different port and can't allow http. I ended up using HAProxy instead.