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 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
https://www.workerman.net/doc/workerman/faq/secure-websocket-server.html#nginx%E9%85%8D%E7%BD%AE%E5%8F%82%E8%80%83
大佬的意思是不是这样的?不要直接连接workerman的7272端口,需要把7272端口在nginx上做个代理,然后页面中连接nginx 代理的端口
对