Skip to content
This repository has been archived by the owner on Dec 18, 2018. It is now read-only.

Error during WebSocket handshake: Incorrect 'Sec-WebSocket-Accept' header value #1585

Closed
tranphuongyd opened this issue Mar 13, 2018 · 9 comments

Comments

@tranphuongyd
Copy link

I'm using the SignalR in .Net Core project (Microsoft.AspNetCore.SignalR -Version 1.0.0-alpha2-final).
It's work very well from 1 week ago. BUT today it's get the error: WebSocket connection to 'mydomain' failed: Error during WebSocket handshake: Incorrect 'Sec-WebSocket-Accept' header value.
image

The browser is Chrome version 65.0.3325.146
With Fire Fox get another error like:
Firefox can’t establish a connection to the server at ws:MyDomain

Can someone help me resolve it.
Thanks!

@analogrelay
Copy link
Contributor

Could you use the Network tab of your browser dev tools to capture the network traffic going on so we can take a look at what's happening? In Chrome, you can just right click anywhere in the Network tab's list of requests and choose 'Save as HAR with Content' and then upload that file and link it here (please don't paste it inline, it's very large, you can use a gist to host the content if you need to).

@tranphuongyd
Copy link
Author

Hi @anurse ,
Just resolved it by install Websockets on IIS. Go to the Server Manager > Manage > Add Roles and Features > Web Server > Application Development > Websockets.

Many thanks!

@analogrelay
Copy link
Contributor

Ah, yes, I forgot to ask if you were running behind IIS, which does require installing the WebSockets feature. Glad it's resolved! Closing this issue now.

@Polyterative
Copy link

@tranphuongyd Fixed the problem, many thanks.
To anyone here having issues with Angular 6's change detection, SignalR's fallback might be the issue.
Fixed my problems (messed up change detection/angular material events/rxjs not working without additional action) after activating web sockets

@jjxtra
Copy link

jjxtra commented Sep 19, 2018

IIS appears to be changing the Sec-WebSocket-Key header value for some strange reason. Have confirmed this by logging the header to file. The header logged in aspnet core is not the same one as the client sends. Any ideas?

@analogrelay
Copy link
Contributor

analogrelay commented Sep 19, 2018

This is expected. Are you seeing an issue? When you are using ANCM, there are two separate WebSocket connections at play:

Browser <---> IIS <---> ASP.NET Core App

IIS is forwarding frames back and forth but these are separate WebSocket connections so the Sec-WebSocket-Key header will not be the same for these two connections.

@jjxtra
Copy link

jjxtra commented Sep 19, 2018

@anurse Unfortunately it looks like there is something fishy going on. I logged an issue: dotnet/aspnetcore#3539

@analogrelay
Copy link
Contributor

Ok, it looks like this is an IIS issue. Looks like that issue has found it's way to the right place.

@gatapia
Copy link

gatapia commented Dec 13, 2018

I'm getting this error now. Angular 7 + .Net Core 2.1 + Microsoft.AspNetCore.SignalR 1.04.

This error does not happen when using the dotnet run server but when deploying to IIS (Windows 10 and Windows Server 2008 R2).

I'm assuming that its because win 10 IIS and Win Srv 2008 IIS (7.5) do not have WebSockets. But isnt SignalR supposed to be smart enough to detect this and fallback?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants