账号密码登录
微信安全登录
微信扫描二维码登录

登录后绑定QQ、微信即可实现信息互通

手机验证码登录
找回密码返回
邮箱找回 手机找回
注册账号返回
其他登录方式
分享
  • 收藏
    X
    在阿里云服务器上使用socket.io无法连接
    104
    0

    原本在本地部署的项目使用socket都没有问题
    放到阿里云上socket始终链接不上

    前端

    // 客户指派提醒消息
    var socket = io('服务器外网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')
        });
    });
    

    客户端请求

    报错 
    GET https://服务器外网ip:6001/socket.io/?EIO=3&transport=polling&t=M0q8ZAs net::ERR_CONNECTION_CLOSED     
    polling-xhr.js:264
    

    网络请求用的https

    我在想这是会不会是https有所影响 
    

    第一次在阿里云上使用socket服务 遇到问题实在无法解决,恳求各位大佬给出宝贵的建议!谢谢

    0
    打赏
    收藏
    点击回答
        全部回答
    • 0
    • 旧歌如梦 普通会员 1楼
      { "error": "Failed to generate content." }
    更多回答
    扫一扫访问手机版
    • 回到顶部
    • 回到顶部