Search code examples
ruby-on-railsnginxwebsocketfaye

Faye works with a delay


I use rails applicaton at my local machine and it works fine. But I can't make it work at production server.

I use thin and nginx, as I know nginx doesnt support websockets. Sometimes I saw an error in logs: '[Faye::RackAdapter] input must be a string or IO". I read forums and disabled websockets in faye adding line "Faye.Transport.WebSocket.isUsable = function(_,c) { c(false) };" at the end of faye-browser.js.

I see this post requests in firebug:

[{"id":"1","channel":"/meta/handshake","successful":true,"version":"1.0","supportedConnectionTypes":["long-polling","cross-origin-long-polling","callback-polling","websocket","eventsource","in-process"],"clientId":"3q84u8vsc0mtdehob5dweh5nw","advice":{"reconnect":"retry","interval":0,"timeout":45000}}]

and this:

[{"id":"2","clientId":"3q84u8vsc0mtdehob5dweh5nw","channel":"/meta/subscribe","successful":true,"subscription":"/queue/chat"},{"id":"3","clientId":"3q84u8vsc0mtdehob5dweh5nw","channel":"/meta/connect","successful":true,"advice":{"reconnect":"retry","interval":45000,"timeout":0}}]

Now faye actually works, but it take ~30-60 seconds to get request and update the page. Is there a way to reduce interval of checking?

My nginx conf: http://pastie.org/3982274[Faye::RackAdapter] input must be a string or IO


Solution

  • Problem solved. I had to install HAproxy and put it before nginx.