properly test for and report HTTP connection errors
@@ -152,13 +152,13 @@ void WSClient::test_token(const String server_address, const uint16_t server_por
WiFiClient client;
HTTPClient http;
- debugD("Testing token");
-
String url = String("http://") + server_address + ":" + server_port + "/signalk/v1/api/";
+ debugD("Testing token with url %s", url.c_str());
http.begin(client, url);
String full_token = String("JWT ") + auth_token;
http.addHeader("Authorization", full_token.c_str());
int httpCode = http.GET();
+ if (httpCode > 0) {
String payload = http.getString();
http.end();
debugD("Testing resulted in http status %d", httpCode);
@@ -172,6 +172,10 @@ void WSClient::test_token(const String server_address, const uint16_t server_por
} else {
connection_state = disconnected;
}
+ } else {
+ debugE("GET... failed, error: %s\n", http.errorToString(httpCode).c_str());
+ connection_state = disconnected;
+ }
}
void WSClient::send_access_request(const String server_address, const uint16_t server_port) {
