Javascript 让WebSocket在Raspberry Pi上与Nginx和Asp.Net核心协同工作
我试图让web套接字在Asp.Net核心应用程序中工作,该应用程序托管在nginx inside Raspberry Pi下 我的默认文件设置是:Javascript 让WebSocket在Raspberry Pi上与Nginx和Asp.Net核心协同工作,javascript,c#,nginx,asp.net-core,websocket,Javascript,C#,Nginx,Asp.net Core,Websocket,我试图让web套接字在Asp.Net核心应用程序中工作,该应用程序托管在nginx inside Raspberry Pi下 我的默认文件设置是: location /the_socket/ { proxy_pass http://websocket:8090/; } 在课堂上,websocket(使用斑点)的打开方式如下: var server = new WebSocketServer("ws://0.0.0.0:8090/the_socket"); server.S
location /the_socket/ {
proxy_pass http://websocket:8090/;
}
在课堂上,websocket(使用斑点)的打开方式如下:
var server = new WebSocketServer("ws://0.0.0.0:8090/the_socket");
server.Start(
socket =>
{
socket.OnOpen = () =>
{
};
socket.OnClose = () =>
{
};
socket.OnMessage = message =>
{
};
});
这是我正在调用的JavaScript:
url = "ws://the_socket:8090";
$(document).ready(function () {
function Connect() {
try {
$("#lblConnectionStatus").html("Reconnecting...");
if (ws instanceof WebSocket) {
ws.close();
}
ws = new WebSocket(url);
ws.binaryType = "arraybuffer";
ws.onerror = function (e) {
$("#divInternalMessangingStatus").html("Internal Messaging Error: " + e.message);
};
ws.onclose = function () {
$("#divInternalMessangingStatus").html("Internal Messaging Closed:");
Connect();
};
ws.onopen = function () {
$("#divInternalMessangingStatus").html("Client connected");
};
ws.onmessage = function (e) {
$("#divInternalMessangingStatus").html(e.data);
};
} catch (err) {
$("#divInternalMessangingStatus").html(err);
}
}
Connect();
});
连接上的哪些错误被拒绝
铌
我试着改变:
location /the_socket/ {
proxy_pass http://websocket:8090/;
}
致:
location /the_socket/ {
proxy_pass http://0.0.0.0:8090/;
}