I recently learned about SignalR and implemented a Persistent Online Connection check where the repository of the states is a SQL database. It correctly detects when a user is Online/Offline. The problem becomes when the user is Online browsing the Home/Index.cshtml and then goes to Home/Edit.cshtml, OnDisconnected gets fired thus it creates a new connection. If I will like to keep the connection open how to? I had placed the hub connection in the _Layout.cshtml but obviously this gets reloaded as a new page is browsed. I attempted to increase:

GlobalHost.Configuration.ConnectionTimeout = TimeSpan.FromSeconds(110);

GlobalHost.Configuration.DisconnectTimeout = TimeSpan.FromSeconds(45);

GlobalHost.Configuration.KeepAlive = TimeSpan.FromSeconds(15);

In the Startup.cs right before app.MapSignalR();. Did not work, not sure why.

Thus if I will like to keep a chat api the user will appear offline/online momentarily. I will like to prevent this.

Related posts

Recent Viewed