Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions .pubnub.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
name: c-sharp
version: "7.3.5"
version: "7.3.6"
schema: 1
scm: github.com/pubnub/c-sharp
changelog:
- date: 2025-04-03
version: v7.3.6
changes:
- type: bug
text: "Reafctor: Removed excess logging from transport module. Removed redundant logging from transport layer and added thread id information for tracking http request."
- date: 2025-03-31
version: v7.3.5
changes:
Expand Down Expand Up @@ -872,7 +877,7 @@ features:
- QUERY-PARAM
supported-platforms:
-
version: Pubnub 'C#' 7.3.5
version: Pubnub 'C#' 7.3.6
platforms:
- Windows 10 and up
- Windows Server 2008 and up
Expand All @@ -883,7 +888,7 @@ supported-platforms:
- .Net Framework 4.6.1+
- .Net Framework 6.0
-
version: PubnubPCL 'C#' 7.3.5
version: PubnubPCL 'C#' 7.3.6
platforms:
- Xamarin.Android
- Xamarin.iOS
Expand All @@ -903,7 +908,7 @@ supported-platforms:
- .Net Core
- .Net 6.0
-
version: PubnubUWP 'C#' 7.3.5
version: PubnubUWP 'C#' 7.3.6
platforms:
- Windows Phone 10
- Universal Windows Apps
Expand All @@ -927,7 +932,7 @@ sdks:
distribution-type: source
distribution-repository: GitHub
package-name: Pubnub
location: https://github.com/pubnub/c-sharp/releases/tag/v7.3.5.0
location: https://github.com/pubnub/c-sharp/releases/tag/v7.3.6.0
requires:
-
name: ".Net"
Expand Down Expand Up @@ -1210,7 +1215,7 @@ sdks:
distribution-type: source
distribution-repository: GitHub
package-name: PubNubPCL
location: https://github.com/pubnub/c-sharp/releases/tag/v7.3.5.0
location: https://github.com/pubnub/c-sharp/releases/tag/v7.3.6.0
requires:
-
name: ".Net Core"
Expand Down Expand Up @@ -1569,7 +1574,7 @@ sdks:
distribution-type: source
distribution-repository: GitHub
package-name: PubnubUWP
location: https://github.com/pubnub/c-sharp/releases/tag/v7.3.5.0
location: https://github.com/pubnub/c-sharp/releases/tag/v7.3.6.0
requires:
-
name: "Universal Windows Platform Development"
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
v7.3.6 - April 03 2025
-----------------------------
- Fixed: reafctor: Removed excess logging from transport module. Removed redundant logging from transport layer and added thread id information for tracking http request.

