Graham Laidler - 212 - Oct 31, 2014

Hi, I am trying to use ServiceStack’s Server Sent Events with Redis backend.  All hooked up well, but when the client attempts to connect, I am getting a null reference exception when trying to get the CurrentServerTime - I am only hooking up RedisServerEvents in Global.asax.cs, NOT RedisPubSubServer - is this wrong?:

— Global.asax.cs
container.Register<IRedisClientsManager>(c => new pooledRedisClientManager(redisConnection));
                
container.Register<IServerEvents>(c => new RedisServerEvents(c.Resolve<IRedisClientsManager>()));
                container.Resolve<IServerEvents>().Start();

------ Exception info
[NullReferenceException: Object reference not set to an instance of an object.]
   ServiceStack.Redis.RedisPubSubServer.get_CurrentServerTime() +30
   ServiceStack.&lt;&gt;c__DisplayClass21.&lt;StoreSubscriptionInfo&gt;b__15(IRedisClient r) +59
   ServiceStack.RedisServerEvents.StoreSubscriptionInfo(IRedisClient redis, SubscriptionInfo info) +175
   ServiceStack.RedisServerEvents.Register(IEventSubscription sub, Dictionary`2 connectArgs) +97
   ServiceStack.ServerEventsHandler.ProcessRequestAsync(IRequest req, IResponse res, String operationName) +1494
   ServiceStack.Host.Handlers.HttpAsyncTaskHandler.System.Web.IHttpAsyncHandler.BeginProcessRequest(HttpContext context, AsyncCallback cb, Object extraData) +114
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +12650919
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean&amp; completedSynchronously) +288
</pre></code>

Hi Graham, could you submit this issue to: https://github.com/ServiceStack/Issues

and we can continue the thread from there.

Your configuration code looks right as it matches the RedisServerEvents support in Chat:
https://github.com/ServiceStackApps/Chat/blob/master/src/Chat/Global.asax.cs#L49-L53

So I’m not sure what the issue is, can we try to see if it’s an environment issue by checking if the RedisServerEvent Chat app work for you? You just need to add:

<add key=“RedisHost” value=“localhost” />

in your Web.config <appSettings/> to get it to run on Redis Server Events

Otherwise can you connect to Redis Server normally with the RedisClient, e.g in your AppHost with:

using (var redis = container.Resolve<IRedisClientsManager>().GetClient())
{
    var serverTime = redis.GetServerTime();
}

If you can, what’s the best way to get a repro? could you put together a small sample that shows the issue that I can check out?

Graham Laidler:

It was my Redis version - when I did as you suggested, it didn’t seem to support the TIME command - god knows what version I was running.  When I downloaded latest MSOpenTech and overwrite binaries - all was fine.

Thanks for support.

G