@Override public void stop() { if (!this.externallyManaged) { try { this.jettyClient.stop(); } catch (Exception ex) { throw new IllegalStateException("Error stopping Jetty WebSocketClient", ex); } } }
@Override public void stop() { try { this.client.stop(); } catch (Exception ex) { logger.error("Failed to stop Jetty WebSocketClient", ex); } }
@Override public void disconnect() throws IOException { if ( client != null ) { try { client.stop(); } catch ( Exception e ) { throw new IOException( e ); } } }
@OnDisabled @OnShutdown @Override public void stopClient() throws Exception { activeSessions.clear(); if (sessionMaintenanceScheduler != null) { try { sessionMaintenanceScheduler.shutdown(); } catch (Exception e) { getLogger().warn("Failed to shutdown session maintainer due to {}", new Object[]{e}, e); } sessionMaintenanceScheduler = null; } if (client == null) { return; } client.stop(); client = null; }
public Session connect(AgentWebSocketClientController controller) throws Exception { if (webSocketClient == null || !webSocketClient.isRunning()) { if (webSocketClient != null) { webSocketClient.stop(); } webSocketClient = builder.build(); webSocketClient.start(); } LOG.info("Connecting to websocket endpoint: {}", urlService.getAgentRemoteWebSocketUrl()); ClientUpgradeRequest request = new ClientUpgradeRequest(); request.addExtensions("fragment;maxLength=" + getMessageBufferSize()); return webSocketClient.connect(controller, new URI(urlService.getAgentRemoteWebSocketUrl()), request).get(); }
@Override public void destroy() { super.destroy(); try { wsFactory.stop(); } catch (Exception e) { log.warning("Error stopping WebSocket server", e); } if (proxyUrl != null) { try { httpClient.stop(); } catch (Exception e) { log.warning("Error stopping HTTP client", e); } try { wsClient.stop(); } catch (Exception e) { log.warning("Error stopping WebSocket client", e); } } stopped = true; synchronized (statusLock) { if (waiting) { buildThread.interrupt(); } } }
@After public void tearDown() throws Exception { client.stop(); m_server.stopServer(); IntegrationUtils.clearTestStorage(); }
private Code makeWsRequest(final String username, final String password) throws Exception { final WebSocketClient wsClient = new WebSocketClient(); wsClient.start(); try { final ClientUpgradeRequest request = new ClientUpgradeRequest(); if (!username.isEmpty()) { final String authHeader = "Basic " + buildBasicAuthHeader(username, password); request.setHeader(HttpHeaders.AUTHORIZATION, authHeader); } final WebSocketListener listener = new WebSocketListener(); final URI wsUri = REST_APP.getWsListener().resolve("/ws/query"); wsClient.connect(listener, wsUri, request); assertThat("Response received", listener.latch.await(30, TimeUnit.SECONDS), is(true)); final Throwable error = listener.error.get(); return error == null ? Code.OK : extractStatusCode(error); } finally { wsClient.stop(); } }
public void disconnect() { running = false; if (webSocketImpl != null) { webSocketImpl.close(); } if (webSocketClient != null) { try { webSocketClient.stop(); } catch (Exception e) { LOGGER.error("", e); } webSocketClient.destroy(); } }
@Override public void run(CommandLine theCommandLine) throws ParseException { String target = theCommandLine.getOptionValue("t"); if (isBlank(target) || (!target.startsWith("ws://") && !target.startsWith("wss://"))) { throw new ParseException("Target (-t) needs to be in the form \"ws://foo\" or \"wss://foo\""); } IdDt subsId = new IdDt(theCommandLine.getOptionValue("i")); WebSocketClient client = new WebSocketClient(); SimpleEchoSocket socket = new SimpleEchoSocket(subsId.getIdPart()); try { client.start(); URI echoUri = new URI(target); ClientUpgradeRequest request = new ClientUpgradeRequest(); ourLog.info("Connecting to : {}", echoUri); client.connect(socket, echoUri, request); while (!myQuit) { Thread.sleep(500L); } ourLog.info("Shutting down websocket client"); } catch (Exception e) { throw new CommandFailureException(e); } finally { try { client.stop(); } catch (Exception e) { ourLog.error("Failure", e); } } }
public void depose() throws Exception { keepRun = false; if (ws != null) ws.stop(); }
@Override public void close() { try { client.stop(); } catch (Exception e) { throw new RuntimeException(e); } } }
@Override public void stop() { try { this.client.stop(); } catch (Exception ex) { logger.error("Failed to stop Jetty WebSocketClient", ex); } }
@Override public void stop() { try { this.client.stop(); } catch (Exception ex) { logger.error("Failed to stop Jetty WebSocketClient", ex); } }
/** * Stops the module, by closing the web socket. */ @Override public void stop() throws IOException { try { client.stop(); } catch (IOException e) { throw e; } catch (Exception e) { throw new IllegalStateException(e); } }
@Override public void close() throws Exception { if(client != null ) { client.stop(); } }
@Override public void disconnect() { if (client == null) { return; } socket.send(new DisconnectMessage(privateKey)); try { client.stop(); } catch (Exception e) { e.printStackTrace(); } }
@OnWebSocketClose public void onClose(int statusCode, String reason) { logger.info(String.format("Connection closed: %d - %s", statusCode, reason)); try { if (client.isRunning()) { client.stop(); client.destroy(); } } catch (Exception e) { logger.log(Level.INFO, "Exception while trying to handle socket close", e); } }
@After public void teardown() throws Exception{ client.stop(); }
public synchronized void disconnect() throws Exception { if (logger.isTraceEnabled()) { logger.entry(); } stopRequested = true; if (client.isRunning()) { client.stop(); } if (logger.isTraceEnabled()) { logger.exit(); } }