Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SignalR Core on .NET Core 2.2 not connecting on Azure but works locally #8677

Closed
mikeesouth opened this issue Mar 20, 2019 · 1 comment
Closed

Comments

@mikeesouth
Copy link

Describe the bug

I've been using SignalR Core for quite some time and it have been working nicely. When upgrading versions it stopped working on Azure but it still works locally. I upgraded these packages:

  • The javascript client from 1.1.0-preview2-35157 to 1.1.0 (@aspnet/signalr)
  • The server client from 1.1.0-preview2-35157 to 1.1.0 (Microsoft.AspNetCore.SignalR)
  • The server from .NET Core 2.1.4 to 2.2

I did change the CORS settings since "AllowCredentials" is no longer allowed in combination with "AllowAnyOrigin". The CORS settings are only used for localhost development, in Azure environment everything runs on the same origin so no CORS is necessary.
Everything works perfectly in localhost but in Azure (I host the solution as an app service) the client cannot connect to the server. No error, no log, only "pending" connection, hubConnection.start() does not finish.

I've tried to apply CORS even for Azure but it does not help.

It is worth noting that the Azure environment uses HTTPS but localhost does not.

Expected behavior

That the connection establishes correctly.

Screenshots

Additional context

dotnet --info:

.NET Core SDK (reflecting any global.json):
 Version:   2.2.200
 Commit:    27f814f6ba

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.17763
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\2.2.200\

Host (useful for support):
  Version: 2.2.2
  Commit:  a4fd7b2c84

.NET Core SDKs installed:
  2.1.600 [C:\Program Files\dotnet\sdk]
  2.2.200 [C:\Program Files\dotnet\sdk]

.NET Core runtimes installed:
  Microsoft.AspNetCore.All 2.1.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.2.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.1.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.2.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 2.1.8 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.2.2 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]

To install additional .NET Core runtimes or SDKs:
  https://aka.ms/dotnet-download

It is somewhat similar to #4483 (but CORS does not help). It is also somewehat similar to #4389 (but I do not use MessagePack).

Some relevant code snippets:
Startup.cs :: ConfigureServices:
services.AddSignalR();
Startup.cs :: Configure:
app.UseSignalR(routes =>{ routes.MapHub("/ws"); });

websockets.ts:

try {
  let options = {
    logMessageContent: true,
    transport: HttpTransportType.WebSockets
  };
  this.hubConnection = new HubConnectionBuilder()
    .configureLogging(LogLevel.Error)
    .withUrl(this.uri, options)
    .build();

  this.hubConnection.on('MessageFromServer', (data: any) => {
    this.handleMessage(data);
  });

  this.hubConnection.onclose = e => {
    this.log('connection closed');
  };

  this.hubConnection.start()
    .then(() => {
      this.log('Hub connection started');
      this.connectionEstablishedEvent();
      this.checkConnection();
    })
    .catch(err => {
      this.log('Error while establishing connection');
      this.connectionFailedEvent();
      setTimeout(() => { this.connect(); }, this.RECONNECT_DELAY);
    });
} catch (exc) {
  this.log('websockets - exception:', exc);
}

Any ideas?

@mikeesouth
Copy link
Author

Ok, after spending a couple of days I finally solved it (just after posting the question of course). The problem was hidden in the exception in the catch clause. I use typescript and webpack to bundle the solution. Previous versions of @aspnet/signalr had some kind of babel issue so I had to use a babel-loader to transpile the js code. This seems to have changed between 1.1.0-preview2-35157 and 1.1.0. By removing the babel-loader from node_modules/signalr the code compiles correctly.

When using the babel-loader I got an exception in the signalr source: RangeError: Maximum call stack size exceeded.

halter73 pushed a commit to dotnet-maestro-bot/AspNetCore that referenced this issue Mar 28, 2019
@ghost ghost locked as resolved and limited conversation to collaborators Dec 3, 2019
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

1 participant