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).
Have you implemented AspNetZero using the the StackExchange Redis Backplane? Trying to tackle SignlaR behind a load balancer using Set up a Redis backplane for ASP.NET Core SignalR scale-out. I've added the StackExchangeRedis NuGet package and called AddStackExchangeRedis after the AddSignalR method. Everything seems to work ok, but SignalR only works for users that are connected to the same server. If user A is on server 1 and user B is on server 2, it doesn't work. If A & B are both on Server 1, it works. This is the code we've implemented in the Startup ConfigureServices.
var signalrBuilder = services.AddSignalR(o =>
{
o.EnableDetailedErrors = true;
});
signalrBuilder.AddStackExchangeRedis(_appConfiguration["SignalR:ConnectionString"], options => {
options.Configuration.ChannelPrefix = "zerochannel";
});
I can see all the servers "subscribe" in the redis logs. But for some reason, when I message goes out of one server the other servers are not picking it up. This is an example of what I see in Redis. I'm not entirely sure the meaning/importance of the names on the SUBSCRIBE lines.
1549404094.848664 [0 172.17.0.12:37121] "AUTH" "XXXXXXX"
1549404094.848693 [0 172.17.0.12:37121] "ECHO" "\x89\xcf\xf7\xf4>\xaf C\x9cz\x88\xd8\xf1\x98\xb6\x05"
1549404094.848704 [0 172.17.0.12:37121] "SUBSCRIBE" "zerochannel__Booksleeve_MasterChanged"
1549404094.864930 [0 172.17.0.12:36336] "AUTH" "5NSAjVIyvGmfpBot"
1549404094.865012 [0 172.17.0.12:36336] "INFO"
1549404094.865086 [0 172.17.0.12:36336] "ECHO" "\x89\xcf\xf7\xf4>\xaf C\x9cz\x88\xd8\xf1\x98\xb6\x05"
1549404094.866966 [0 172.17.0.12:36336] "PING"
1549404094.866995 [0 172.17.0.12:36336] "GET" "__Booksleeve_TieBreak"
1549404094.867013 [0 172.17.0.12:36336] "PING"
1549404094.867017 [0 172.17.0.12:36336] "GET" "__Booksleeve_TieBreak"
1549404094.867023 [0 172.17.0.12:36336] "INFO" "replication"
1549404095.289384 [0 172.17.0.12:37121] "SUBSCRIBE" "zerochannelSMCDemo.Web.Chat.SignalR.ChatHub:all"
1549404095.333222 [0 172.17.0.12:37121] "SUBSCRIBE" "zerochannelSMCDemo.Web.Chat.SignalR.ChatHub:internal:groups"
1549404095.366710 [0 172.17.0.12:37121] "SUBSCRIBE" "zerochannelSMCDemo.Web.Chat.SignalR.ChatHub:internal:ack:smczero-deployment-858c6845f9-sn8p4_056b26b232fe4cc99fdee32792553850"
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" ] },
Interesting. I still get the same result. I am building the site on a Mac, could that be the problem?
Just created a dropbox folder and invited you to share.
Sure, where should I send them?
This is what I got.