I am trying to connect from a js file to a web socket on asp.

this.socket = new WebSocket(Мой внешний ip:8080/XHandler.ashx); 

On a local network with a local IP, everything works fine, but if I bring up a site on IIS, and try to connect from outside on an external IP, I get js error:

 WebSocket connection to 'ws://Мой внешний ip:8080/XHandler.ashx' failed: Error in connection establishment: net::ERR_CONNECTION_TIMED_OUT 

I can go to the page on the external ip, the controller works correctly. Ports are open and forwarded. Most interestingly, if I run IIS in debugging mode through Visual Studio, Everything starts to work in a strange way. I'm out of options, tell me where to dig.

 public class XHandler : IHttpHandler { private WebSocket socket; public bool IsReusable { get { return false; } } public void ProcessRequest(HttpContext context) { if (context.IsWebSocketRequest) { context.AcceptWebSocketRequest(WebSocketRequest); } } private async Task WebSocketRequest(AspNetWebSocketContext context) { //..... } } 
  • I will clarify: I can enter the site from the Internet. The controller executes and returns the page. On this page JS with WebSocket connection. I try to connect to the same address and port, only in another "Controller" - HttpHandler. Routes are registered, ports are thrown. On a local network with local addresses, everything works, but not via the Internet. - Pavel Rembrant pm

0