Skip to content

Commit 049f5c5

Browse files
authored
Change subscribe session settings (#130)
refactor(subscribe): change subscribe session settings Change settings for subscribe `URLSession` and limit number of concurrent connections per host. refactor(presence): presence leave on subscribe session Call presence leave using subscribe `URLSession` to avoid potential presence race of condition.
1 parent f28fe7b commit 049f5c5

File tree

14 files changed

+67
-45
lines changed

14 files changed

+67
-45
lines changed

.pubnub.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
11
---
22
name: swift
33
scm: github.com/pubnub/swift
4-
version: "6.0.3"
4+
version: "6.0.4"
55
schema: 1
66
changelog:
7+
- date: 2023-03-16
8+
version: 6.0.4
9+
changes:
10+
- type: improvement
11+
text: "Change the settings for subscribe `URLSession` and limit the number of concurrent connections per host."
12+
- type: improvement
13+
text: "Call presence leave using subscribe `URLSession` to avoid potential presence race of condition."
714
- date: 2023-01-04
815
version: 6.0.3
916
changes:
@@ -473,7 +480,7 @@ sdks:
473480
- distribution-type: source
474481
distribution-repository: GitHub release
475482
package-name: PubNub
476-
location: https://github.com/pubnub/swift/archive/refs/tags/6.0.3.zip
483+
location: https://github.com/pubnub/swift/archive/refs/tags/6.0.4.zip
477484
supported-platforms:
478485
supported-operating-systems:
479486
macOS:

PubNub.xcodeproj/project.pbxproj

Lines changed: 33 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@
134134
3558068A230F4C99005CDD92 /* InstanceIdOperatorTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 35580687230F4B75005CDD92 /* InstanceIdOperatorTests.swift */; };
135135
3558069A2311F968005CDD92 /* SubscriptionStreamTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 355806992311F968005CDD92 /* SubscriptionStreamTests.swift */; };
136136
3558069C231303D9005CDD92 /* AutomaticRetryTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3558069B231303D9005CDD92 /* AutomaticRetryTests.swift */; };
137-
355806DB23145749005CDD92 /* PubNub.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = PubNub::PubNub::Product /* PubNub.framework */; };
137+
355806DB23145749005CDD92 /* PubNub.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = "PubNub::PubNub::Product" /* PubNub.framework */; };
138138
3559977B23073D53000BCFD1 /* WeakBoxTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3559977A23073D53000BCFD1 /* WeakBoxTests.swift */; };
139139
3559977F23078A7C000BCFD1 /* message_counts_error_invalid_arguments.json in Resources */ = {isa = PBXBuildFile; fileRef = 3559977E230787E7000BCFD1 /* message_counts_error_invalid_arguments.json */; };
140140
3559978223079070000BCFD1 /* forbidden_Message.json in Resources */ = {isa = PBXBuildFile; fileRef = 3559978023078F85000BCFD1 /* forbidden_Message.json */; };
@@ -398,9 +398,9 @@
398398
79407BE5271D4CFA0032076C /* PubNubFilesContractTestSteps.swift in Sources */ = {isa = PBXBuildFile; fileRef = 79407BD1271D4CFA0032076C /* PubNubFilesContractTestSteps.swift */; };
399399
79407C00271D519F0032076C /* Features in Resources */ = {isa = PBXBuildFile; fileRef = 79407BFF271D519F0032076C /* Features */; };
400400
79407C01271D519F0032076C /* Features in Resources */ = {isa = PBXBuildFile; fileRef = 79407BFF271D519F0032076C /* Features */; };
401-
7941EEA9270E433F0054D9EF /* PubNub.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = PubNub::PubNub::Product /* PubNub.framework */; platformFilter = ios; };
401+
7941EEA9270E433F0054D9EF /* PubNub.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = "PubNub::PubNub::Product" /* PubNub.framework */; platformFilter = ios; };
402402
7951954E26C955CE001E308C /* PAMToken.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7951954D26C955CE001E308C /* PAMToken.swift */; };
403-
79657AA3271A13F700BACEC5 /* PubNub.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = PubNub::PubNub::Product /* PubNub.framework */; platformFilter = ios; };
403+
79657AA3271A13F700BACEC5 /* PubNub.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = "PubNub::PubNub::Product" /* PubNub.framework */; platformFilter = ios; };
404404
A5115F2529195AF400F6ADA1 /* PubNubObjectsMembersContractTestSteps.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5115F2429195AF400F6ADA1 /* PubNubObjectsMembersContractTestSteps.swift */; };
405405
A5115F2629195AF400F6ADA1 /* PubNubObjectsMembersContractTestSteps.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5115F2429195AF400F6ADA1 /* PubNubObjectsMembersContractTestSteps.swift */; };
406406
A5115F28291D54F500F6ADA1 /* PubNubObjectsMembershipsContractTestSteps.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5115F27291D54F500F6ADA1 /* PubNubObjectsMembershipsContractTestSteps.swift */; };
@@ -411,12 +411,13 @@
411411
A56445F02906AFF40085B310 /* PubNubObjectsTestHelpers.swift in Sources */ = {isa = PBXBuildFile; fileRef = A56445EE2906AFF40085B310 /* PubNubObjectsTestHelpers.swift */; };
412412
A56445F22907D9FD0085B310 /* PubNubObjectsChannelMetadataContractTestSteps.swift in Sources */ = {isa = PBXBuildFile; fileRef = A56445F12907D9FD0085B310 /* PubNubObjectsChannelMetadataContractTestSteps.swift */; };
413413
A56445F32907D9FD0085B310 /* PubNubObjectsChannelMetadataContractTestSteps.swift in Sources */ = {isa = PBXBuildFile; fileRef = A56445F12907D9FD0085B310 /* PubNubObjectsChannelMetadataContractTestSteps.swift */; };
414+
A5A574D429C309750065D333 /* leave_success.json in Resources */ = {isa = PBXBuildFile; fileRef = A5A574D329C309750065D333 /* leave_success.json */; };
414415
A5F19EE329126D8200F185A9 /* PubNubObjectsUUIDMetadataContractTestSteps.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5F19EE229126D8200F185A9 /* PubNubObjectsUUIDMetadataContractTestSteps.swift */; };
415416
A5F19EE429126D8200F185A9 /* PubNubObjectsUUIDMetadataContractTestSteps.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5F19EE229126D8200F185A9 /* PubNubObjectsUUIDMetadataContractTestSteps.swift */; };
416417
D2635DFB22FCCF080097CF64 /* message_counts_success.json in Resources */ = {isa = PBXBuildFile; fileRef = D2635DFA22FCCF080097CF64 /* message_counts_success.json */; };
417418
OBJ_31 /* PubNub.swift in Sources */ = {isa = PBXBuildFile; fileRef = OBJ_11 /* PubNub.swift */; };
418419
OBJ_49 /* PubNubTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = OBJ_15 /* PubNubTests.swift */; };
419-
OBJ_51 /* PubNub.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = PubNub::PubNub::Product /* PubNub.framework */; };
420+
OBJ_51 /* PubNub.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = "PubNub::PubNub::Product" /* PubNub.framework */; };
420421
/* End PBXBuildFile section */
421422

