* All messages received from the remote peer are strings only, but may be JSON formatted.
@@ -56,12 +54,13 @@
*/
public class WebSocketClientService {
-
private StompSession stompSession;
private Runnable connectCallback;
private Runnable disconnectCallback;
private final List
- *
+ * Called if connection fails or if connection is lost (e.g. remote service is terminated).
*
* @param session the client STOMP session
- * @param exception the exception that occurred. This is evaluated to determine if a reconnection
- * thread should be launched.
+ * @param exception the exception that occurred.
*/
@Override
public void handleTransportError(StompSession session, Throwable exception) {
- if(exception instanceof DeploymentException){
- logger.log(Level.WARNING, "Unable to connect", exception);
+ logger.log(Level.WARNING, "Connection failed or lost, will attempt to reconnect", exception);
+ if (disconnectCallback != null && exception instanceof ConnectionLostException) {
+ disconnectCallback.run();
}
- else {
- logger.log(Level.WARNING, "Connection lost, will attempt to reconnect", exception);
- if (exception instanceof ConnectionLostException && disconnectCallback != null) {
- disconnectCallback.run();
- }
+ try {
+ Thread.sleep(10000);
connect();
+ } catch (InterruptedException e) {
+ logger.log(Level.WARNING, "Sleep interrupted", e);
}
}
}
@@ -268,7 +235,7 @@ public static boolean checkAvailability(String webSocketConnectUrl) {
WebSocketClient webSocketClient = new StandardWebSocketClient();
WebSocketStompClient stompClient = new WebSocketStompClient(webSocketClient);
try {
- StompSession stompSession = stompClient.connect(webSocketConnectUrl, new StompSessionHandlerAdapter() {
+ StompSession stompSession = stompClient.connectAsync(webSocketConnectUrl, new StompSessionHandlerAdapter() {
@Override
public Type getPayloadType(StompHeaders headers) {
return super.getPayloadType(headers);
@@ -277,7 +244,7 @@ public Type getPayloadType(StompHeaders headers) {
stompSession.disconnect();
return true;
} catch (Exception e) {
- logger.log(Level.WARNING, "Remote service on " + webSocketConnectUrl + " does not support web socket connection", e);
+ logger.log(Level.WARNING, "Remote service on " + webSocketConnectUrl + " does not support web socket connection on url " + webSocketConnectUrl, e);
}
return false;
}
diff --git a/dependencies/phoebus-target/pom.xml b/dependencies/phoebus-target/pom.xml
index fe2b7ba830..f8620edd50 100644
--- a/dependencies/phoebus-target/pom.xml
+++ b/dependencies/phoebus-target/pom.xml
@@ -223,26 +223,20 @@
null.
*/
public ESTreeNode getParentNode(String uniqueId) {
- Builder bqb = new Builder();
- bqb.must(TermQuery.of(w -> w.field("childNodes").value(uniqueId))._toQuery());
- SearchRequest searchRequest = SearchRequest.of(s -> s.index(ES_TREE_INDEX)
- .query(bqb.build()._toQuery())
- .timeout("60s"));
try {
- SearchResponse