diff --git a/build b/build index d2e1cefe..7d373862 100644 --- a/build +++ b/build @@ -1 +1 @@ -44 \ No newline at end of file +45 \ No newline at end of file diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index 1d3cf8f8..6012347f 100755 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -75,6 +75,7 @@ if [[ "$TEMPLATE_CONFIG" = 'true' ]]; then STORAGE_TYPE_MYSQL_PORT=${STORAGE_TYPE_MYSQL_PORT:-"3306"} \ CERTIFICATES_ALLOWMISMATCH=${CERTIFICATES_ALLOWMISMATCH:-"false"} \ IPINFO_DEFAULT_COUNTRY=${IPINFO_DEFAULT_COUNTRY:-"US"} \ + DEVICE_SESSION_TIMEOUT=${DEVICE_SESSION_TIMEOUT:-"600"} \ envsubst < /owgw.properties.tmpl > $OWGW_CONFIG/owgw.properties fi diff --git a/owgw.properties.tmpl b/owgw.properties.tmpl index 69862421..fd9353c2 100644 --- a/owgw.properties.tmpl +++ b/owgw.properties.tmpl @@ -85,6 +85,7 @@ iptocountry.ipdata.apikey = ${IPTOCOUNTRY_IPDATA_APIKEY} autoprovisioning.process = ${AUTOPROVISIONING_PROCESS} +openwifi.session.timeout = ${DEVICE_SESSION_TIMEOUT} # # rtty # diff --git a/src/AP_WS_Server.cpp b/src/AP_WS_Server.cpp index bc5adaa0..e1ef48c4 100644 --- a/src/AP_WS_Server.cpp +++ b/src/AP_WS_Server.cpp @@ -55,6 +55,8 @@ namespace OpenWifi { MicroServiceConfigGetBool("openwifi.certificates.allowmismatch", true); MismatchDepth_ = MicroServiceConfigGetInt("openwifi.certificates.mismatchdepth", 2); + SessionTimeOut_ = MicroServiceConfigGetInt("openwifi.session.timeout", 10*60); + Reactor_pool_ = std::make_unique(); Reactor_pool_->Start(); @@ -188,8 +190,9 @@ namespace OpenWifi { while (hint != end(SerialNumbers_)) { if (hint->second.second == nullptr) { hint = SerialNumbers_.erase(hint); - } else if ((now - hint->second.second->State_.LastContact) > (10 * 60)) { + } else if ((now - hint->second.second->State_.LastContact) > SessionTimeOut_) { hint->second.second->EndConnection(false); + poco_information(Logger(),fmt::format("{}: Session seems idle. Controller disconnecting device.", hint->second.second->SerialNumber_)); Sessions_.erase(hint->second.second->State_.sessionId); Garbage_.push_back(hint->second.second); hint = SerialNumbers_.erase(hint); diff --git a/src/AP_WS_Server.h b/src/AP_WS_Server.h index 17d32414..83d24813 100644 --- a/src/AP_WS_Server.h +++ b/src/AP_WS_Server.h @@ -254,7 +254,7 @@ namespace OpenWifi { std::uint64_t NumberOfConnectedDevices_ = 0; std::uint64_t AverageDeviceConnectionTime_ = 0; std::uint64_t NumberOfConnectingDevices_ = 0; - + std::uint64_t SessionTimeOut_ = 10*60; mutable std::mutex StatsMutex_; std::atomic_uint64_t TX_=0,RX_=0;