rebus-org / Rebus.SignalR

:bus: Rebus-based SignalR backplane
Other
29 stars 6 forks source link

Intermittent missed messages with SQL Server #14

Open elylv opened 1 year ago

elylv commented 1 year ago

I am using Rebus with SQL Server backing, to send SignalR messages from the server to the client.

        services.AddSignalR()
            .AddRebusBackplane<NotificationHub>();
        var conn = configuration["ConnectionStrings:DefaultConnection"];
        services.AddRebus(conf => conf
        .Transport(t => t.UseSqlServer(new SqlServerTransportOptions(conn), "MessageQueue").SetEnsureTablesAreCreated(false))
        .Options(o => { o.EnableSynchronousRequestReply(); o.SimpleRetryStrategy("MessageErrors", 10); })
        .Logging(l => l.Serilog())
        .Routing(r => r.TypeBased()
                .MapSignalRCommands<NotificationHub>("MessageQueue"))
            .Subscriptions(s => s.StoreInSqlServer(conn, "MessageSubscriptions", false))
        );

When it comes to sending a message e.g. await hubContext.Clients.User(user.UserName).SendAsync("NewNotification", unreadNotifs, notifdtos); it works, but very intermittently.

I can view the websocket communication between the browser and the server, and I see valid pings back and forward between them, but intermittently, it doesn't send some messages (no websocket communication seen, but no errors raised), and I can't work out why. If I remove the AddRebusBackplane and just use normal SignalR, everything works fine. But in my production environment, I am load balanced and need to have the SignalR hubs centralized, so need to use Rebus.

Any ideas?

mookid8000 commented 1 year ago

@rsivanov Any idea what could cause this?

kzimny commented 9 months ago

Are you working behind a "special" firewall? For test purposes change the HttpTransportType from your Hub to HttpTransportType.WebSockets | HttpTransportType.LongPolling:

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapHub<RegistrationHub>("/registrationHub", options =>
                {
                    options.Transports = HttpTransportType.WebSockets | HttpTransportType.LongPolling;
                });
            });

I had a similar issue with load balancer. This is probably not an issue with Rebus package.