ServerEventsClient Auto-Reconnect, best practice Authentication


I’m using the C# ServerEventsClient. My ServiceStack server (IIS) has the option in ServerEvents, LimitToAuthenticatedUsers enabled. My client has to have a continuous connection to the API.

My client can Authenticate, and THEN start the SSE Client to use it. In a scenario where I don’t have to authenticate, SSE Client wil automatically reconnect if connection should drop. However, when using Authentication and the server is rebooted, it has to reauthenticate.

Is this somehow encapsulated in the SSE Client, or should I do this myself reacting on an OnException of Unauthorized kind?

What Authenticaton are you using? If you’re using Session based Authentication with a distributed caching provider the session won’t be lost on restart and it should auto reconnect by itself.

I’m using CredentialAuthProvider, but no Distributed Caching Provider of some sort.
For me; I’m no big fan of Session caching, but if it’s the only possibility to get this working I’ll think it over.


Credentials AuthProvider does use Sessions and if you don’t use a distributed caching provider then all sessions are lost after each App restart.