422423
/* Begin PBXContainerItemProxy section */
@@ -919,6 +920,7 @@
919920
A5115F2A291D5C2700F6ADA1 /* PubNubObjectsContractTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PubNubObjectsContractTests.swift; sourceTree = "<group>"; };
920921
A56445EE2906AFF40085B310 /* PubNubObjectsTestHelpers.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PubNubObjectsTestHelpers.swift; sourceTree = "<group>"; };
921922
A56445F12907D9FD0085B310 /* PubNubObjectsChannelMetadataContractTestSteps.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PubNubObjectsChannelMetadataContractTestSteps.swift; sourceTree = "<group>"; };
923+
A5A574D329C309750065D333 /* leave_success.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = leave_success.json; sourceTree = "<group>"; };
922924
A5F19EE229126D8200F185A9 /* PubNubObjectsUUIDMetadataContractTestSteps.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PubNubObjectsUUIDMetadataContractTestSteps.swift; sourceTree = "<group>"; };
923925
D2635DFA22FCCF080097CF64 /* message_counts_success.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = message_counts_success.json; sourceTree = "<group>"; };
924926
OBJ_11 /* PubNub.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PubNub.swift; sourceTree = "<group>"; };
@@ -928,8 +930,8 @@
928930
OBJ_24 /* PubNubSwift.podspec */ = {isa = PBXFileReference; explicitFileType = text.script.ruby; path = PubNubSwift.podspec; sourceTree = "<group>"; };
929931
OBJ_6 /* Package.swift */ = {isa = PBXFileReference; explicitFileType = sourcecode.swift; path = Package.swift; sourceTree = "<group>"; };
930932
OBJ_9 /* PubNub.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PubNub.h; sourceTree = "<group>"; };
931-
PubNub::PubNub::Product /* PubNub.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = PubNub.framework; sourceTree = BUILT_PRODUCTS_DIR; };
932-
PubNub::PubNubTests::Product /* PubNubTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; path = PubNubTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
933+
"PubNub::PubNub::Product" /* PubNub.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = PubNub.framework; sourceTree = BUILT_PRODUCTS_DIR; };
934+
"PubNub::PubNubTests::Product" /* PubNubTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; path = PubNubTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
933935
/* End PBXFileReference section */
934936

