jimsynz / faye-rails

Simple Rails glue for the Faye messaging protocol.
MIT License
435 stars 79 forks source link

Error 404 Not Found #35

Closed bodrovis closed 8 years ago

bodrovis commented 11 years ago

Hello. I am using Faye with Rails 3.2.12 to implement comments that are instantly showing up. Everything is working fine, however I get some errors in the Firebug console. When i open the page the POST request is being sent to "http://mydomain.com/faye" with the following response:

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

But right after this appears an error

"NetworkError: 400 Bad Request - http://mydomain.com/faye"

Then another POST request is again sent to the "http://mydomain.com/faye" with reponse like:

[{"id":"2","clientId":"j1ezqdmr62rap6njeqv7u21kj2nndw1","channel":"/meta/subscribe","successful":true,"subscription":"/comments"},{"id":"3","clientId":"j1ezqdmr62rap6njeqv7u21kj2nndw1","channel":"/meta/connect","successful":true,"advice":{"reconnect":"retry","interval":0,"timeout":25000}}]

Then another two errors appears:

Firefox can't establish a connection to the server at ws://mydomain.com/faye.

and

"NetworkError: 404 Not Found - http://mydomain.com/faye/j1ezqdmr62rap6njeqv7u21kj2nndw1/j1ezqdmr62rap6njeqv7u21kj2nndw1"

After these errors follow succesfull POST requests to the "http://mydomain.com/faye" with responses like:

[{"id":"5","clientId":"j1ezqdmr62rap6njeqv7u21kj2nndw1","channel":"/meta/connect","successful":true,"advice":{"reconnect":"retry","interval":0,"timeout":25000}}]

I get all these errors in production (Heroku).

Still the comments are being updated instantly and I detect no other errors or problems.

In my route file I get:

  faye_server '/faye', :timeout => 25

Am I doing something wrong or did I forget something?

Thanks!

jimsynz commented 11 years ago

Heroku doesn't support websockets, so what you're seeing is Faye trying to select the best transfer protocol. I think you can disable websockets in the client so that you don't see these errors.

bodrovis commented 11 years ago

Understood. I used

client.disable('websocket')

to disable websockets. Now I get only two errors after the page is loaded:

"NetworkError: 404 Not Found - http://mydomain.com/faye/4ex1s08qcb1tzby20uve9udda2v9nld/4ex1s08qcb1tzby20uve9udda2v9nld"

and

Firefox can't establish a connection to the server at http://mydomain.com/faye/4ex1s08qcb1tzby20uve9udda2v9nld/4ex1s08qcb1tzby20uve9udda2v9nld.
adedip commented 11 years ago

Same problem here, even disabling websockets doesn't work, I'm not using heroku though, everything works in development mode and does not in production env.

bodrovis commented 11 years ago

Well, I have to admit that everything is working fine for me, though I see those errors.

bcavileer commented 11 years ago

The GET request is generated by the EventSource connection type.

Try adding this: client.disable('eventsource');

Since I'm using Heroku, and WebSockets aren't supported, I disabled both: client.disable('websocket'); client.disable('eventsource');

This stopped the ActionController::RoutingError(s)

Praveen-Invoscape commented 7 years ago

@bcavileer @bodrovis i am also have this issue bad request for "https://mydomain.herokuapp.com/faye" for my domain.I am new to rails so plz explain to use your answer

bodrovis commented 7 years ago

@Praveen-Invoscape I have not used faye in quite a while, mainly because Rails 5 now has ActionCable. That line should be added into your JS or CoffeeScript file, but things may have changes during these years so it may not be needed. Also, your error may be related to something else. By the way, here is my article on Faye that may come in handy https://www.sitepoint.com/realtime-mini-chat-rails-faye/

bodrovis commented 7 years ago

@Praveen-Invoscape Also do note that now Heroku does support websockets - at least I had no problems with ActionCable.

Praveen-Invoscape commented 7 years ago

Thank you @bodrovis i will try to fix it by your link