9

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

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.'.

enter image description here

Lakin Lu
  • 4,376
  • 3
  • 10
  • 12

2 Answers2

6

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.

Lakin Lu
  • 4,376
  • 3
  • 10
  • 12
0

The same here, but a bit different: I ran the server in Rider and everything worked. I put it in another directory and I've got handshake errors. Removing the handshake timeout and it works everywhere.

Slesa
  • 245
  • 2
  • 11