diff --git a/OCPP-J/src/main/java/eu/chargetime/ocpp/JSONConfiguration.java b/OCPP-J/src/main/java/eu/chargetime/ocpp/JSONConfiguration.java index b6a67943e..859479775 100644 --- a/OCPP-J/src/main/java/eu/chargetime/ocpp/JSONConfiguration.java +++ b/OCPP-J/src/main/java/eu/chargetime/ocpp/JSONConfiguration.java @@ -36,7 +36,8 @@ public class JSONConfiguration { public static final String PING_INTERVAL_PARAMETER = "PING_INTERVAL"; public static final String USERNAME_PARAMETER = "USERNAME"; public static final String PASSWORD_PARAMETER = "PASSWORD"; - + public static final String CONNECTION_TIMEOUT_IN_MS = "CONNECTION_TIMEOUT_IN_MS"; + private final HashMap parameters = new HashMap<>(); private JSONConfiguration() {} diff --git a/OCPP-J/src/main/java/eu/chargetime/ocpp/WebSocketTransmitter.java b/OCPP-J/src/main/java/eu/chargetime/ocpp/WebSocketTransmitter.java index a3851a56a..29fca9b46 100644 --- a/OCPP-J/src/main/java/eu/chargetime/ocpp/WebSocketTransmitter.java +++ b/OCPP-J/src/main/java/eu/chargetime/ocpp/WebSocketTransmitter.java @@ -84,8 +84,10 @@ public void connect(String uri, RadioEvents events) { httpHeaders.put("Authorization", "Basic " + new String(base64Credentials)); } + long connectionTimeout = this.configuration.getParameter(JSONConfiguration.CONNECTION_TIMEOUT_IN_MS, 0); + client = - new WebSocketClient(resource, draft, httpHeaders) { + new WebSocketClient(resource, draft, httpHeaders, connectionTimeout) { @Override public void onOpen(ServerHandshake serverHandshake) { logger.debug("On connection open (HTTP status: {})", serverHandshake.getHttpStatus());