当我连接到服务器上的Socket.io时,我收到400错误,但我没有看到连接到localhost的任何错误。 (相同的代码并通过socket.io-objc连接)
我正在使用Azure来托管node.js项目。 (如果有所不同,我也在azure配置中打开了websockets)
ERROR: handshake failed ... The request timed out.
onError() Error Domain=SocketIOError Code=-6 "The operation couldn’t be completed.
(SocketIOError error -6.)" UserInfo=0x1874cc00 {NSUnderlyingError=0x1870cad0 "The request timed out."}
服务器代码(在Azure上)
var fs = require('fs');
var app = require('express')(),
server = require('http').createServer(app),
redis = require("redis"),
Primus = require('primus'),
kue = require("kue");
var haversine = require('haversine')
var finish = require("finish");
var client = redis.createClient(12276, "redis url");
client.auth('password');
var io = require('socket.io').listen(server);
io.sockets.on('connection', function (socket) {
socket.emit('join', { status: 'connected' });
});
var port = process.env.port || 1337;
server.listen(port);
SOCKET.IO-OBJC CODE
- (void) reconnect
{
[socketIO disconnectForced];
socketIO = [[SocketIO alloc] initWithDelegate:self];
socketIO.useSecure = NO;
[socketIO connectToHost:@"siteurl" onPort:80];
}