Skip to content

HTTP client failed/timeout to establish connection to airgradient server #282

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Feb 5, 2025
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
6 changes: 4 additions & 2 deletions src/AgApiClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ bool AgApiClient::fetchServerConfiguration(void) {
}
#else
HTTPClient client;
client.setTimeout(timeoutMs);
client.setConnectTimeout(timeoutMs); // Set timeout when establishing connection to server
client.setTimeout(timeoutMs); // Timeout when waiting for response from AG server
if (apiRootChanged) {
// If apiRoot is changed, assume not using https
if (client.begin(uri) == false) {
Expand Down Expand Up @@ -133,7 +134,8 @@ bool AgApiClient::postToServer(String data) {
}
#else
HTTPClient client;
client.setTimeout(timeoutMs);
client.setConnectTimeout(timeoutMs); // Set timeout when establishing connection to server
client.setTimeout(timeoutMs); // Timeout when waiting for response from AG server
if (apiRootChanged) {
// If apiRoot is changed, assume not using https
if (client.begin(uri) == false) {
Expand Down
2 changes: 1 addition & 1 deletion src/AgApiClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class AgApiClient : public PrintLog {
bool getConfigFailed;
bool postToServerFailed;
bool notAvailableOnDashboard = false; // Device not setup on Airgradient cloud dashboard.
uint16_t timeoutMs = 10000; // Default set to 10s
uint16_t timeoutMs = 15000; // Default set to 15s

public:
AgApiClient(Stream &stream, Configuration &config);
Expand Down