Skip to content

armgit / core

Public Imported from GitHub
0

100% open-source IoT Platform - Integrate your devices, add intelligence, build custom apps

Improve HttpClientProtocol robustness

Rich Turnera8003bc3292f
diff --git a/agent/src/main/java/org/openremote/agent/protocol/http/HttpClientProtocol.java b/agent/src/main/java/org/openremote/agent/protocol/http/HttpClientProtocol.java
index a862e7a56..71037eb94 100644
--- a/agent/src/main/java/org/openremote/agent/protocol/http/HttpClientProtocol.java
+++ b/agent/src/main/java/org/openremote/agent/protocol/http/HttpClientProtocol.java
@@ -1122,13 +1122,17 @@ public class HttpClientProtocol extends AbstractProtocol {
LOG.fine("Scheduling polling request '" + clientRequest + "' to execute every " + pollingMillis + " ms for attribute: " + attributeRef);
return executorService.scheduleWithFixedDelay(() ->
- executePollingRequest(clientRequest, body, response ->
+ executePollingRequest(clientRequest, body, response -> {
+ try {
onPollingResponse(
- clientRequest,
- response,
- attributeRef,
- protocolConfigurationRef)
- ), 0, pollingMillis, TimeUnit.MILLISECONDS);
+ clientRequest,
+ response,
+ attributeRef,
+ protocolConfigurationRef);
+ } catch (Exception e) {
+ LOG.log(Level.WARNING, getProtocolDisplayName() + " exception thrown whilst processing polling response [" + (e.getCause() != null ? e.getCause().getMessage() : e.getMessage()) + "]: " + clientRequest.requestTarget.getUriBuilder().build().toString());
+ }
+ }), 0, pollingMillis, TimeUnit.MILLISECONDS);
}
protected void executePollingRequest(HttpClientRequest clientRequest, String body, Consumer<Response> responseConsumer) {