关于使用 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)中删除上面标记的Redis 注册时,效果很好。任何建议,想法都会非常有帮助。谢谢