接收器握手前关闭套接字IO SSL连接

时间:2016-04-17 14:51:36

标签: node.js ssl socket.io

我构建了一个Socket IO网络聊天,并希望使用SSL证书使其安全。聊天工作正常,但现在我收到连接失败的消息: 'ws://localhost:2250/socket.io/?id_user=56&id_dep=58%2C74%2C58%2C58%2C111&EIO=3&transport=websocket' failed: Connection closed before receiving a handshake response

服务器接缝工作正常,但是,它看起来像客户端问题。 这是代码。 服务器:

var https = require('https');
var md5 = require('MD5');
var _ = require('underscore');
var cron = require('cron');
var db = require('../database.js');
var $ = require('jquery');
var fs = require('fs');

var options = {
key:    fs.readFileSync('../ssl/ssl.key/app.key'),
cert:   fs.readFileSync('../ssl/ssl.crt/app.crt'),
ca:     fs.readFileSync('../ssl/ssl.crt/app.ca-bundle')
};
httpServer = https.createServer(options, function(req, res) { 

});
httpServer.listen("2250"); //écoute du serveur sur le port 2901
db.init();
var ionotif = require('socket.io-client');
var io = require('socket.io')(httpServer,  {secure : true, 'transports': ['websocket', 'polling']});

客户端:

$(document).ready(function() {
var socket = io.connect('wss://localhost:2250', {'transports': ['websocket', 'polling'], query : {id_user : id, id_dep : id_dep}});

谢谢你,祝你有个美好的一天!

0 个答案:

没有答案