9

I have implemented HTML5 Websocket in my MVC5 Application. I have implemented this web socket using web API. This code is working fine in my local environment. But it is giving me below error in my test environment.

"WebSocket connection to '' failed: HTTP Authentication failed; no valid credentials available."

My server Configuration is Windows server 2012 with IIS8

Please Help me out.

Virang Patel
  • 91
  • 1
  • 1
  • 3

3 Answers3

1

We have a few customers who had this issue only on servers which were windows 2012. It seems related to websockets being present and on. Enabling Cross Domain fixed it for us on those servers.

  // Turn cross domain on 
    var config = new HubConfiguration { EnableCrossDomain = true };

    // This will map out to http://localhost:50001/signalr by default
    app.MapHubs(config);
Tim
  • 7,401
  • 13
  • 61
  • 102
  • The mechanism to enable cross domain in SignalR has changed. Here is the updated information: https://learn.microsoft.com/en-us/aspnet/signalr/overview/guide-to-the-api/hubs-api-guide-javascript-client#crossdomain – codeMonkey Mar 28 '18 at 17:21
0

My reason is that filter intercepts in server

@Override
public void doFilter(ServletRequest request, ServletResponse response,
                     FilterChain chain) throws IOException, ServletException {
    HttpServletRequest req = (HttpServletRequest) request;
    HttpServletResponse rep = (HttpServletResponse) response;
    handleRequest(req);

    // swagger 不过滤
    String ur = req.getRequestURI();
    if (req.getRequestURI().contains("swagger")
            || req.getRequestURI().contains("swagger")
            || req.getRequestURI().contains("v2/api-docs")
            || req.getRequestURI().contains("websocket")
            || req.getRequestURI().startsWith("/images/favicon-")
            || req.getRequestURI().startsWith("/configuration/")
            || req.getRequestURI().startsWith("/v2/editapi/") ) {

        chain.doFilter(request, response);
    }
Nocturne
  • 1
  • 1
0

I don't know if it can help you, but worth try!

There is and old issue here at SO that explain about authentication with Web Socket (JS generic websocket).

Please, check this issue: HTTP headers in Websockets client API

All Pereira
  • 139
  • 1
  • 2
  • 13