0

I have a Node.js server running Websocket. (using Pomelo). I am able to run a web application and connect to it (localhost @port 3104).

however, when I try to use socket.io (SocketRocket) for IOS and connect to the same localhost and port, I get this error:

> http://127.0.0.1:3014/socket.io/1/?t=16807 
> "ERROR: handshake failed ... The request timed out"

detail of the error:

Error Domain=NSURLErrorDomain Code=-1001 "The request timed out." UserInfo=0x6c723c0 
{NSErrorFailingURLStringKey=http://127.0.0.1:3014/socket.io/1/?t=16807, NSErrorFailingURLKey=http://127.0.0.1:3014/socket.io/1/?t=16807, NSLocalizedDescription=The request timed out., NSUnderlyingError=0x6c72400 "The request timed out."}

i tried. 127.0.01, localhost... even explicit IP address.. all fail

any idea what I should check? and should it be "http" protocol ? or wss?

murvinlai
  • 48,919
  • 52
  • 129
  • 177
  • possible duplicate of [How to use SocketRocket with socket.io?](http://stackoverflow.com/questions/9302561/how-to-use-socketrocket-with-socket-io) – Josh C. Feb 26 '14 at 20:40

1 Answers1

0

Got it working.. I just cannot run a websocket server. I have to run a socket.io server... then it works.

murvinlai
  • 48,919
  • 52
  • 129
  • 177
  • Hello, can you pls help me in js file. I am getting ERROR: handshake failed ... The request timed out" ervery time. while in browser it wroks file. – Pratik Patel Apr 20 '16 at 08:47
  • var express = require('express'); var app = express(); var server = app.listen(3000); var io = require('socket.io').listen(server); server.listen(3000, function () { console.log('listening on *:3000');}); var users = {}; app.get('/', function(req, res){ res.sendfile('index.html'); }); io.sockets.on('connection', function(socket){ socket.on("register", function(username) { users[username] = socket.id; }); socket.on('chat message', function(msg){ io.sockets.emit('new message',msg); }); }); – Pratik Patel Apr 20 '16 at 08:49