Java Code Examples for javax.websocket.WebSocketContainer#setDefaultMaxTextMessageBufferSize()
The following examples show how to use
javax.websocket.WebSocketContainer#setDefaultMaxTextMessageBufferSize() .
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: LibertySessionWrapper.java From rogue-cloud with Apache License 2.0 | 6 votes |
private void connect(String url) { // Don't try to connect if we have already disposed of the session, or the client instance if (disposed || LibertyClientInstance.getInstance().isDisposed()) { log.interesting("Ignoring connect as instance of wrapper is disposed ["+disposed+","+LibertyClientInstance.getInstance().isDisposed()+"]", parent.getLogContext()); return; } log.interesting("Attempting to connect", parent.getLogContext()); final ClientEndpointConfig cec = ClientEndpointConfig.Builder.create().build(); // // ClientManager client = ClientManager.createClient(); WebSocketContainer c = ContainerProvider.getWebSocketContainer(); c.setDefaultMaxTextMessageBufferSize(1024 * 1024); c.setDefaultMaxSessionIdleTimeout(2 * TimeUnit.MILLISECONDS.convert(RCSharedConstants.MAX_ROUND_LENGTH_IN_NANOS, TimeUnit.NANOSECONDS)); try { c.connectToServer(this.hce, cec, new URI(url)); // Wait for the endpoint to call us on success or failure. } catch (DeploymentException | IOException | URISyntaxException e) { errorOccurred(null); } }
Example 2
Source File: WebsocketLauncher.java From java-sdk with Apache License 2.0 | 5 votes |
public static boolean startUp(BinanceDexClientEndpoint endpoint){ try { WebSocketContainer container = ContainerProvider.getWebSocketContainer(); container.setDefaultMaxBinaryMessageBufferSize(128000000); container.setDefaultMaxTextMessageBufferSize(128000000); container.connectToServer(endpoint,new URI(endpoint.getUrl())); return true; } catch (Exception e) { throw new RuntimeException(e); } }
Example 3
Source File: WebsocketLauncher.java From java-sdk with Apache License 2.0 | 5 votes |
public static boolean startUp(BinanceDexClientEndpoint endpoint){ try { WebSocketContainer container = ContainerProvider.getWebSocketContainer(); container.setDefaultMaxBinaryMessageBufferSize(128000000); container.setDefaultMaxTextMessageBufferSize(128000000); container.connectToServer(endpoint,new URI(endpoint.getUrl())); return true; } catch (Exception e) { throw new RuntimeException(e); } }
Example 4
Source File: WebSocketSessionContext.java From artemis with Apache License 2.0 | 4 votes |
public WebSocketSessionContext(final ArtemisClientConfig config) { Preconditions.checkArgument(config != null, "config"); _ttl = config.properties().getLongProperty(config.key("websocket-session.ttl"), 5 * 60 * 1000L, 5 * 60 * 1000, 30 * 60 * 1000); _connectTimeout = config.properties().getLongProperty(config.key("websocket-session.connect-timeout"), 5 * 1000L, 1000, 30 * 1000); pingTimeout = config.properties().getLongProperty(config.key("websocket-session.ping-timeout"), 1000L, 50, 10 * 1000); defaultMaxTextMessageBufferSize = config.properties().getIntProperty(config.key("websocket-session.text-message.buffer-size"), 8, 8, 32); final WebSocketContainer container = ContainerProvider.getWebSocketContainer(); container.setDefaultMaxTextMessageBufferSize(defaultMaxTextMessageBufferSize.typedValue() * 1024); _wsClient = new StandardWebSocketClient(container); _addressManager = config.addressManager(); _addressContext.set(_addressManager.getContext()); _handler = new WebSocketHandler() { @Override public void afterConnectionEstablished(final WebSocketSession session) throws Exception { } @Override public void handleMessage(final WebSocketSession session, final WebSocketMessage<?> message) throws Exception { if (message instanceof TextMessage) { WebSocketSessionContext.this.handleMessage(session, message); } else if (message instanceof PongMessage) { synchronized (receivePong) { receivePong.notifyAll(); } } } @Override public void handleTransportError(final WebSocketSession session, final Throwable exception) throws Exception { markdown(); _logger.error("WebSocketSession transport error", exception); } @Override public void afterConnectionClosed(final WebSocketSession session, final CloseStatus closeStatus) throws Exception { _logger.info("WebSocketSession closed: " + closeStatus); checkHealth(); } @Override public boolean supportsPartialMessages() { return false; } }; rateLimiter = config.getRateLimiterManager().getRateLimiter(config.key("websocket-session.reconnect-times"), new RateLimiterConfig(true, new RangePropertyConfig<Long>(5L, 3L, 60L), new TimeBufferConfig(20 * 1000, 2 * 1000))); final DynamicScheduledThreadConfig dynamicScheduledThreadConfig = new DynamicScheduledThreadConfig(config.properties(), new RangePropertyConfig<Integer>(20, 0, 200), new RangePropertyConfig<Integer>(1000, 100, 10 * 60 * 1000)); _healthChecker = new DynamicScheduledThread(config.key("websocket-session.health-check"), new Runnable() { @Override public void run() { WebSocketSessionContext.this.checkHealth(); } }, dynamicScheduledThreadConfig); _healthChecker.setDaemon(true); }