Hi,
I am using ServiceStack 5.5.1 with .NET Core 2.2 and would like to know how you can recover from a Server Event Heartbeat Exception.
In the log I get the following on a C# console client:
2019-08-28 22:25:58,470 [72] DEBUG ServiceStack.ServerEventsClient [(null)] - [SSE-CLIENT] Heartbeat sent to: https://server01.myserver.com/event-heartbeat?id=5GD4KIbbwCIRrVA1k3wU
2019-08-28 22:26:08,478 [72] DEBUG ServiceStack.ServerEventsClient [(null)] - [SSE-CLIENT] Prep for Heartbeat…
2019-08-28 22:26:08,478 [72] DEBUG ServiceStack.ServerEventsClient [(null)] - [SSE-CLIENT] Sending Heartbeat…
2019-08-28 22:26:08,664 [6] DEBUG ServiceStack.ServerEventsClient [(null)] - [SSE-CLIENT] LastPulseAt: 21:26:08.6646476
2019-08-28 22:26:08,664 [6] DEBUG ServiceStack.ServerEventsClient [(null)] - [SSE-CLIENT] OnHeartbeatReceived: (ServerEventHeartbeat) #10270 on #SERVER01_DGXzea49) (agent)
2019-08-28 22:26:08,664 [6] DEBUG ServiceStack.ServerEventsClient [(null)] - [SSE-CLIENT] Heartbeat sent to: https://server01.myserver.com/event-heartbeat?id=5GD4KIbbwCIRrVA1k3wU
2019-08-28 22:26:18,666 [6] DEBUG ServiceStack.ServerEventsClient [(null)] - [SSE-CLIENT] Prep for Heartbeat…
2019-08-28 22:26:18,666 [6] DEBUG ServiceStack.ServerEventsClient [(null)] - [SSE-CLIENT] Sending Heartbeat…
2019-08-28 22:26:18,786 [72] DEBUG ServiceStack.ServerEventsClient [(null)] - [SSE-CLIENT] LastPulseAt: 21:26:18.7861605
2019-08-28 22:26:18,786 [72] DEBUG ServiceStack.ServerEventsClient [(null)] - [SSE-CLIENT] OnHeartbeatReceived: (ServerEventHeartbeat) #10271 on #SERVER01_DGXzea49) (agent)
2019-08-28 22:26:18,786 [18] DEBUG ServiceStack.ServerEventsClient [(null)] - [SSE-CLIENT] Heartbeat sent to: https://server01.myserver.com/event-heartbeat?id=5GD4KIbbwCIRrVA1k3wU
2019-08-28 22:26:28,791 [18] DEBUG ServiceStack.ServerEventsClient [(null)] - [SSE-CLIENT] Prep for Heartbeat…
2019-08-28 22:26:28,792 [18] DEBUG ServiceStack.ServerEventsClient [(null)] - [SSE-CLIENT] Sending Heartbeat…
2019-08-28 22:26:31,532 [18] DEBUG ServiceStack.ServerEventsClient [(null)] - [SSE-CLIENT] Error from Heartbeat: The remote server returned an error: (404) Subscription ‘5GD4KIbbwCIRrVA1k3wU’ does not exist.
2019-08-28 22:26:31,532 [18] ERROR ServiceStack.ServerEventsClient [(null)] - [SSE-CLIENT] OnExceptionReceived: The remote server returned an error: (404) Subscription ‘5GD4KIbbwCIRrVA1k3wU’ does not exist. on #SERVER01_DGXzea49)
System.Net.WebException: The remote server returned an error: (404) Subscription ‘5GD4KIbbwCIRrVA1k3wU’ does not exist.
at System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
at System.Net.WebRequest.<>c.b__68_2(IAsyncResult iar)
at System.Threading.Tasks.TaskFactory1.FromAsyncCoreLogic(IAsyncResult iar, Func
2 endFunction, Action1 endAction, Task
1 promise, Boolean requiresSynchronization)
— End of stack trace from previous location where exception was thrown —
at ServiceStack.HttpUtils.SendStringToUrlAsync(String url, String method, String requestBody, String contentType, String accept, Action1 requestFilter, Action
1 responseFilter) in C:\BuildAgent\work\912418dcce86a188\src\ServiceStack.Text\HttpUtils.cs:line 600
2019-08-28 22:26:31,533 [18] DEBUG ServiceStack.ServerEventsClient [(null)] - Stop()
2019-08-28 22:26:31,533 [18] DEBUG ServiceStack.ServerEventsClient [(null)] - [SSE-CLIENT] Unregistering…
2019-08-28 22:26:31,860 [18] DEBUG ServiceStack.ServerEventsClient [(null)] - Start()
2019-08-28 22:26:31,968 [18] ERROR ServiceStack.ServerEventsClient [(null)] - [SSE-CLIENT] OnExceptionReceived: The remote server returned an error: (401) Unauthorized. on #(not connected)
System.Net.WebException: The remote server returned an error: (401) Unauthorized.
at ServiceStack.PclExport.GetResponse(WebRequest webRequest) in C:\BuildAgent\work\912418dcce86a188\src\ServiceStack.Text\PclExport.cs:line 180
at ServiceStack.ServerEventsClient.Start() in C:\BuildAgent\work\3481147c480f4a2f\src\ServiceStack.Client\ServerEventsClient.cs:line 222
at ServiceStack.ServerEventsClient.b__104_1(Task t) in C:\BuildAgent\work\3481147c480f4a2f\src\ServiceStack.Client\ServerEventsClient.cs:line 485
2019-08-28 22:26:32,641 [18] DEBUG ServiceStack.ServerEventsClient [(null)] - Stop()
2019-08-28 22:26:32,641 [51] DEBUG ServiceStack.ServerEventsClient [(null)] - Sleeping for 22ms after 2 continuous errors
2019-08-28 22:26:32,666 [51] DEBUG ServiceStack.ServerEventsClient [(null)] - Start()
2019-08-28 22:26:32,777 [51] DEBUG ServiceStack.ServerEventsClient [(null)] - [SSE-CLIENT] LastPulseAt: 21:26:32.7777449
After this happens the client doesn’t reconnect. Is there an event I can subscribe to so I can reconnect as it doesn’t seem to reconnect automatically.
Thanks in advance.