My Environment
- .NetCore SDk - 2.1.300
- Microsoft.AspNetCore.SignalR - 1.0.0
- IIS - Version 10.0.12393.0 in Window Server 2016
Sample Code for AspNetCore.SignalR
- I follow the instructions by link https://docs.microsoft.com/en-us/aspnet/core/signalr/get-started?view=aspnetcore-2.1&tabs=visual-studio to complete a sample AspNetCore.SignalR chat code.
- I can run it successfully in Visual Studio.
- After that, I publish it to my server (window server 2016, IIS has websocket feature), and it also works fine. That means, my server environment support AspNetCore.SignalR well.
Abp for AspNetCore.SignalR
- I download the ABP template code from ABP website
- Upgrade the .net core sdk to .net core 2.1
- Upgrade nuget packages
- Follow my above steps to add sample AspNetCore.SignalR chat code in the project.
- Run it successfully in visual studio
The issue is, when I publish it to the server (same as my above server), and run it, it throws a error - AspNetCore.SignalR.HubConnectionContext - Failed connection handshake.
I have research it, but didn't get any solution. could you please help to look at it what the issue is?
I have push my project into github: https://github.com/lcyhjx/AbpExample, you can pull and run it (Just run AbpExample.Web.Host). It works fine in Visual Studio, but failed in IIS.
The error detail:
- Information: Normalizing '/chatHub' to 'http://localhost:6011/chatHub'.
- Information: WebSocket connected to ws://localhost:6011/chatHub?id=2zix_nPHODwLEv2p_4VCAw'
- Error: Connection disconnected with error 'Error: Server returned handshake error: An unexpected error occurred during connection handshake.'.
I have addressed the issue. It's a code issue, in my code I have set
HandshakeTimeout = TimeSpan.MaxValue;
If I comment above code, then all works fine in both VS and IIS.