I am running ABP MVC .Net Core on a web farm behind a load balancer. I use SignalR for notifications. After logging in attempts are made to initiate a SignalR connection. In the browser dev tools you can see the activity:
/signalr/connect?transport=serverSentEvents&clientProtocol=1.5&connectionToken=xxx&connectionData=%5B%7B%22name%22%3A%22abpcommonhub%22%7D%2C%7B%22name%22%3A%22chathub%22%7D%5D&tid=6
However, this gives a 400 with the following error: The ConnectionId is in the incorrect format.
Following advice from other sources:
I have shared .NET Core data protection keys in Redis.
IIS has defined machine keys so these are the same on all servers.
The app pools are set to run as the same domain user.
Can you help me discover what I have missed please.
Thanks
5 Answer(s)
-
0
Hi,
Have you followed this document to integrate SignalR into your project <a class="postlink" href="https://aspnetboilerplate.com/Pages/Documents/SignalR-AspNetCore-Integration">https://aspnetboilerplate.com/Pages/Doc ... ntegration</a> ? Becasue .NET Core version of AspNet Zero doesn't have SignalR yet.
-
0
Thank you for your reply.
I am actually using Abp.Web.SignalR. The ASP.NET Zero template I am using is version 2.2.2.
SIgnalR itself works, except when load balanced. This is how I configure SignalR:
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) { //Initializes ABP framework. app.UseAbp(options => { options.UseAbpRequestLocalization = false; //used below: UseAbpRequestLocalization }); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseStatusCodePagesWithRedirects("~/Error?statusCode={0}"); app.UseExceptionHandler("/Error"); } app.UseAuthentication(); app.UseJwtTokenMiddleware(); if (bool.Parse(_appConfiguration["IdentityServer:IsEnabled"])) { app.UseIdentityServer(); } app.UseStaticFiles(); app.UseAbpRequestLocalization(); #if FEATURE_SIGNALR //Integrate to OWIN app.UseAppBuilder(ConfigureOwinServices); #endif app.UseSession(); app.UseMvc(routes => { routes.MapRoute( name: "defaultWithArea", template: "{area}/{controller=Home}/{action=Index}/{id?}"); routes.MapRoute( name: "default", template: "{controller=Home}/{action=Index}/{id?}"); }); } #if (FEATURE_SIGNALR) private void ConfigureOwinServices(IAppBuilder app) { app.Properties["host.AppName"] = "MyApp"; app.UseAbp(); //added based on this https://github.com/aspnetboilerplate/aspnetboilerplate/issues/1962 GlobalHost.DependencyResolver.Register(typeof(IAssemblyLocator), () => new SignalRAssemblyLocator()); // configure SignalR to use Redis backplane GlobalHost.DependencyResolver.UseRedis(_appConfiguration.GetRedisConnectionString(), 6379, "", "MyQueue"); app.MapSignalR(); }
-
0
@devkev2403 probably the problem is related to SignalR itself.
Have you searched it on the web ? -
0
@ismcagdas
Yes, I have spent quite a lot of time on this issue. I have done a lot of research and as per my previous post I have:
Put data protection keys in Redis (not sure SignalR uses them)
Made machine keys the same on both servers
Have the app pool on both servers running as the same userI'm not sure where the problem lies - just wondered if you have any ideas?
I will keep investigating.
-
0
Hi,
If you haven't seen this, Microsoft has an official document <a class="postlink" href="https://docs.microsoft.com/en-us/aspnet/signalr/overview/performance/scaleout-with-redis">https://docs.microsoft.com/en-us/aspnet ... with-redis</a>.
It might help you.