Unexpected response code:200 #72

Closed
Thibaut opened this Issue Jun 19, 2011 · 9 comments

Comments

Projects
None yet
3 participants
Contributor

Thibaut commented Jun 19, 2011

My Faye server is deployed on Heroku which does not support WebSockets.
I don't know why it actually doesn't work but it causes trouble with Chrome/Safari.

  • Chrome reverts to JSONP even though CORS is possible and displays the error 'Unexpected response code:200' 30 seconds later.
  • Safari displays the same error message immediately and then fails to connect entirely.

I'll see if I can work out a patch. In the mean time I've disabled WebSockets on my Faye server.

Collaborator

jcoglan commented Jun 19, 2011

Could you get involved with this thread, it seems like this problem and the CORS origin problem are related:

http://groups.google.com/group/faye-users/browse_thread/thread/bc98f8a41093be47

Contributor

Thibaut commented Jun 19, 2011

This issue is caused by callback.call(scope, false) being called after a delay (or asynchronously) in Faye.Transport.WebSocket.isUsable.

It's unrelated to WebSocket (it just so happens that WebSocket is the only transport with an asynchronous isUsable). If I remove the test socket altogether and only leave Faye.ENV.setTimeout(notconnected, this.WEBSOCKET_TIMEOUT) then both Chrome and Safari (where WebSockets are supported) will fallback to JSONP instead of CORS.

The Unexpected response code:200 error is no problem. Even though we can see it in the debug console the socket.onerror event is fired as expected and execution continues.

Collaborator

jcoglan commented Jun 19, 2011

You mean these lines? https://github.com/jcoglan/faye/blob/master/javascript/transport/web_socket.js#L83-85

I don't quite follow what you're saying. Is the problem that this function can be called twice, once on error and again after a timeout?

Contributor

Thibaut commented Jun 19, 2011

Yes

Collaborator

jcoglan commented Jun 19, 2011

Okay, I've stopped this function being re-callable: https://github.com/jcoglan/faye/commit/62a004380a21935347604d8cac56604d5495aabd

Contributor

Thibaut commented Jun 19, 2011

I tried this but it does not work (I'll check again).
The problem is not with it being called twice but being called after a delay.

EDIT: I confirm it doesn't work.

bk-one commented Jul 12, 2011

I have the same issue, and once it got the "unexpexted repsonse code: 200" message, i don't receive any updates anymore (running faye 0.6.3)

Collaborator

jcoglan commented Jul 14, 2011

As detailed in the linked mailing list post, here's what I think is going on:

  • Faye calls Faye.Transport.WebSocket.isUsable(), which tries to open a socket to the server
  • The WebSocket connection fails, and Faye goes on to try other transports
  • The browser re-uses that TCP connection to perform regular old HTTP requests and get 200 responses
  • The WebSocket client does not expect such responses to come over the socket and complains
  • However, the onerror handler is not called in this case so the user cannot handle the error

I'm not sure if it's possible to do anything about this. Is it breaking your application, or just causing annoying errors? If it's breaking your app, I suggest disabling the transport entirely by doing this:

Faye.Transport.WebSocket.isUsable = function(_,c) { c(false) };
Collaborator

jcoglan commented Dec 10, 2013

I'm closing this issue since it related to very old code that is no longer in this repo, and it's not seen any activity in two years.

@jcoglan jcoglan closed this Dec 10, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment