鍍金池/ 問(wèn)答/Java  PHP  網(wǎng)絡(luò)安全  HTML/ 在阿里云服務(wù)器上使用socket.io無(wú)法連接

在阿里云服務(wù)器上使用socket.io無(wú)法連接

原本在本地部署的項(xiàng)目使用socket都沒(méi)有問(wèn)題
放到阿里云上socket始終鏈接不上

前端

// 客戶指派提醒消息
var socket = io('服務(wù)器外網(wǎng)ip:6001');
socket.on("members:assign.notification", function (data) {
    // toastr.info(data.content, data.title, {
    //     "timeOut": 14400000,
    //     "extendedTimeOut": 14400000
    // });
    console.log(data);
});

socket.io

var app = require('http').createServer(handler);
var io = require('socket.io')(app);

var Redis = require('ioredis');
var redis = new Redis(6379, '127.0.0.1');

app.listen(6001, function () {
    console.log('Socket server is running at port 6001!');
});

function handler(req, res) {
    res.writeHead(200);
    res.end('');
}

io.on('connection', function (socket) {
    socket.on('message', function (message) {
        console.log(message)
    });
    socket.on('disconnect', function () {
        console.log('user disconnect')
    });
});

客戶端請(qǐng)求

報(bào)錯(cuò) 
GET https://服務(wù)器外網(wǎng)ip:6001/socket.io/?EIO=3&transport=polling&t=M0q8ZAs net::ERR_CONNECTION_CLOSED     
polling-xhr.js:264

網(wǎng)絡(luò)請(qǐng)求用的https

我在想這是會(huì)不會(huì)是https有所影響 

第一次在阿里云上使用socket服務(wù) 遇到問(wèn)題實(shí)在無(wú)法解決,懇求各位大佬給出寶貴的建議!謝謝

回答
編輯回答
糖果果

你服務(wù)器端用的是 http,客戶端請(qǐng)求用 https 當(dāng)然有問(wèn)題。

2017年2月23日 15:00
編輯回答
女流氓

安全組策略端口開(kāi)了么~

2018年3月3日 14:25