I am developing a simple application using the current latest versions of nodejs + socket.io on Windows. I have encountered a problem when the socket get created on the client side, but socket.emit results in the following output in the console (using Google Chrome):
GET http://0.0.34.184:8888/socket.io/1/?t=1321385855665&jsonp=0
Which is quite strange because I am testing on localhost:8888 so it should be at least 127.0.0.1 and not 0.0.34.184. The socket.io client on the page is requested from the server in the tag as follows:
<script type="text/javascript" src="socket.io/socket.io.js"></script>
Then I connect using the following code:
socket = io.connect('localhost:8888');
socket.on("my_event", receiveNetEvent);
console.log('LOG: sio init complete, socket=' + socket);
The log states that socket=[Object object] which is not null or undefined so everything should work.
The sending itseld is performed in the following function:
function sendRequest(request){
socket.emit('request', request);
}
The request object, passed to the function is formed and passed like this:
var initRequest = {};
initRequest.subject = 'weather';
initRequest.key = 'initial';
sendRequest(initRequest);
And it is a valid json object according, again, to console.log().
All this leaves me totally clueless about any possible reason of the happening.
Try adding http:// to the connect path. That solved this error for me.