com.neovisionaries.ws.client.WebSocketException Java Examples
The following examples show how to use
com.neovisionaries.ws.client.WebSocketException.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WebsocketAPI.java From smartcoins-wallet with MIT License | 5 votes |
public static void sendData(final WebSocket webSocket) { thread = new Thread(new Runnable() { @Override public void run() { try { webSocket.connect(); } catch (WebSocketException e) { Log.e(TAG, "WebSocketException. Msg: " + e.getMessage()); } } }); thread.start(); }
Example #2
Source File: DiscordWebSocketAdapter.java From Javacord with Apache License 2.0 | 5 votes |
@Override public void onError(WebSocket websocket, WebSocketException cause) { switch (cause.getMessage()) { // TODO This is copied from v2. I'm unsure if that's something we should do. Probably not ^^ case "Flushing frames to the server failed: Connection closed by remote host": case "Flushing frames to the server failed: Socket is closed": case "Flushing frames to the server failed: Connection has been shutdown: javax.net.ssl.SSLException:" + " java.net.SocketException: Connection reset": case "An I/O error occurred while a frame was being read from the web socket: Connection reset": break; default: logger.warn("Websocket error!", cause); break; } }
Example #3
Source File: DiscordWebSocketAdapter.java From Javacord with Apache License 2.0 | 5 votes |
@Override public void onError(WebSocket websocket, WebSocketException cause) { switch (cause.getMessage()) { // TODO This is copied from v2. I'm unsure if that's something we should do. Probably not ^^ case "Flushing frames to the server failed: Connection closed by remote host": case "Flushing frames to the server failed: Socket is closed": case "Flushing frames to the server failed: Connection has been shutdown: javax.net.ssl.SSLException:" + " java.net.SocketException: Connection reset": case "An I/O error occurred while a frame was being read from the web socket: Connection reset": break; default: logger.warn("Websocket error!", cause); break; } }
Example #4
Source File: Examples.java From javakiteconnect with MIT License | 4 votes |
/** Demonstrates com.zerodhatech.ticker connection, subcribing for instruments, unsubscribing for instruments, set mode of tick data, com.zerodhatech.ticker disconnection*/ public void tickerUsage(KiteConnect kiteConnect, ArrayList<Long> tokens) throws IOException, WebSocketException, KiteException { /** To get live price use websocket connection. * It is recommended to use only one websocket connection at any point of time and make sure you stop connection, once user goes out of app. * custom url points to new endpoint which can be used till complete Kite Connect 3 migration is done. */ final KiteTicker tickerProvider = new KiteTicker(kiteConnect.getAccessToken(), kiteConnect.getApiKey()); tickerProvider.setOnConnectedListener(new OnConnect() { @Override public void onConnected() { /** Subscribe ticks for token. * By default, all tokens are subscribed for modeQuote. * */ tickerProvider.subscribe(tokens); tickerProvider.setMode(tokens, KiteTicker.modeFull); } }); tickerProvider.setOnDisconnectedListener(new OnDisconnect() { @Override public void onDisconnected() { // your code goes here } }); /** Set listener to get order updates.*/ tickerProvider.setOnOrderUpdateListener(new OnOrderUpdate() { @Override public void onOrderUpdate(Order order) { System.out.println("order update "+order.orderId); } }); /** Set error listener to listen to errors.*/ tickerProvider.setOnErrorListener(new OnError() { @Override public void onError(Exception exception) { //handle here. } @Override public void onError(KiteException kiteException) { //handle here. } @Override public void onError(String error) { System.out.println(error); } }); tickerProvider.setOnTickerArrivalListener(new OnTicks() { @Override public void onTicks(ArrayList<Tick> ticks) { NumberFormat formatter = new DecimalFormat(); System.out.println("ticks size "+ticks.size()); if(ticks.size() > 0) { System.out.println("last price "+ticks.get(0).getLastTradedPrice()); System.out.println("open interest "+formatter.format(ticks.get(0).getOi())); System.out.println("day high OI "+formatter.format(ticks.get(0).getOpenInterestDayHigh())); System.out.println("day low OI "+formatter.format(ticks.get(0).getOpenInterestDayLow())); System.out.println("change "+formatter.format(ticks.get(0).getChange())); System.out.println("tick timestamp "+ticks.get(0).getTickTimestamp()); System.out.println("tick timestamp date "+ticks.get(0).getTickTimestamp()); System.out.println("last traded time "+ticks.get(0).getLastTradedTime()); System.out.println(ticks.get(0).getMarketDepth().get("buy").size()); } } }); // Make sure this is called before calling connect. tickerProvider.setTryReconnection(true); //maximum retries and should be greater than 0 tickerProvider.setMaximumRetries(10); //set maximum retry interval in seconds tickerProvider.setMaximumRetryInterval(30); /** connects to com.zerodhatech.com.zerodhatech.ticker server for getting live quotes*/ tickerProvider.connect(); /** You can check, if websocket connection is open or not using the following method.*/ boolean isConnected = tickerProvider.isConnectionOpen(); System.out.println(isConnected); /** set mode is used to set mode in which you need tick for list of tokens. * Ticker allows three modes, modeFull, modeQuote, modeLTP. * For getting only last traded price, use modeLTP * For getting last traded price, last traded quantity, average price, volume traded today, total sell quantity and total buy quantity, open, high, low, close, change, use modeQuote * For getting all data with depth, use modeFull*/ tickerProvider.setMode(tokens, KiteTicker.modeLTP); // Unsubscribe for a token. tickerProvider.unsubscribe(tokens); // After using com.zerodhatech.com.zerodhatech.ticker, close websocket connection. tickerProvider.disconnect(); }
Example #5
Source File: DiscordWebSocketAdapter.java From Javacord with Apache License 2.0 | 4 votes |
@Override public void onConnectError(WebSocket websocket, WebSocketException exception) { logger.warn("Websocket onConnect error!", exception); }
Example #6
Source File: DiscordWebSocketAdapter.java From Javacord with Apache License 2.0 | 4 votes |
@Override public void onUnexpectedError(WebSocket websocket, WebSocketException cause) { logger.warn("Websocket onUnexpected error!", cause); }
Example #7
Source File: DiscordWebSocketAdapter.java From Javacord with Apache License 2.0 | 4 votes |
@Override public void onConnectError(WebSocket websocket, WebSocketException exception) { logger.warn("Websocket onConnect error!", exception); }
Example #8
Source File: SystemStatusService.java From AirMapSDK-Android with Apache License 2.0 | 4 votes |
@Override public void onConnectError(WebSocket websocket, WebSocketException exception) throws Exception { super.onConnectError(websocket, exception); Timber.e(exception); }
Example #9
Source File: SystemStatusService.java From AirMapSDK-Android with Apache License 2.0 | 4 votes |
@Override public void onError(WebSocket websocket, WebSocketException cause) throws Exception { super.onError(websocket, cause); Timber.e(cause); }
Example #10
Source File: SystemStatusService.java From AirMapSDK-Android with Apache License 2.0 | 4 votes |
@Override public void onFrameError(WebSocket websocket, WebSocketException cause, WebSocketFrame frame) throws Exception { super.onFrameError(websocket, cause, frame); }
Example #11
Source File: SystemStatusService.java From AirMapSDK-Android with Apache License 2.0 | 4 votes |
@Override public void onMessageError(WebSocket websocket, WebSocketException cause, List<WebSocketFrame> frames) throws Exception { super.onMessageError(websocket, cause, frames); }
Example #12
Source File: SystemStatusService.java From AirMapSDK-Android with Apache License 2.0 | 4 votes |
@Override public void onMessageDecompressionError(WebSocket websocket, WebSocketException cause, byte[] compressed) throws Exception { super.onMessageDecompressionError(websocket, cause, compressed); }
Example #13
Source File: SystemStatusService.java From AirMapSDK-Android with Apache License 2.0 | 4 votes |
@Override public void onTextMessageError(WebSocket websocket, WebSocketException cause, byte[] data) throws Exception { super.onTextMessageError(websocket, cause, data); }
Example #14
Source File: SystemStatusService.java From AirMapSDK-Android with Apache License 2.0 | 4 votes |
@Override public void onSendError(WebSocket websocket, WebSocketException cause, WebSocketFrame frame) throws Exception { super.onSendError(websocket, cause, frame); }
Example #15
Source File: SystemStatusService.java From AirMapSDK-Android with Apache License 2.0 | 4 votes |
@Override public void onUnexpectedError(WebSocket websocket, WebSocketException cause) throws Exception { super.onUnexpectedError(websocket, cause); }
Example #16
Source File: DiscordWebSocketAdapter.java From Javacord with Apache License 2.0 | 4 votes |
@Override public void onUnexpectedError(WebSocket websocket, WebSocketException cause) { logger.warn("Websocket onUnexpected error!", cause); }
Example #17
Source File: WebSocketLogger.java From Javacord with Apache License 2.0 | 4 votes |
@Override public void onUnexpectedError(WebSocket websocket, WebSocketException cause) { logger.trace("onUnexpectedError", cause); }
Example #18
Source File: GetLimitOrders.java From smartcoins-wallet with MIT License | 4 votes |
@Override public void onError(WebSocket websocket, WebSocketException cause) throws Exception { mListener.onError(new BaseResponse.Error(cause.getMessage())); websocket.disconnect(); }
Example #19
Source File: WebSocketLogger.java From Javacord with Apache License 2.0 | 4 votes |
@Override public void onConnectError(WebSocket websocket, WebSocketException cause) { logger.trace("onConnectError", cause); }
Example #20
Source File: WebSocketLogger.java From Javacord with Apache License 2.0 | 4 votes |
@Override public void onError(WebSocket websocket, WebSocketException cause) { logger.trace("onError", cause); }
Example #21
Source File: WebSocketLogger.java From Javacord with Apache License 2.0 | 4 votes |
@Override public void onFrameError(WebSocket websocket, WebSocketException cause, WebSocketFrame frame) { logger.trace("onFrameError: frame='{}'", frame, cause); }
Example #22
Source File: WebSocketLogger.java From Javacord with Apache License 2.0 | 4 votes |
@Override public void onMessageError(WebSocket websocket, WebSocketException cause, List<WebSocketFrame> frames) { logger.trace("onMessageError: frames='{}'", frames, cause); }
Example #23
Source File: WebSocketLogger.java From Javacord with Apache License 2.0 | 4 votes |
@Override public void onMessageDecompressionError(WebSocket websocket, WebSocketException cause, byte[] compressed) { logger.trace("onMessageDecompressionError: compressed='{}'", compressed, cause); }
Example #24
Source File: WebSocketLogger.java From Javacord with Apache License 2.0 | 4 votes |
@Override public void onTextMessageError(WebSocket websocket, WebSocketException cause, byte[] data) { logger.trace("onTextMessageError: data='{}'", data, cause); }
Example #25
Source File: WebSocketLogger.java From Javacord with Apache License 2.0 | 4 votes |
@Override public void onSendError(WebSocket websocket, WebSocketException cause, WebSocketFrame frame) { logger.trace("onSendError: frame='{}'", frame, cause); }
Example #26
Source File: WebSocketLogger.java From Javacord with Apache License 2.0 | 4 votes |
@Override public void onUnexpectedError(WebSocket websocket, WebSocketException cause) { logger.trace("onUnexpectedError", cause); }
Example #27
Source File: WebSocketListener.java From FlareBot with MIT License | 4 votes |
@Override public void onMessageError(WebSocket webSocket, WebSocketException e, List<WebSocketFrame> list) throws Exception { }
Example #28
Source File: CustomWebSocketListener.java From WebRTCapp with Apache License 2.0 | 4 votes |
@Override public void onConnectError(WebSocket websocket, WebSocketException cause) throws Exception { Log.i(TAG, "Connect error: " + cause); }
Example #29
Source File: CustomWebSocketListener.java From WebRTCapp with Apache License 2.0 | 4 votes |
@Override public void onError(WebSocket websocket, WebSocketException cause) throws Exception { Log.i(TAG, "Error! " + cause); }
Example #30
Source File: CustomWebSocketListener.java From WebRTCapp with Apache License 2.0 | 4 votes |
@Override public void onFrameError(WebSocket websocket, WebSocketException cause, WebSocketFrame frame) throws Exception { Log.i(TAG, "Frame error"); }