935937
/* Begin PBXFrameworksBuildPhase section */
@@ -1566,6 +1568,7 @@
15661568
children = (
15671569
35A66A8B22F9080A00AC67A9 /* getState_success.json */,
15681570
35E71C39249027120032A991 /* getState_single_success.json */,
1571+
A5A574D329C309750065D333 /* leave_success.json */,
15691572
35A66A8C22F9084000AC67A9 /* setState_success.json */,
15701573
35A66A9522F9B71200AC67A9 /* setState_missing_state.json */,
15711574
35A6C78022FB2E4C00E97CC5 /* herenow_success.json */,
@@ -2034,8 +2037,8 @@
20342037
OBJ_17 /* Products */ = {
20352038
isa = PBXGroup;
20362039
children = (
2037-
PubNub::PubNubTests::Product /* PubNubTests.xctest */,
2038-
PubNub::PubNub::Product /* PubNub.framework */,
2040+
"PubNub::PubNubTests::Product" /* PubNubTests.xctest */,
2041+
"PubNub::PubNub::Product" /* PubNub.framework */,
20392042
3558073723145749005CDD92 /* PubNubIntTests.xctest */,
20402043
7941EF40270E433F0054D9EF /* PubNubContractTests.xctest */,
20412044
79657AAB271A13F700BACEC5 /* PubNubContractTestsBeta.xctest */,
@@ -2336,7 +2339,7 @@
23362339
productReference = 79657AAB271A13F700BACEC5 /* PubNubContractTestsBeta.xctest */;
23372340
productType = "com.apple.product-type.bundle.unit-test";
23382341
};
2339-
PubNub::PubNub /* PubNub */ = {
2342+
"PubNub::PubNub" /* PubNub */ = {
23402343
isa = PBXNativeTarget;
23412344
buildConfigurationList = OBJ_27 /* Build configuration list for PBXNativeTarget "PubNub" */;
23422345
buildPhases = (
@@ -2349,10 +2352,10 @@
23492352
);
23502353
name = PubNub;
23512354
productName = PubNub;
2352-
productReference = PubNub::PubNub::Product /* PubNub.framework */;
2355+
productReference = "PubNub::PubNub::Product" /* PubNub.framework */;
23532356
productType = "com.apple.product-type.framework";
23542357
};
2355-
PubNub::PubNubTests /* PubNubTests */ = {
2358+
"PubNub::PubNubTests" /* PubNubTests */ = {
23562359
isa = PBXNativeTarget;
23572360
buildConfigurationList = OBJ_45 /* Build configuration list for PBXNativeTarget "PubNubTests" */;
23582361
buildPhases = (
@@ -2367,7 +2370,7 @@
23672370
);
23682371
name = PubNubTests;
23692372
productName = PubNubTests;
2370-
productReference = PubNub::PubNubTests::Product /* PubNubTests.xctest */;
2373+
productReference = "PubNub::PubNubTests::Product" /* PubNubTests.xctest */;
23712374
productType = "com.apple.product-type.bundle.unit-test";
23722375
};
23732376
/* End PBXNativeTarget section */
@@ -2420,8 +2423,8 @@
24202423
projectDirPath = "";
24212424
projectRoot = "";
24222425
targets = (
2423-
PubNub::PubNub /* PubNub */,
2424-
PubNub::PubNubTests /* PubNubTests */,
2426+
"PubNub::PubNub" /* PubNub */,
2427+
"PubNub::PubNubTests" /* PubNubTests */,
24252428
7941EE6B270E433F0054D9EF /* PubNubContractTests */,
24262429
79657A93271A13F700BACEC5 /* PubNubContractTestsBeta */,
24272430
3558069D23145749005CDD92 /* PubNubIntegration */,
@@ -2577,6 +2580,7 @@
25772580
35FE93EA22EF93A90051C455 /* cannotConnectToHost.json in Resources */,
25782581
35FE93E622EF93A90051C455 /* secureConnectionFailed.json in Resources */,
25792582
35A6C7B322FBD9D200E97CC5 /* push_remove_all_success.json in Resources */,
2583+
A5A574D429C309750065D333 /* leave_success.json in Resources */,
25802584
350BC40F233952F400011262 /* objects_uuid_all_success_empty.json in Resources */,
25812585
35293AA8236B6C5D0049A71F /* removeMessageAction_error_400_noMessage.json in Resources */,
25822586
35FE93EE22EF93A90051C455 /* unsupportedURL.json in Resources */,
@@ -3061,7 +3065,7 @@
30613065
/* Begin PBXTargetDependency section */
30623066
3558069E23145749005CDD92 /* PBXTargetDependency */ = {
30633067
isa = PBXTargetDependency;
3064-
target = PubNub::PubNub /* PubNub */;
3068+
target = "PubNub::PubNub" /* PubNub */;
30653069
targetProxy = 3558069F23145749005CDD92 /* PBXContainerItemProxy */;
30663070
};
30673071
358B8917284D206B00DB0F3D /* PBXTargetDependency */ = {
@@ -3081,17 +3085,17 @@
30813085
};
30823086
358B8962284D22B100DB0F3D /* PBXTargetDependency */ = {
30833087
isa = PBXTargetDependency;
3084-
target = PubNub::PubNub /* PubNub */;
3088+
target = "PubNub::PubNub" /* PubNub */;
30853089
targetProxy = 358B8961284D22B100DB0F3D /* PBXContainerItemProxy */;
30863090
};
30873091
358B8966284D22D800DB0F3D /* PBXTargetDependency */ = {
30883092
isa = PBXTargetDependency;
3089-
target = PubNub::PubNub /* PubNub */;
3093+
target = "PubNub::PubNub" /* PubNub */;
30903094
targetProxy = 358B8965284D22D800DB0F3D /* PBXContainerItemProxy */;
30913095
};
30923096
358B8968284D22E200DB0F3D /* PBXTargetDependency */ = {
30933097
isa = PBXTargetDependency;
3094-
target = PubNub::PubNub /* PubNub */;
3098+
target = "PubNub::PubNub" /* PubNub */;
30953099
targetProxy = 358B8967284D22E200DB0F3D /* PBXContainerItemProxy */;
30963100
};
30973101
358B896A284D22E200DB0F3D /* PBXTargetDependency */ = {
@@ -3122,18 +3126,18 @@
31223126
7941EE6C270E433F0054D9EF /* PBXTargetDependency */ = {
31233127
isa = PBXTargetDependency;
31243128
platformFilter = ios;
3125-
target = PubNub::PubNub /* PubNub */;
3129+
target = "PubNub::PubNub" /* PubNub */;
31263130
targetProxy = 7941EE6D270E433F0054D9EF /* PBXContainerItemProxy */;
31273131
};
31283132
79657A94271A13F700BACEC5 /* PBXTargetDependency */ = {
31293133
isa = PBXTargetDependency;
31303134
platformFilter = ios;
3131-
target = PubNub::PubNub /* PubNub */;
3135+
target = "PubNub::PubNub" /* PubNub */;
31323136
targetProxy = 79657A95271A13F700BACEC5 /* PBXContainerItemProxy */;
31333137
};
31343138
OBJ_52 /* PBXTargetDependency */ = {
31353139
isa = PBXTargetDependency;
3136-
target = PubNub::PubNub /* PubNub */;
3140+
target = "PubNub::PubNub" /* PubNub */;
31373141
targetProxy = 35EA73F422B1916100D97BF0 /* PBXContainerItemProxy */;
31383142
};
31393143
/* End PBXTargetDependency section */
@@ -3240,7 +3244,7 @@
32403244
"@executable_path/Frameworks",
32413245
"@loader_path/Frameworks",
32423246
);
3243-
MARKETING_VERSION = 6.0.3;
3247+
MARKETING_VERSION = 6.0.4;
32443248
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
32453249
MTL_FAST_MATH = YES;
32463250
PRODUCT_BUNDLE_IDENTIFIER = com.pubnub.swift.PubNubUser;
@@ -3287,7 +3291,7 @@
32873291
"@executable_path/Frameworks",
32883292
"@loader_path/Frameworks",
32893293
);
3290-
MARKETING_VERSION = 6.0.3;
3294+
MARKETING_VERSION = 6.0.4;
32913295
MTL_ENABLE_DEBUG_INFO = NO;
32923296
MTL_FAST_MATH = YES;
32933297
PRODUCT_BUNDLE_IDENTIFIER = com.pubnub.swift.PubNubUser;
@@ -3387,7 +3391,7 @@
33873391
"@executable_path/Frameworks",
33883392
"@loader_path/Frameworks",
33893393
);
3390-
MARKETING_VERSION = 6.0.3;
3394+
MARKETING_VERSION = 6.0.4;
33913395
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
33923396
MTL_FAST_MATH = YES;
33933397
PRODUCT_BUNDLE_IDENTIFIER = com.pubnub.swift.PubNubSpace;
@@ -3436,7 +3440,7 @@
34363440
"@executable_path/Frameworks",
34373441
"@loader_path/Frameworks",
34383442
);
3439-
MARKETING_VERSION = 6.0.3;
3443+
MARKETING_VERSION = 6.0.4;
34403444
MTL_ENABLE_DEBUG_INFO = NO;
34413445
MTL_FAST_MATH = YES;
34423446
PRODUCT_BUNDLE_IDENTIFIER = com.pubnub.swift.PubNubSpace;
@@ -3549,7 +3553,7 @@
35493553
"@executable_path/Frameworks",
35503554
"@loader_path/Frameworks",
35513555
);
3552-
MARKETING_VERSION = 6.0.3;
3556+
MARKETING_VERSION = 6.0.4;
35533557
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
35543558
MTL_FAST_MATH = YES;
35553559
PRODUCT_BUNDLE_IDENTIFIER = com.pubnub.swift.PubNubMembership;
@@ -3597,7 +3601,7 @@
35973601
"@executable_path/Frameworks",
35983602
"@loader_path/Frameworks",
35993603
);
3600-
MARKETING_VERSION = 6.0.3;
3604+
MARKETING_VERSION = 6.0.4;
36013605
MTL_ENABLE_DEBUG_INFO = NO;
36023606
MTL_FAST_MATH = YES;
36033607
PRODUCT_BUNDLE_IDENTIFIER = com.pubnub.swift.PubNubMembership;
@@ -4053,7 +4057,7 @@
40534057
"$(inherited)",
40544058
"$(TOOLCHAIN_DIR)/usr/lib/swift/macosx",
40554059
);
4056-
MARKETING_VERSION = 6.0.3;
4060+
MARKETING_VERSION = 6.0.4;
40574061
OTHER_CFLAGS = "$(inherited)";
40584062
OTHER_LDFLAGS = "$(inherited)";
40594063
OTHER_SWIFT_FLAGS = "$(inherited)";
@@ -4092,7 +4096,7 @@
40924096
"$(inherited)",
40934097
"$(TOOLCHAIN_DIR)/usr/lib/swift/macosx",
40944098
);
4095-
MARKETING_VERSION = 6.0.3;
4099+
MARKETING_VERSION = 6.0.4;
40964100
OTHER_CFLAGS = "$(inherited)";
40974101
OTHER_LDFLAGS = "$(inherited)";
40984102
OTHER_SWIFT_FLAGS = "$(inherited)";

