New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unexpected token u #143
Comments
Is this a duplicate of #135? |
I am serving the application directly without using nginx as the proxy. |
In that case I'm going to need some example code to demonstrate this. Can you put an example on GitHub? |
It seems to happen randomly, I will try to reproduce it and give you the example code. Thanks for the quick replies. |
If you can find out what the input to |
After observing the servers for a while (After adding some tracking code - line 2211 of faye-node.js) console.log("Faye _callWithParams");
console.log(params);
var message = JSON.parse(params.message), The error will be occurred when the params is {} Faye _callWithParams
{}
2012-05-09 19:25:53 [ERROR] [Faye.NodeAdapter] Unexpected token u
Backtrace:
SyntaxError: Unexpected token u
at Object.parse (native)
at Object._callWithParams (/opt/3_1/node_modules/faye/node/faye-node.js:2213:26)
at Object.handle (/opt/3_1/node_modules/faye/node/faye-node.js:2153:19)
at HTTPServer.<anonymous> (/opt/3_1/node_modules/faye/node/faye-node.js:2125:52)
at HTTPServer.emit (events.js:70:17)
at HTTPParser.onIncoming (http.js:1572:12)
at HTTPParser.parserOnHeadersComplete [as onHeadersComplete] (http.js:91:29)
at Socket.ondata (http.js:1468:22)
at TCP.onread (net.js:374:27) I wonder why Faye receive a request with no params at all? Maybe It is about expressjs sending wrong messages? P/S: updated, these are the requests that cause the error headers:
{ 'user-agent': 'Opera/9.80 (Windows NT 6.0; U; en) Presto/2.7.62 Version/11.01',
host: 'mydomain.com',
accept: 'text/html, application/xml;q=0.9, application/xhtml+xml, image/png, image/jpeg, image/gif, image/x-xbitmap, */*;q=0.1',
'accept-language': 'en,en-US;q=0.9',
'accept-charset': 'iso-8859-1, utf-8, utf-16, *;q=0.1',
'accept-encoding': 'deflate, gzip, x-gzip, identity, *;q=0',
referer: 'http://mydomain.com/chatbox/bc28658ccd3461f761d3bfb3db5d1c23',
cookie: '__utma=59786367.1441917673.1336595873.1336595873.1336595873.1; __utmb=59786367.1.10.1336595873; __utmc=59786367; __utmz=59786367.1336595873.1.1.utmcsr=misaha.blogspot.com|utmccn=(referral)|utmcmd=referral|utmcct=/2012/04/cabin-in-woods_30.html',
cookie2: '$Version=1',
'cache-control': 'no-cache',
connection: 'Keep-Alive, TE',
te: 'deflate, gzip, chunked, identity, trailers' } AND headers:
{ host: 'mydomain.com',
'user-agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:11.0) Gecko/20100101 Firefox/11.0',
accept: 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
'accept-language': 'pt-br,pt;q=0.8,en-us;q=0.5,en;q=0.3',
'accept-encoding': 'gzip, deflate',
'sec-websocket-version': '13',
origin: 'http://mydomain.com',
'sec-websocket-key': 'pbUkxnI4ZQvbl1qH5QZfbQ==',
cookie: 'connect.sid=9iftuCl2K0OJjezcEOMFJV4I.l%2Bs1x7CqGpJVb5PuDGOmRrIeG4E6vl3GryStmi%2BIsC4; __utma=59786367.844784998.1336595412.1336595412.1336595412.1; __utmb=59786367.1.10.1336595412; __utmc=59786367; __utmz=59786367.1336595412.1.1.utmcsr=elektromusic.net|utmccn=(referral)|utmcmd=referral|utmcct=/central.php',
pragma: 'no-cache',
'cache-control': 'no-cache, max-age=2592000',
connection: 'keep-alive' }, I am not sure if it will help or not. |
This explains the parsing error, since
I'm now wondering if this is related to #139 or expressjs/express#1097. Obviously, if Faye receives a request with no parameters it should treat the request as invalid, but I'm not sure why the request is empty. As for the requests you posted, the first is either a GET or POST and entering this section of code: Check out the values of The second request is an invalid WebSocket request (it has Verify that Faye works if you run it separately from Express, and check the values I mentioned. We might be able to do something about the broken WebSocket but it might be worth checking that Express does not garble it. e.g. have you tried making a plain http://github.com/faye/faye-websocket-node server embedded in an Express app? |
I am facing the same issue when i deployed it on heroku works fine locally on my mac |
@hackable Could you gather the information I asked for in the previous comment? Would be really helpful for diagnosis. Also, are you using the Node version, and with or without Express? |
Node 0.6.17 i tried with express and without it on heroku both times it shows [ERROR] [Faye.NodeAdapter] Unexpected token u http = require('http')
fs = require('fs')
path = require("path")
#All set, start listening!
port = process.env.PORT or 3000
server = http.createServer((request, response) ->
console.log "request starting..."
filePath = "public" + request.url
filePath = "public/index.html" if filePath is "public/"
extname = path.extname(filePath)
contentType = "text/html"
switch extname
when ".js"
contentType = "text/javascript"
when ".css"
contentType = "text/css"
path.exists filePath, (exists) ->
if exists
fs.readFile filePath, (error, content) ->
if error
response.writeHead 500
response.end()
else
response.writeHead 200,
"Content-Type": contentType
response.end content, "utf-8"
else
response.writeHead 404
response.end()
)
bayeux.attach(server)
server.listen(port) |
Found time to put up a Heroku app myself and investigate. The problem is that Heroku does not support WebSocket, but they modify the incoming WebSocket request by removing the This does not seem to stop Faye clients from working, but it does result in log noise. I will see about making changes so that Faye's error messaging is more informative, but for now you should do this on the client side to stop it trying to use WebSocket:
|
I can confirm even after putting client.disable('websocket') the errors still show. |
Are you calling it immediately after creating the client with If not, I'm going to need more debugging info from you -- the HTTP method, request path and headers for requests triggering the bug. |
Seems, we become a bit more close to understanding, what happens: fontello/fontello#60 . As you can see - IE9 works with no problems, but all other browsers, wich support ws, fail to connect and fail to fallback. It's 99.9% combination of 2 bugs:
(2) is a real fuckup in our case, since we use faye for all client-server communications (no ajax at all). |
There's a bunch of ways a proxy can mess sockets up. I really need to take a look at the request you're seeing (method, URL, headers) before making a decision on how to handle it. What I do know is that the Faye client should detect that WebSocket is not usable -- the server will not be establishing the connection properly -- and it ought to be able to detect this and use something else. Does this bug result in broken clients, or just log noise from the initial connection attempt? |
Yes, all his browsers, that started connection with websocket protocol, become broken. Those could not do automatic fallback to polling and others. May be, that's caused by another bug. Don't know exactly. Here is a live log of all "ivalid token u" exceptions: http://fontello.com/fuckup.log . Fontello uses faye to broadcast "online" users & send click at 1 button to server. Very simple - almost no place to make errors. Now wait a bit, until person, that managed to reproduce bug, will be back at work and can do some simple tests fontello/fontello#60 (comment) If you need something more - feel free to ask anytime. |
@jcoglan I have added
You can see the patch we use to produce these logs here: https://gist.github.com/2829288 |
Am reading the
You can tell from the client ID in the URL that this is an EventSource request. However, EventSource requests are supposed to contain
This is a GET request with no query string, and nothing to indicate it's a WebSocket or EventSource connection. It's simply invalid; there is nothing useful the Faye server can do with this. It actually seems unlikely that the request was made by a Faye client at all, or if it was then it's been messed up by a proxy and there's not a lot we can do with it.
This is a WebSocket request (notice
This is a POST containing JSON that should have
This could potentially be fixed by trying to parse the body as a query string, then if that fails treat the body as literal JSON. This feels messy though, and likely to have other unwanted side effects. The failure of this request could also explain the inability to fall back after broken WebSockets, since it means that long-polling will not work either. On the whole it seems that either your hosting stack, or proxies being used by your users, are breaking almost all the transports used by Faye. The only one that will probably work is One final piece of research I'd like you to do is to check whether we can detect failed WebSocket and EventSource connections. Take a look at https://github.com/faye/faye/blob/master/javascript/transport/web_socket.js and https://github.com/faye/faye/blob/master/javascript/transport/event_source.js, and look for the creation of socket objects. Add
|
What's the status of this issue? I've not heard any updates in a month. |
At our side status with websocket->polling fallback did not changed. Just started to work with backlog tasks yesterdy. James, i offer to close this one now, as partially solved (about bad/unclear logs). When we get more info about clientside - me or ixti will create new ticket with better description. |
I'm closing this per @puzrin's last comment. Please open a new issue if/when you have more concrete information. |
I am having many of this errors on my log.
I am using nodejs 0.6.17, expressjs 2.5.9 (with cluster) and faye 0.8.2 with redis 2.4.8
I am not sure what is it and how to fix it?
The text was updated successfully, but these errors were encountered: