Base solution for your next web application

Activities of "cmthomps"

Here's a question for you. Have you tried to reproduce the issue I'm having on your machine with Redis and the StackExchangeRedis nuget package? When I run a straight, out of the box download of AspNetZero with no changes other than adding the StackExchangeRedis nuget package and adding the call to AddStackExchangeRedis in Startup.cs, the notifications do not work. Don't know what else to tell you.

I made no changes to the client side of things. In the Web.Mvc project, I changed a couple of things:

  1. In the Startup.cs ConfigureServices method, I changed
            var signalrBuilder = services.AddSignalR();

To

                var signalrBuilder = services.AddSignalR();
                signalrBuilder.AddStackExchangeRedis(_appConfiguration["SignalR:ConnectionString"], options => {
                        options.Configuration.ChannelPrefix = "smczero";
                        });
                }
  1. In the Configure method, I changed
            app.UseSignalR(routes =>
            {
                routes.MapHub<AbpCommonHub>("/signalr");
                routes.MapHub<ChatHub>("/signalr-chat");
            });

To

            app.UseSignalR(routes =>
            {
                routes.MapHub<SmcAbpCommonHub>("/signalr");
                routes.MapHub<ChatHub>("/signalr-chat");
            });

The last thing I did was register the register the SmcSignalRRealTimeNotifier as IRealTimeNotifier in my Web.Core project which is where the new module code lives.

Thanks @aaron. You're right.... That leads me to my next question. As part of this, I've created my own module that represents the ABP SignalRRealTimeNotifier called SmcSignalRRealTimeNotifier. In there, I've defined a my own AbpCommonHub called SmcAbpCommonHub. The code in the module is exactly the same as what is in ABP (Abp.AspNetCore.SignalR/AspNetCore/SignalR/).

When I use the AbpCommonHub in the Mvc startup.cs, the redis notifications do not work. When I override the SignalRRealTimeNotifier dependency with my own SmcSignalRRealTimeNotifier and use the SmcAbpCommonHub, the redis notifications start working. Can you think of a reason why that is?

Not sure. The first one does not work with Redis the second one does. I guess others will find this if they need it.

I'd like to vote for AspNetZero to enhance the product to support scale out using load balancing. Given the popularity of kubernetes, having this capability will be extremely valuable. I've got it running on kubernetes now, but finding that notifications and chat do not work. We got notifications to work using the hack above and I'm trying to get chat working with Redis using the code developed by another user. Haven't had any luck yet with Chat. All credit to personball on github.

RedisOnlineClientManager.cs

Here's what seems to have fixed it for me. I don't really understand why, but it seems to work nonetheless.

In the SendNotificationsAsync method, I changed the line that says:

signalRClient.SendAsync("getNotification", userNotification);

to

_hubContext.Clients.Client(onlineClient.ConnectionId).SendAsync("getNotification", userNotification);

Does that make any sense to you?  if I use the signalRClient object, it doesn't seem to send the notifications properly.

It looks like the ConnectionId is valid. I starting logging the UserId and the ConnectionId. This what that looks like:

UserID: 1 ConnectionId: wRX8xHl-XqgDsKZ8zGunNA

When I use var signalRClient = _hubContext.Clients.Client(onlineClient.ConnectionId);, I do not see any activity on the redis server.  When I use Clients.All, I start to see activity on the Redis server that looks like:

<br>

1549554528.516258 [0 172.17.0.9:45157] "INFO" "replication"
1549554536.048210 [0 172.17.0.1:61383] "PUBLISH" "smczeroSmc.Abp.AspNetCore.SignalR.Hubs.AbpCommonHub:all" "\x92\x90\x81\xa4json\xc5\x02E{\"type\":1,\"target\":\"getNotification\",\"arguments\":[{\"tenantId\":null,\"userId\":1,\"state\":0,\"notification\":{\"tenantId\":null,\"notificationName\":\"App.TestNotification\",\"data\":{\"message\":{\"sourceName\":\"SMCDemo\",\"name\":\"TestNotification\"},\"type\":\"Abp.Notifications.LocalizableMessageNotificationData\",\"properties\":{\"message\":{\"sourceName\":\"SMCDemo\",\"name\":\"TestNotification\"}}},\"entityType\":null,\"entityTypeName\":null,\"entityId\":null,\"severity\":2,\"creationTime\":\"2019-02-07T10:48:52.744841-05:00\",\"id\":\"4defe4c2-997f-4cc2-9368-fda4a8ec947d\"},\"id\":\"2aeb9a04-d11a-4118-8ef8-5e592b0b06ca\"}]}\x1e"
1549554538.425415 [0 127.0.0.1:54504] "AUTH" "5NSAjVIyvGmfpBot"

I don't really know what the implications are to using Clients.All.  Do you?

Thanks, Craig

@ismcagdas - I got notifications working in a load balanced environment. What I found was that there maybe an issue with SignalRRealTimeNotifier in the Abp.AspNetCore.SignalR. In that code, there is a line that says:

var signalRClient = _hubContext.Clients.Client(onlineClient.ConnectionId);

If I change that line of code to:

var signalRClient = _hubContext.Clients.All;

I'll be completely honest, I don't really know why it works. I was going through Microsoft's example on the redis backplane and found this difference. When I changed it, it started working (at least in my initial tests).

Did you all ever figure this out? Running into the same issue?

@maliming thanks. I added a comment to the issue in github because I found other issues with the bundlconfig file.

It seems as though the problem is the order of how the javascript files are getting bundled. In my case the culprit is librarySettings.js. It's getting inserted into the bundled file before app.localize is getting defined further down in the file. Is there a way to control the order of how the files get bundled?

My "hack" solution was to exclude librarySettings.js in my first bundle and then add it in the next step.

{ "outputFileName": "wwwroot/view-resources/Areas/App/Views/_Bundles/common-scripts.js", "inputFiles": [ "wwwroot/Common/Scripts//*.js", "!wwwroot/Common/Scripts/librarySettings.js", "!wwwroot/Common/Scripts//*min.js", "!wwwroot/Common/Scripts/Chat/chat.signalr.js" ] }, { "outputFileName": "wwwroot/view-resources/Areas/App/Views/_Bundles/common-scripts.js", "inputFiles": [ "wwwroot/view-resources/Areas/App/Views/_Bundles/common-scripts.js", "wwwroot/Common/Scripts/librarySettings.js" ] },

Showing 11 to 20 of 59 entries