我的系统的Socket.IO配置有问题。服务器在Heroku上,使用Redis。配置是:
var rtg = require("url").parse(url);
var pub = redis.createClient(rtg.port, rtg.hostname);
var sub = redis.createClient(rtg.port, rtg.hostname, { return_buffers: true });
pub.auth(rtg.auth.split(":")[1]);
sub.auth(rtg.auth.split(":")[1]);
var redisOptions = {
pubClient: pub,
subClient: sub,
host: rtg.hostname,
port: rtg.port
};
io.adapter(ioredis(redisOptions));
但我从IOS客户端获取以下日志:
2016-04-08 11:45:52.371 xxx[2952:841559] LOG SocketEngine: Starting engine
2016-04-08 11:45:52.371 xxx[2952:841559] LOG SocketEngine: Handshaking
2016-04-08 11:45:52.372 xxx[2952:841559] LOG SocketEnginePolling: Doing polling request
2016-04-08 11:45:53.215 xxx[2952:842326] LOG SocketEnginePolling: Got polling response
2016-04-08 11:45:53.227 xxx[2952:842204] LOG SocketEngine: Got message: <!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style type="text/css">
html, body, iframe { margin: 0; padding: 0; height: 100%; }
iframe { display: block; width: 100%; border: none; }
</style>
<title>Application Error</title>
</head>
<body>
<iframe src="//s3.amazonaws.com/heroku_pages/error.html">
<p>Application Error</p>
</iframe>
</body>
</html>
有时,Chrome会将响应记录在下方:
{"code":1,"message":"Session ID unknown"}
该配置有什么问题?