Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Intermittent error code 400, description "" on client connecting to channel

My Google App Engine app, which uses the Channel API works well some of the time. Intermittently, though, the js code connecting to the channel generates an error. In socket.onError, the error code is set to 400 and the description is set to an empty string. I have checked that the token being used to connect is valid. I also tried recreating the channel in socket.onError, by first calling socket.close() but that does not seem to work. Often there is a series of failures before a success. The client js is running on Safari on iOS. Any ideas on how to fix or work around the problem will be welcome. Right now, my best workaround is to keep trying till I succeed, increasing the interval between attempts on each failure. The server side presence API does not help, since the 'connected' hook is not called reliably.

like image 436
er0 Avatar asked Dec 19 '12 23:12

er0


People also ask

What is the reason for 400 Bad Request?

The HyperText Transfer Protocol (HTTP) 400 Bad Request response status code indicates that the server cannot or will not process the request due to something that is perceived to be a client error (for example, malformed request syntax, invalid request message framing, or deceptive request routing).

What is server 400?

YouTube error 400 usually indicates your connection is unstable or you're using incorrect date and time settings.

What is 400 error in angular?

Check for File Size As we've mentioned earlier, another cause for a 400 error is file size. If you're trying to upload a file that's too large that it exceeds the server file limit, you'll get a 400 error. To confirm that this is causing the issue, try to upload a file that's smaller in size.


3 Answers

It is known issue http://code.google.com/p/googleappengine/issues/detail?id=4940 and it was accepted. As you see the status of issue is not fixed. Feel free to star it.

like image 162
Kirill Lebedev Avatar answered Nov 15 '22 03:11

Kirill Lebedev


I know double posting is bad (issue starred & comment posted)... but I suspect this thread might get more attention than the issue comments ^^

As far as we are concerned, it's at the very least a documentation issue:

https://developers.google.com/appengine/docs/java/channel/javascript still states " An onerror call is always followed by an onclose call and the channel object will have to be recreated after this event"

It is only true for, as far as we have guessed, error codes 400 and 401 (which are strings, not numbers, btw, so beware of === in the js code).

It is untrue for other error codes (we have logged at least the -1 code).

There should be a documentation covering all error codes and their (expected) management.

Atm, we have a "channel manager" that reuses the same channel token when code is not 400 or 401, and that makes sure onclose is called once and once only per Socket.

Before that, we were trying to close properly, and reopen (new underlying Socket) with a shiny brand new token: usually we got an error 400 followed by an error -1.

FUI we first detected this behavior on iOS, quite recently (regression ftw? Before that iOS was dandy). Reopening the socket after a code -1 is not a panacea: sometimes it will succeed (onopen properly called), and then fail silently (no message received, no onerror called).

Generally, we also noticed more consistent behavior on desktop browsers than mobile ones, across all user agents and platforms (more on that: yay! Other issues incoming! Especially android...)

OK, this post might have been useful after all. Thx!

[EDIT: corrected a mistake... we don't reuse the channel object nor the socket object, only the token]

like image 38
Lionel D Avatar answered Nov 15 '22 03:11

Lionel D


I contacted Google support about this issue.

When a error 400 happens it's because a timeout (one minute it seems) happened. This timeout generates a disconnection (url disconnected is called and you should remove the client id of the database). Then, a new channel must be created with a new client id.

But it is not enough. We have to use this jquery command line : $('#wcs-iframe').remove();
Just inside the js onerror function and before to try to recreate the channel.

like image 31
Sébastien Beaujard Avatar answered Nov 15 '22 04:11

Sébastien Beaujard