具有 azure RedisServerEvents 的服务堆栈服务器事件不起作用,而默认选项 MemoryServerEvents 起作用

servicestack server events with azure RedisServerEvents doesn't work, while default option MemoryServerEvents works

关于使用 Azure Redis 缓存的 Servicestack ServerEvents 的问题..

服务器代码: 我在 Global.asax 文件

的配置方法下有这些行
Plugins.Add(new ServerEventsFeature { 
OnConnect = (res,httpReq) => res.Publish("cmd.onConnect","Message on connect") ,
OnCreated = (res,httpReq) => res.Publish("cmd.onConnect","Message on create"), 
  ...I have custom message for OnSubscription and OnPublish as well
})

**var redisHost = AppSettings.GetString("RedisHost");
container.Register<IRedisClientsManager>(
    new RedisManagerPool(redisHost));
container.Register<IServerEvents>(c => 
    new RedisServerEvents(c.Resolve<IRedisClientsManager>()));
container.Resolve<IServerEvents>().Start();**

以下是我 web.config 中用于 redis 连接的值格式

add key="RedisHost" value="passKey@Hostname:6380?ssl=true"

客户代码:

ServerEventConnect connectMsg = null;
var msgs = new List<ServerEventMessage>();
var commands = new List<ServerEventMessage>();
var errors = new List<Exception>();

var client = new ServerEventsClient(baseUri,"home") {
OnConnect = e => connectMsg = e,
OnCommand = commands.Add,
OnMessage = msgs.Add,
OnException = errors.Add,
}.Start();

var connectMsg = client.Connect();

var joinMsg = client.WaitForNextCommand();

connectMsg.Wait();//It gets connnected
joinMsg.Wait(); //When I debug, it is getting lost on this line. I don't get any error message!

当我删除上面 Global.asax 中标记的 标记的 时(即默认选项 MemoryServerEvents),效果很好。任何建议,想法都会非常有帮助。谢谢

天哪..终于我找到了问题所在..它与服务器事件代码或其配置无关!!!但是我在我的应用程序中出于不同的目的使用了以下行,这对服务器事件有影响!

            // Set the default reuse scope for the container to per request
            container.DefaultReuse = ReuseScope.Request;

我想 onConnect 是第一个请求,而 OnJoin 或其他事件是单独的请求。由于在我的应用程序中设置了重用范围,它无法继续?!如果错误,请分享您的想法。谢谢