如何在ASP.NET Core中指定WebSocket服务器端口?

时间:2017-07-18 14:39:54

标签: websocket asp.net-core

如何为ASP.NET Core网站指定WebSocket端口?它只使用默认端口,用于调试是59451.我想打开两个端口,但我无法弄清楚如何在ASP.NET Core中设置WebSocket端口。

ASP.NET Core

app.UseWebSockets(); 

app.Use(async (context, next) =>
{
    if (context.Request.Path == "/upload")
    {
        // context.WebSockets.

        if (context.WebSockets.IsWebSocketRequest)
        {
            // this uses default port 59451
            WebSocket webSocket = await context.WebSockets.AcceptWebSocketAsync();
        }
    }
}

javascript:

uploadWebSocket = new WebSocket("ws://localhost:59451/upload"); 

0 个答案:

没有答案