Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/263.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 让WebSocket在Raspberry Pi上与Nginx和Asp.Net核心协同工作_Javascript_C#_Nginx_Asp.net Core_Websocket - Fatal编程技术网

Javascript 让WebSocket在Raspberry Pi上与Nginx和Asp.Net核心协同工作

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

我试图让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.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/;
}