diff --git a/CHANGELOG.md b/CHANGELOG.md index 52dd4a2..7aead8d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ ## xx.xx.x - Request queue processing now is limited to 100 requests at a time - 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. +- 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. ## 22.09.1 - Mitigated a problem that caused invalid pointer error if the database path was set wrong diff --git a/include/countly.hpp b/include/countly.hpp index 5588b7d..9c95583 100644 --- a/include/countly.hpp +++ b/include/countly.hpp @@ -90,7 +90,7 @@ class Countly : public cly::CountlyDelegates { void setDeviceID(const std::string &value, bool same_user = false); - void start(const std::string &app_key, const std::string &host, int port = -1, bool start_thread = false); + void start(const std::string &app_key, const std::string &host, int port = 0, bool start_thread = false); void startOnCloud(const std::string &app_key); diff --git a/src/countly.cpp b/src/countly.cpp index fe1dc0d..bb2188f 100644 --- a/src/countly.cpp +++ b/src/countly.cpp @@ -390,6 +390,11 @@ void Countly::start(const std::string &app_key, const std::string &host, int por enable_automatic_session = start_thread; start_thread = true; + if (port < 0 || port > 65535) { + log(LogLevel::WARNING, "[Countly][start] Port number is out of valid boundaries. Setting it to 0."); + port = 0; + } + configuration->port = port; configuration->appKey = app_key; configuration->serverUrl = host; diff --git a/tests/config.cpp b/tests/config.cpp index 2840ca5..8949dff 100644 --- a/tests/config.cpp +++ b/tests/config.cpp @@ -76,7 +76,7 @@ TEST_CASE("Validate setting configuration values") { ct.setMaxRequestQueueSize(10); ct.SetPath(TEST_DATABASE_NAME); ct.setMaxRQProcessingBatchSize(10); - ct.start("YOUR_APP_KEY", "https://try.count.ly", 443, false); + ct.start("YOUR_APP_KEY", "https://try.count.ly", -1, false); // Get configuration values using Countly getters const CountlyConfiguration config = ct.getConfiguration();