v7.3.5 - March 31 2025
-----------------------------
- Fixed: standardize connection configuration to address inconsistent platform defaults leading to socket exhaustion under high load.
Expand Down
2 changes: 1 addition & 1 deletion src/Api/PubnubApi/EndPoint/Files/SendFileOperation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ private async Task<PNResult<PNFileUploadResult>> ProcessFileUpload()
};
transportRequest.Headers.Add("Content-Type", contentType);
Tuple<string, PNStatus> jsonAndStatusTuple;
var transportResponse = await PubnubInstance.transportMiddleware.Send(transportRequest: transportRequest);
var transportResponse = await PubnubInstance.transportMiddleware.Send(transportRequest: transportRequest).ConfigureAwait(false);
if (transportResponse.StatusCode == 204 && transportResponse.Error == null)
{
var responseString = "{}";
Expand Down
35 changes: 23 additions & 12 deletions src/Api/PubnubApi/EndPoint/PubSub/SubscribeManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,14 @@ public SubscribeManager(PNConfiguration pubnubConfig, IJsonPluggableLibrary json
internal void MultiChannelUnSubscribeAll<T>(PNOperationType type, Dictionary<string, object> externalQueryParam)
{
//Retrieve the current channels already subscribed previously and terminate them
TerminateCurrentSubscriberRequest();
if (OngoingSubscriptionCancellationTokenSources.TryGetValue(PubnubInstance.InstanceId, out var tokenSource))
{
if (tokenSource != null)
{
IsCurrentSubscriptionCancellationRequested[PubnubInstance.InstanceId] = true;
TerminateCurrentSubscriberRequest();
}
}
string[] currentChannels = SubscriptionChannels.ContainsKey(PubnubInstance.InstanceId)
? SubscriptionChannels[PubnubInstance.InstanceId].Keys?.ToArray() ?? []
: [];
Expand All @@ -53,13 +60,18 @@ internal void MultiChannelUnSubscribeAll<T>(PNOperationType type, Dictionary<str
operationType: PNOperationType.Leave);
PubnubInstance.transportMiddleware.Send(transportRequest: leaveTransportRequest).ContinueWith(t =>
{
SubscriptionChannels[PubnubInstance.InstanceId]?.Clear();
SubscriptionChannelGroups[PubnubInstance.InstanceId]?.Clear();
try
{
SubscriptionChannels[PubnubInstance.InstanceId]?.Clear();
SubscriptionChannelGroups[PubnubInstance.InstanceId]?.Clear();
}
catch (Exception e)
{
logger?.Debug($"No subscription found.{e.Message}");
}
});
}

SubscriptionChannels[PubnubInstance.InstanceId]?.Clear();
SubscriptionChannelGroups[PubnubInstance.InstanceId]?.Clear();

TerminateCurrentSubscriberRequest();
TerminateReconnectTimer();
TerminatePresenceHeartbeatTimer();
Expand Down Expand Up @@ -294,15 +306,15 @@ internal void MultiChannelUnSubscribeInit<T>(PNOperationType type, string channe
catch (Exception ex)
{
logger?.Error(
$"At SubscribeManager.MultiChannelUnSubscribeInit() \n channel(s)={string.Join(",", validChannels.OrderBy(x => x).ToArray())} \n cg(s)={string.Join(",", validChannelGroups.OrderBy(x => x).ToArray())} \n Exception Details={ex}");
$"SubscribeManager.MultiChannelUnSubscribeInit() \n channel(s)={string.Join(",", validChannels.OrderBy(x => x).ToArray())} \n cg(s)={string.Join(",", validChannelGroups.OrderBy(x => x).ToArray())} \n Exception Details={ex}");
}
}

internal void MultiChannelSubscribeInit<T>(PNOperationType responseType, string[] rawChannels,
string[] rawChannelGroups, Dictionary<string, string> initialSubscribeUrlParams,
Dictionary<string, object> externalQueryParam)
{
logger?.Debug("INITIAL SUBSCRIBE REQUEST getting executed through MultiChannelSubscribeInit");
logger?.Trace("SubscribeManager: MultiChannelSubscribeInit() Invoked");
try
{
bool channelGroupSubscribeOnly = false;
Expand Down Expand Up @@ -355,8 +367,7 @@ internal void MultiChannelSubscribeInit<T>(PNOperationType responseType, string[
{
channelGroupSubscribeOnly = true;
}

logger?.Debug($"MultiChannelSubscribeRequest with tt=0");

MultiChannelSubscribeRequest<T>(responseType, channels, channelGroups, 0, 0, false,
initialSubscribeUrlParams, externalQueryParam);
if (SubscribeHeartbeatCheckTimer != null)
Expand Down Expand Up @@ -451,8 +462,7 @@ private void MultiChannelSubscribeRequest<T>(PNOperationType type, string[] chan
long lastTimetoken = LastSubscribeTimetoken.ContainsKey(PubnubInstance.InstanceId)
? LastSubscribeTimetoken[PubnubInstance.InstanceId]
: 0;
logger?.Trace(
$"Building request for channel(s)={multiChannel}, channelgroup(s)={multiChannelGroup} with timetoken={lastTimetoken}");
logger?.Trace($"Building request for channel(s)={multiChannel}, channelgroup(s)={multiChannelGroup} with timetoken={lastTimetoken}");
string channelsJsonState = BuildJsonUserState(channels, channelGroups, false);
config[PubnubInstance.InstanceId].UserId =
CurrentUserId[PubnubInstance.InstanceId]; // to make sure we capture if UUID is changed
Expand Down Expand Up @@ -486,6 +496,7 @@ private void MultiChannelSubscribeRequest<T>(PNOperationType type, string[] chan
{
networkConnection = true;
var json = Encoding.UTF8.GetString(transportResponse.Content);
logger?.Debug($"SubscribeManager received response: {json}");
pubnubRequestState.GotJsonResponse = true;
if (!string.IsNullOrEmpty(json))
{
Expand Down
16 changes: 9 additions & 7 deletions src/Api/PubnubApi/EndPoint/PubSub/SubscribeManager2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public async Task<Tuple<HandshakeResponse, PNStatus>> HandshakeRequest(PNOperati

if (transportResponse.StatusCode == Constants.HttpRequestSuccessStatusCode && transportResponse.Error == null && transportResponse.Content != null) {
var responseJson = Encoding.UTF8.GetString(transportResponse.Content);
logger?.Debug($"Handshake Effect received json: {responseJson}");
PNStatus status = new PNStatus(null, PNOperationType.PNSubscribeOperation, PNStatusCategory.PNConnectedCategory, channels, channelGroups);
HandshakeResponse handshakeResponse = jsonLibrary.DeserializeToObject<HandshakeResponse>(responseJson);
return new Tuple<HandshakeResponse, PNStatus>(handshakeResponse, status);
Expand All @@ -72,13 +73,13 @@ internal void HandshakeRequestCancellation()
cancellationTokenSource.Dispose();
} else
{
logger?.Trace($" SubscribeManager HandshakeRequestCancellation. No request to cancel.");
logger?.Trace($" SubscribeManager HandshakeRequestCancellation. No request to cancel.");
}

logger?.Trace($"SubscribeManager HandshakeRequestCancellation. Done.");
logger?.Trace($"SubscribeManager HandshakeRequestCancellation. Done.");
} catch (Exception ex)
{
logger?.Trace($" SubscribeManager HandshakeRequestCancellation Exception: {ex}");
logger?.Trace($" SubscribeManager HandshakeRequestCancellation Exception: {ex}");
}
}
internal async Task<Tuple<ReceivingResponse<object>, PNStatus>> ReceiveRequest<T>(PNOperationType responseType, string[] channels, string[] channelGroups, long? timetoken, int? region, Dictionary<string, string> initialSubscribeUrlParams, Dictionary<string, object> externalQueryParam)
Expand All @@ -102,6 +103,7 @@ internal async Task<Tuple<ReceivingResponse<object>, PNStatus>> ReceiveRequest<T
var transportResponse = await pubnubInstance.transportMiddleware.Send(transportRequest: transportRequest);
if (transportResponse.Content != null && transportResponse.Error == null && transportResponse.StatusCode == Constants.HttpRequestSuccessStatusCode) {
var responseJson = Encoding.UTF8.GetString(transportResponse.Content);
logger?.Debug($"Receiving Effect received json: {responseJson}");
PNStatus status = new PNStatus(null, PNOperationType.PNSubscribeOperation, PNStatusCategory.PNConnectedCategory, channels, channelGroups);
ReceivingResponse<object> receiveResponse = jsonLibrary.DeserializeToObject<ReceivingResponse<object>>(responseJson);
return new Tuple<ReceivingResponse<object>, PNStatus>(receiveResponse, status);
Expand All @@ -119,7 +121,7 @@ internal async Task<Tuple<ReceivingResponse<object>, PNStatus>> ReceiveRequest<T
} catch (Exception ex)
{
logger?.Error(
$" SubscribeManager=> MultiChannelSubscribeInit \n channel(s)={string.Join(",", channels.OrderBy(x => x).ToArray())} \n cg(s)={string.Join(",", channelGroups.OrderBy(x => x).ToArray())} \n Exception Details={ex}");
$" Receiving effect exception for \n channel(s)={string.Join(",", channels.OrderBy(x => x).ToArray())} \n cg(s)={string.Join(",", channelGroups.OrderBy(x => x).ToArray())} \n Exception Details={ex}");
}
return resp;
}
Expand All @@ -131,12 +133,12 @@ internal void ReceiveRequestCancellation()
cancellationTokenSource.Cancel();
cancellationTokenSource.Dispose();
} else {
logger?.Trace($"SubscribeManager RequestCancellation. No request to cancel.");
logger?.Trace($"SubscribeManager RequestCancellation. No request to cancel.");
}
logger?.Trace($"SubscribeManager ReceiveRequestCancellation. Done.");
logger?.Trace($"SubscribeManager ReceiveRequestCancellation. Done.");
} catch (Exception ex)
{
logger?.Trace($"SubscribeManager ReceiveRequestCancellation Exception: {ex}");
logger?.Trace($"SubscribeManager ReceiveRequestCancellation Exception: {ex}");
}
}

Expand Down
5 changes: 2 additions & 3 deletions src/Api/PubnubApi/EndPoint/PubSub/UnsubscribeOperation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ public IUnsubscribeOperation<T> QueryParam(Dictionary<string, object> customQuer

public void Execute()
{
logger?.Trace($"{GetType().Name} Execute invoked");
logger?.Debug($"PUBNUB Unsubscribe request Execute() received channels = {string.Join(", ", subscribeChannelNames)}");
logger?.Trace($"{GetType().Name} Execute invoked with channels = {string.Join(", ", subscribeChannelNames)}");
Unsubscribe(subscribeChannelNames, subscribeChannelGroupNames);
}

Expand All @@ -60,7 +59,7 @@ private void Unsubscribe(string[] channels, string[] channelGroups)
string channel = (channels != null) ? string.Join(",", channels.OrderBy(x => x).ToArray()) : "";
string channelGroup = (channelGroups != null) ? string.Join(",", channelGroups.OrderBy(x => x).ToArray()) : "";

logger?.Debug($"requested unsubscribe for channel(s)={channel}, cg(s)={channelGroup}");
logger?.Debug($"{GetType().Name} requested unsubscribe for channel(s)={channel}, cg(s)={channelGroup}");

SubscribeManager manager = new SubscribeManager(config, jsonLibrary, unit, pubnubTokenManager, PubnubInstance);
manager.CurrentPubnubInstance(PubnubInstance);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public async Task<PNResult<PNMessageCountResult>> ExecuteAsync()
throw new MissingMemberException("Invalid Subscribe Key");
}

return await MessageCounts(this.channelNames, this.timetokens, this.queryParam);
return await MessageCounts(this.channelNames, this.timetokens, this.queryParam).ConfigureAwait(false);
}

internal void Retry()
Expand Down
2 changes: 1 addition & 1 deletion src/Api/PubnubApi/EventEngine/Core/Engine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ private async void OnEvent(EventQueue q)
transitioning = true;
while (q.Count > 0)
{
await Transition(q.Dequeue());
await Transition(q.Dequeue()).ConfigureAwait(false);
}

transitioning = false;
Expand Down
2 changes: 1 addition & 1 deletion src/Api/PubnubApi/EventEngine/Core/EventQueue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public async Task Loop<T>(System.Func<IEvent, Task<T>> function)
{
while (Count > 0)
{
await function(Dequeue());
await function(Dequeue()).ConfigureAwait(false);
}
}

Expand Down
21 changes: 14 additions & 7 deletions src/Api/PubnubApi/JsonDataParse/EventDeserializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,10 @@ private PNPresenceEventResult DeserializePresenceEvent(IDictionary<string, objec
presenceEvent.Timestamp = presenceTimeStamp;
}

presenceEvent.Uuid = presenceDataFields["uuid"]?.ToString();
if (presenceDataFields.TryGetValue("uuid", out var uuidValue))
{
presenceEvent.Uuid = uuidValue?.ToString();
}

if (Int32.TryParse(presenceDataFields["occupancy"]?.ToString(), out var presenceOccupany))
{
Expand All @@ -79,16 +82,20 @@ private PNPresenceEventResult DeserializePresenceEvent(IDictionary<string, objec
presenceEvent.Timetoken = presenceTimetoken;
}

presenceEvent.Channel = jsonFields["channel"]?.ToString();
presenceEvent.Channel = presenceEvent.Channel?.Replace("-pnpres", "");
if (jsonFields.TryGetValue("channel", out var channelValue))
{
presenceEvent.Channel = channelValue?.ToString()?.Replace("-pnpres", "");
}

presenceEvent.Subscription = jsonFields["channelGroup"]?.ToString();
presenceEvent.Subscription = presenceEvent.Subscription?.Replace("-pnpres", "");
if (jsonFields.TryGetValue("channelGroup", out var subscriptionValue))
{
presenceEvent.Subscription = subscriptionValue?.ToString()?.Replace("-pnpres", "");
}


if (jsonFields["userMetadata"] != null)
if (jsonFields.TryGetValue("userMetadata", out object userMetadataValue))
{
presenceEvent.UserMetadata = jsonFields["userMetadata"];
presenceEvent.UserMetadata = userMetadataValue;
}

if (presenceEvent.Event != null && presenceEvent.Event.ToLowerInvariant() == "interval")
Expand Down
4 changes: 2 additions & 2 deletions src/Api/PubnubApi/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
[assembly: AssemblyProduct("Pubnub C# SDK")]
[assembly: AssemblyCopyright("Copyright © 2021")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyVersion("7.3.5.0")]
[assembly: AssemblyFileVersion("7.3.5.0")]
[assembly: AssemblyVersion("7.3.6.0")]
[assembly: AssemblyFileVersion("7.3.6.0")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
Expand Down
4 changes: 2 additions & 2 deletions src/Api/PubnubApi/PubnubApi.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@

<PropertyGroup>
<PackageId>Pubnub</PackageId>
<PackageVersion>7.3.5.0</PackageVersion>
<PackageVersion>7.3.6.0</PackageVersion>
<Title>PubNub C# .NET - Web Data Push API</Title>
<Authors>Pandu Masabathula</Authors>
<Owners>PubNub</Owners>
<PackageLicenseFile>LICENSE.txt</PackageLicenseFile>
<PackageIconUrl>http://pubnub.s3.amazonaws.com/2011/powered-by-pubnub/pubnub-icon-600x600.png</PackageIconUrl>
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
<RepositoryUrl>https://github.com/pubnub/c-sharp/</RepositoryUrl>
<PackageReleaseNotes>Standardize connection configuration to address inconsistent platform defaults leading to socket exhaustion under high load.</PackageReleaseNotes>
<PackageReleaseNotes>Reafctor: Removed excess logging from transport module. Removed redundant logging from transport layer and added thread id information for tracking http request.</PackageReleaseNotes>
<PackageTags>Web Data Push Real-time Notifications ESB Message Broadcasting Distributed Computing</PackageTags>
<!--<Summary>PubNub is a Massively Scalable Web Push Service for Web and Mobile Games. This is a cloud-based service for broadcasting messages to thousands of web and mobile clients simultaneously</Summary>-->
<Description>PubNub is a Massively Scalable Web Push Service for Web and Mobile Games. This is a cloud-based service for broadcasting messages to thousands of web and mobile clients simultaneously</Description>
Expand Down
Loading
Loading