-
Notifications
You must be signed in to change notification settings - Fork 124
Description
High-Level Problem
A .NET 8 service application that subscribes to messages from PubNub and, upon upgrade/restart, will occasionally get into a state where it cannot connect to PubNub until the application is restarted again.
Notes
- The .NET application is .NET 8 (as time of this writing, v8.0.200).
- Using NuGet PubnubPCL v6.19.7 (latest as of April 16, 2024).
- Using
ReconnectionPolicyrepeatedly fails to connect to PubNub. - The current nature of the .NET application is to perform multiple Subscribe() + Execute() invocations when an entity from a separate system is "discovered" (e.g. Discover Entity A then perform
Subscribe().Channels("entity-A-notification-type1").Execute()). - My personal gut feeling is a thread synchronization issue, possibly somewhere around
ClientNetworkStatus.RefHttpClient = httpClientNetworkStatus. - When I add a project reference to
PubnubApiPCL.csproj, I caught this state where, somehow, there is a header with anullkey (.NET thread safety issue with HTTP headers?).

Reproduction
I have attached a simple application (from a Windows system). You will need to populate SubscribeKey, AuthKey, and channels with real values. Afterwards, you can run the script run.bat which should build and then re-start the application until the problem eventually reproduces; the output will indicate a failure to connect (ERROR Internet connection problem. Retrying connection Cat=PNNetworkIssuesCategory). I usually have it reproduce within about 30 seconds.
ReproductionApp.zip
The application is fairly straightforward: create the Pubnub instance, perform Subscribe().Channels(...).Execute() multiple times, then wait about 2 seconds for connection messages before exiting.