Felix's RPi Gateway installation - progress! but stuck at chat.html

Started by labusr, March 15, 2014, 12:54:02 AM

labusr

Hi,
I'm at the point of testing out the chat example.  I get the username and password prompt for the authentication.  Then the chat example takes over and asks me for my name, I enter it, and this is the output I see on the terminal when I use Chrome:

pi@raspberrypi ~/moteino $    info  - socket.io started
   debug - served static content /socket.io.js
AUTHORIZING CONNECTION FROM 127.0.0.1:43407
   debug - authorized
   info  - handshake authorized nub6NCJl9Dr9c9KaeHbC
   debug - setting request GET /socket.io/1/xhr-polling/nub6NCJl9Dr9c9KaeHbC?t=1395033422271
   debug - setting poll timeout
   debug - client authorized for
   debug - clearing poll timeout
   debug - xhr-polling writing 1::
   debug - set close timeout for client nub6NCJl9Dr9c9KaeHbC
   debug - xhr-polling received data packet 5:::{"name":"adduser","args":["Joe"]}
   debug - broadcasting packet
   debug - setting request GET /socket.io/1/xhr-polling/nub6NCJl9Dr9c9KaeHbC?t=1395033432310
   debug - setting poll timeout
   debug - clearing poll timeout
   debug - xhr-polling writing �64�5:::{"name":"updatechat","args":["SERVER","you have connected"]}�49�5:::{"name":"updateusers","args":[{"Joe":"Joe"}]}
   debug - set close timeout for client nub6NCJl9Dr9c9KaeHbC
   debug - discarding transport
   debug - cleared close timeout for client nub6NCJl9Dr9c9KaeHbC


It knows my name is "Joe".  But it never displays "Joe" on the browser.  I try typing into the text box, but nothing happens.  If I let it sit for a minute, it asks me my name again.  My output starts to differ from Felix's example where it saids

Quotedebug - setting request GET /socket.io/1/xhr-polling/nub6NCJl9Dr9c9KaeHbC?t=1395033422271

Felix's example saids:
Quotedebug - setting request GET /socket.io/1/websocket/xxxxxxxxx

But this is all new to me, and I don't know how to read into that.  Anyone have any ideas?

Thanks!

Edit:  when I use firefox, don't get the name prompt.  I just get the chat window with no activity when I type into it and "debug - served static content /socket.io.js"

labusr

After some googling around, others experienced the same issue with "setting request GET /socket.io/1/xhr-polling/".  But I don't understand the forum solutions well enough to figure out the next step:

Here's two who ran into the same issue:
http://stackoverflow.com/questions/10932895/not-emitting-receiving-events-with-socket-io-and-node-js

https://groups.google.com/forum/#!topic/socket_io/BTjVJRrJSEQ

Maybe someone with more knowledge can help me?

Quote
If your projectname is stock, then that's your problem. Socket.IO is thinking you're using a namespace. You can see this in the xhr-polling received data packet log line. console.log is never called since you're not listening on that namespace on the server side.

You should get rid of /projectname/server from your client connect address and reference the client side library properly so you don't get a 404. Whether that's an Apache proxy issue or fixing the script src in your header depends on your current setup. I can't tell from the code you've provided.

PS: Socket.io should serve the client library at http://127.0.0.1:8080/socket.io/socket.io.js, but you might run into a cross-domain origin policy issue by referencing that asset from a document served by your apache server at port 80. Quick fix could be to serve the client lib from your apache server, which is in the socket.io-client module dist folder.

Quote
http://stackoverflow.com/questions/17730369/connection-failed-from-client-to-server-in-socket-io
In gateway.js, do this:
var io = require('socket.io').listen(8080);
io.set('transports', ['websocket', 'xhr-polling']);

Felix