PubNubSwift.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = 'PubNubSwift'
3-
s.version = '6.0.3'
3+
s.version = '6.0.4'
44
s.homepage = 'https://github.com/pubnub/swift'
55
s.documentation_url = 'https://www.pubnub.com/docs/swift-native/pubnub-swift-sdk'
66
s.authors = { 'PubNub, Inc.' => '[email protected]' }

Sources/PubNub/Errors/ErrorDescription.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,8 @@ extension PubNubError.Reason: CustomStringConvertible, LocalizedError {
179179
return "The request was cancelled by the system/user without error"
180180
case .longPollingRestart:
181181
return "The long polling request needed to be cancelled to restart with new data"
182+
case .longPollingReset:
183+
return "The long polling request needed to be cancelled because the client unsubscribed from all channels and groups."
182184
case .timedOut:
183185
return "An asynchronous operation timed out"
184186
case .nameResolutionFailure:

Sources/PubNub/Errors/PubNubError.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ public struct PubNubError: Error {
130130
case sessionInvalidated
131131
case clientCancelled
132132
case longPollingRestart
133+
case longPollingReset
133134

134135
// Response Received
135136
case badServerResponse
@@ -210,7 +211,7 @@ public struct PubNubError: Error {
210211
.secureConnectionFailure, .certificateTrustFailure, .backgroundUpdatesDisabled,
211212
.backgroundInsufficientResources, .backgroundUserForceQuitApplication:
212213
return .requestTransmission
213-
case .clientCancelled, .sessionDeinitialized, .sessionInvalidated, .longPollingRestart:
214+
case .clientCancelled, .sessionDeinitialized, .sessionInvalidated, .longPollingRestart, .longPollingReset:
214215
return .cancellation
215216
case .badServerResponse, .responseDecodingFailure, .dataLengthExceedsMaximum:
216217
return .responseReceiving

Sources/PubNub/Extensions/URLSessionConfiguration+PubNub.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ public extension URLSessionConfiguration {
6666
static var subscription: URLSessionConfiguration {
6767
let configuration = URLSessionConfiguration.pubnub
6868
configuration.timeoutIntervalForRequest += Constant.minimumSubscribeRequestTimeout
69+
configuration.httpMaximumConnectionsPerHost = 1;
6970

7071
return configuration
7172
}

Sources/PubNub/Helpers/Constants.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public enum Constant {
5757

5858
static let pubnubSwiftSDKName: String = "PubNubSwift"
5959

60-
static let pubnubSwiftSDKVersion: String = "6.0.3"
60+
static let pubnubSwiftSDKVersion: String = "6.0.4"
6161

6262
static let appBundleId: String = {
6363
if let info = Bundle.main.infoDictionary,

Sources/PubNub/Subscription/SubscriptionSession+Presence.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ extension SubscriptionSession {
9898
) {
9999
let router = PresenceRouter(.leave(channels: channels, groups: groups), configuration: configuration)
100100

101-
nonSubscribeSession
101+
longPollingSession
102102
.request(with: router, requestOperator: configuration.automaticRetry)
103103
.validate()
104104
.response(on: .main, decoder: GenericServiceResponseDecoder()) { result in

Sources/PubNub/Subscription/SubscriptionSession.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,8 @@ public class SubscriptionSession {
318318
)
319319
}
320320

321-
if error.pubNubError?.reason == .clientCancelled || error.pubNubError?.reason == .longPollingRestart {
321+
if error.pubNubError?.reason == .clientCancelled || error.pubNubError?.reason == .longPollingRestart ||
322+
error.pubNubError?.reason == .longPollingReset {
322323
if self?.subscriptionCount == 0 {
323324
self?.connectionStatus = .disconnected
324325
} else if self?.request?.requestID == currentSubscribeID {
@@ -388,6 +389,9 @@ public class SubscriptionSession {
388389
notify {
389390
$0.emit(subscribe: .subscriptionChanged(subscribeChange))
390391
}
392+
// Cancel previous subscribe request.
393+
stopSubscribeLoop(.longPollingReset)
394+
391395
// Call unsubscribe to cleanup remaining state items
392396
unsubscribeCleanup(subscribeChange: subscribeChange)
393397
}

0 commit comments

Comments
 (0)