带有SSL的socket.io每分钟都会断开连接

时间:2015-07-09 18:15:43

标签: node.js ssl socket.io connection

我不知道我能做什么。这是我的问题:

自连接通过SSL以来,客户端每分钟都会断开连接并连接。

package;

import flixel.addons.nape.FlxNapeSprite;
import flixel.addons.nape.FlxNapeState;

class PlayState extends FlxNapeState
{
    override public function create():Void
    {
        super.create();

        var _test = new FlxNapeSprite(16, 16);
        _test.makeGraphic(16, 16);
        _test.createRectangularBody();
        _test.body.velocity.x = 100;
        add(_test);
    }
}

这种情况总是发生(非活动和活动),也就是在使用连接时,所以客户端将请求发送到服务器,然后它断开连接,服务器无法将结果响应给客户端......

我的服务器:

[09 Jul 2015][20:00:25] connection EOrQcfqqnEygUYgzAAAA
[09 Jul 2015][20:01:40] disconnect EOrQcfqqnEygUYgzAAAA
[09 Jul 2015][20:01:42] connection GHbO2jV7itWPDqh2AAAB
[09 Jul 2015][20:02:32] disconnect GHbO2jV7itWPDqh2AAAB
[09 Jul 2015][20:02:33] connection FlixPZ5C4qqRBDJsAAAC
[09 Jul 2015][20:03:49] disconnect FlixPZ5C4qqRBDJsAAAC
[09 Jul 2015][20:03:50] connection G5nIaL4KAYYvJ-b9AAAD
[09 Jul 2015][20:05:30] disconnect G5nIaL4KAYYvJ-b9AAAD
...

客户:

var express = require('express');
var connect = require('connect');
var app = express();
var fs = require('fs');

var ssl_options = {
    key: fs.readFileSync('/etc/ssl/private/domain.com.key'),
    cert: fs.readFileSync('/etc/ssl/certs/domain.com.crt'),
    ca: fs.readFileSync('/etc/ssl/certs/companyssl.intermediate.crt')
};

var server = require('https').createServer(ssl_options, app);
var port = process.env.PORT || 443;

var io = require('socket.io')(server);

server.listen(port, function(err) {
    console.log('HTTPS-Server on port ' + port);
});

io.on('connection', function(socket){
    // [...]
});

有人有想法吗?

谢谢!

(socket.io版本:1.2.1)

0 个答案:

没有答案