Hi guys
I have a really strange issue I’m not able to understand. I’m using SSE and sometimes it hangs till timeout when executing Start() method.
This is my apphost
public class MaresApiHost : AppHostHttpListenerPoolBase
{
public override void Configure(Container container)
{
Plugins.Add(new SwaggerFeature());
Plugins.Add(new ServerEventsFeature());
Plugins.Add(new AuthFeature(() => new CustomAuthUserSession(),
new IAuthProvider[]
{
new PinAuthProvider(),
new UserNameAuthProvider()
}
));
//registro i database
container.Register<IDbConnectionFactory>(ServiceEnvironment.Mares40ConnectionFactoryName, c => new OrmLiteConnectionFactory(ApplicationVariables.Instance.ConnectionStringToMasterDatabase, SqlServerDialect.Provider));
container.Register<IDbConnectionFactory>(ServiceEnvironment.Analysis40ConnectionFactoryName, c => new OrmLiteConnectionFactory(ApplicationVariables.Instance.ConnectionStringToAnalysis40Database, SqlServerDialect.Provider));
//registro la cache sul database
container.Register<OrmLiteCacheClient>(c => new OrmLiteCacheClient() { DbFactory = c.ResolveNamed<IDbConnectionFactory>(ServiceEnvironment.Mares40ConnectionFactoryName) });
container.Register<ICacheClient>(c => c.Resolve<OrmLiteCacheClient>());
container.Resolve<ICacheClient>().InitSchema();
//registro tutte le rotte
Routes.AddFromAssembly(base.ServiceAssemblies.ToArray());
//Configs the host
SetConfig(new HostConfig
{
DebugMode = true,
EnableFeatures = Feature.All,
});
//Prevents Json serialized to add __type part on json string for anonymous types serialization
//Read this: -http://stackoverflow.com/questions/18842685/servicestack-sessions-doesnt-work-when-using-jsconfig-excludetypeinfo
JsConfig.Init(new Config
{
DateHandler = DateHandler.ISO8601,
ExcludeTypeInfo = true,
ExcludeDefaultValues = true,
IncludeNullValues = false
});
}
}
on my consumer I’m using a wrap class to execute the Start in this way
public bool Start()
{
try
{
lock (locker)
this.EventClient.Start();
this.IsStarted = true;
}
catch (Exception ex)
{
Log.Error("Start", ex);
this.IsStarted = false;
}
return this.IsStarted;
}
where EventClient is
public ServerEventsClient EventClient { get; private set; }
created in this way
this.Url = $"{ApplicationVariables.Instance.APIProtocol}://{ipAddress}:{ApplicationVariables.Instance.APIPort}/";
this.EventClient = new ServerEventsClient(this.Url);
and the ServerEventsClient sometimes hangs while executing start() till a Timeout exception. My apphost is running on a server that is always reachable. It seems like if it is waiting for a previous task to complete, but I don’t know where I can search.
Is it a problem on the apphost side or in the client side? Is the ServerEventClient threadsafe?
Best regards
Enrico