woekerman启动成功, https域名页面下ws连接不成功

hello21st

问题描述

https域名页面下ws连接不成功,访问https://sns.com:8081/site/room?id=8 出现错误:room?id=8:69 WebSocket connection to 'wss://10.12.28.187:7272/' failed:

程序代码

<script type="text/javascript" charset="utf-8">
var ws;
function init() {
    ws = new WebSocket("ws://10.12.28.187:7272");
    ws.onopen = function() {
        console.log("连接成功");
        var login_data = '{"type":"login","accid":"300"}';
        ws.send(login_data);
        console.log("正在登录:"+login_data);
    };
    ws.onmessage = function(e) {
        var data = JSON.parse(e.data);
        switch(data['type']){
            case 'say':
                console.log("聊天信息:"+e.data);
                break;
            case "notify2":
                console.log("错误:"+e.data);
                break;
        }
    }
    ws.onclose = function() {
         console.log('Disconnected chat server');
    };
}
window.onload=init;
</script>

报错信息

WebSocket connection to 'wss://10.12.28.187:7272/' failed: 
init    @   room?id=8:69

截图报错信息里报错文件相关代码

操作系统及workerman/webman等框架组件具体版本

这里写具体的系统环境相关信息

Workerman version:3.5.15 PHP version:7.4.33
start time:2024-03-14 18:20:14 run 35 days 21 hours
load average: 0.37, 0, 0 event-loop:\Workerman\Events\Event
5 workers 27 processes
worker_name exit_status exit_count
ChatBusinessWorker 0 0
ChatLogicWorker 0 0
ChatGateway 0 0
Register 0 0
ChatSrvGateway 0 0

659 1 1
1个回答

walkor 打赏
  • hello21st 2024-04-19

    大佬的意思是不是这样的?不要直接连接workerman的7272端口,需要把7272端口在nginx上做个代理,然后页面中连接nginx 代理的端口

  • walkor 2024-04-19

×
🔝