我当前的应用程序使用Akamai(SSL)HAProxy(SSL)NodeJS(socket.io) .
index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Socket IO Testing</title>
</head>
<body>
<div>
<h3>Request</h3>
<span id="socketId"></span>
</div>
<div>
<h3>Response</h3>
<span id="responseText"></span>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/2.0.4/socket.io.js"></script>
<script>
var socket = io.connect("https://host_name_here");
socket.on('ConnectionEstablished', function(data) {
document.getElementById("socketId").innerText = JSON.stringify({socketId:socket.id,text:"Socket Connected successfully"});
document.getElementById("responseText").innerText = "";
console.log("Connection established successfully");
});
socket.io.on("connect_error",function (err) {
console.log("Connection Error : " + err);
});
</script>
</body>
</html>
app.js
const express = require("express");
const app = express();
const socket-io = require('socket.io');
app.use(express.static("index.html");
const server = app.listen(8000,function () {
log.info(`express server run on port 8000`);
});
const io = socket-io.listen(server);
io.on("connection",function(){
console.log("socket connection established ");
});
当请求直接来自HAProxy,然后传递给后端服务器(nodejs socket.io)时,应用程序可以通过wss创建websocket连接 .
问题出现在Akamai然后转发到HAProxy然后转发到后端服务器(nodejs socket.io)应用程序抛出SSL终止错误 .
确切的错误消息 - WebSocket connection to 'wss://{}/socket.io/?EIO=3&transport=websocket&sid=4rBehZxSnWwPsbiXAACV' failed: Error during WebSocket handshake: Unexpected response code: 400
无法确定Akamai发出请求时出了什么问题 .
感谢任何帮助或领导 .
谢谢 .
1 回答
Akamai上没有关于Websockets的官方文档 . 我不认为akamai现在支持websocket . 在akamai的其中一个上找到了这个forum thread
Akamai没有回复最后一条评论 . (Aug'17) .
我不认为这与SSL终止有关 . 即使在http上,我也无法 Build 套接字连接(ws而不是wss)