使用redis背板时不传输信号器消息

o75abkj4  于 2021-06-09  发布在  Redis
关注(0)|答案(0)|浏览(265)

我们有一个应用程序,它使用signalr将消息从asp.net mvc应用程序推送到客户端。推送功能以前是工作的,但当尝试添加redis背板时,通知不再推送到客户端。要推送数据,服务器端有以下代码:

public class SignalrDataSync : IDataSync
{
    private readonly IHubContext _hubContext;

    public SignalrDataSync(IHubContext hubContext)
    {
        _hubContext = hubContext;
    }

    public void UpdateSitePartForUser(TmoUser user, SitePart sitePart)
    {
        var connection = GetConnectionForUser(user);
        var view = SitePartViewModel.FromEntity(sitePart);
        connection.Invoke("updateClient", view);
    }

    private IClientProxy GetConnectionForUser(TmoUser user) => _hubContext.Clients.Group(user.UserName);
}

如您所见,我们将数据推送到一个组,该组是用户的用户名。数据是在被推送之前转换为视图模型的实体。要配置背板,我们将其添加到作为应用程序启动一部分的配置中:

public class SignalrBootstrapper
{
    public void Configuration(IAppBuilder app)
    {
        var scaleoutConfig = new RedisScaleoutConfiguration(ConnectionStrings.Redis, "CandidateSignalrBackplane");
        GlobalHost.DependencyResolver.UseStackExchangeRedis(scaleoutConfig);

        // Any connection or hub wire up and configuration should go here
        app.MapSignalR();
    }
}

我已经在signar上启用了跟踪,可以看到客户端连接并加入正确的组。请参阅下面的消息总线日志(这里的组是fred1003):
signalr.scaleoutmessagebus信息:0:onreceived(0,77,1)signalr.scaleoutmessagebus详细信息:0:received message 77:'{“waitforack”:false,“id”:“e2786caa-df1b-4892-bfa3-4909ebb82624”,“commandtype”:0,“value”:null}'over scaleoutmessagebus signalr.scaleoutmessagebus详细信息:0:message id:77,流:0,eventkey:'c-21075c00-9430-48da-91c1-4250ac117407'已保存,本地id:0 signalr.scaleoutmessagebus详细信息:0:计划eventkey:c-21075c00-9430-48da-91c1-4250ac117407
signalr.scaleoutmessagebus信息:0:onreceived(0,78,1)signalr.scaleoutmessagebus verbose:0:received message 78:'{“waitforack”:true,“id”:“20d69878-d5d4-467a-acf5-eabe75160729”,“commandtype”:1,“value”:“hg synchub.fred1003”}“over scaleoutmessagebus signalr.scaleoutmessagebus verbose:0:message id:78,stream:0,eventkey:'c-21075c00-9430-48da-91c1-4250ac117407'已保存,本地id:1 signalr.scaleoutmessagebus详细信息:0:调度eventkey:c-21075c00-9430-48da-91c1-4250ac117407
signalr.scaleoutmessagebus信息:0:onreceived(0,79,1)signalr.scaleoutmessagebus详细信息:0:received message 79:“”over scaleoutmessagebus signalr.scaleoutmessagebus详细信息:0:message id:79,stream:0,eventkey:'signalr\uu server'与本地id一起保存:0 signalr.scaleoutmessagebus详细信息:0:scheduling eventkeys:signalr\uu server
signalr.scaleoutmessagebus信息:0:onreceived(0,80,1)signalr.scaleoutmessagebus详细信息:0:received message 80:'{“waitforack”:true,“id”:“668e5f76-e305-41a4-90a3-deb494b95fb9”,“commandtype”:2,“value”:“hg synchub.fred1003”}'over scaleoutmessagebus signalr.scaleoutmessagebus详细信息:0:message id:80,流:0,eventkey:'c-0abd061f-e00f-42c1-b245-fa49903c53bc'已保存,本地id:2 signalr.scaleoutmessagebus详细信息:0:计划eventkey:c-0abd061f-e00f-42c1-b245-fa49903c53bc
因为这是通过,我可以告诉连接到redis示例正在工作(我也尝试手动连接到redis和订阅通道,可以看到这些消息在客户端连接时传入)。然而,当尝试实际推送数据时,redis没有收到任何东西,因此客户端没有收到任何东西。

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题