Skip to content

Commit 6bdbbea

Browse files
authored
Port number fix (#124)
* fix * change
1 parent 33408b2 commit 6bdbbea

File tree

4 files changed

+8
-2
lines changed

4 files changed

+8
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
## xx.xx.x
22
- Request queue processing now is limited to 100 requests at a time
33
- Added 'setEventsToRQThreshold' method that sets the number of events after which all events will be sent to the RQ. Default value is set to 100.
4+
- Mitigated an issue where not providing a virtual port number (or providing a negative value) at the 'start' was causing SDK to assign a wrong port number.
45

56
## 22.09.1
67
- Mitigated a problem that caused invalid pointer error if the database path was set wrong

include/countly.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ class Countly : public cly::CountlyDelegates {
9090

9191
void setDeviceID(const std::string &value, bool same_user = false);
9292

93-
void start(const std::string &app_key, const std::string &host, int port = -1, bool start_thread = false);
93+
void start(const std::string &app_key, const std::string &host, int port = 0, bool start_thread = false);
9494

9595
void startOnCloud(const std::string &app_key);
9696

src/countly.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,11 @@ void Countly::start(const std::string &app_key, const std::string &host, int por
390390
enable_automatic_session = start_thread;
391391
start_thread = true;
392392

393+
if (port < 0 || port > 65535) {
394+
log(LogLevel::WARNING, "[Countly][start] Port number is out of valid boundaries. Setting it to 0.");
395+
port = 0;
396+
}
397+
393398
configuration->port = port;
394399
configuration->appKey = app_key;
395400
configuration->serverUrl = host;

tests/config.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ TEST_CASE("Validate setting configuration values") {
7676
ct.setMaxRequestQueueSize(10);
7777
ct.SetPath(TEST_DATABASE_NAME);
7878
ct.setMaxRQProcessingBatchSize(10);
79-
ct.start("YOUR_APP_KEY", "https://try.count.ly", 443, false);
79+
ct.start("YOUR_APP_KEY", "https://try.count.ly", -1, false);
8080

8181
// Get configuration values using Countly getters
8282
const CountlyConfiguration config = ct.getConfiguration();

0 commit comments

Comments
 (0)