io.netty.handler.codec.http.websocketx.WebSocketClientHandshaker Java Examples
The following examples show how to use
io.netty.handler.codec.http.websocketx.WebSocketClientHandshaker.
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: WebsocketChannelInitializer.java From SynchronizeFX with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void addToPipeline(final ChannelPipeline pipeline) { pipeline.addLast("http-codec", new HttpClientCodec()); pipeline.addLast("aggregator", new HttpObjectAggregator(8192)); final WebSocketClientHandshaker handShaker = new WhiteSpaceInPathWebSocketClientHandshaker13(serverUri, WebSocketVersion.V13, PROTOCOL, false, createHttpHeaders(httpHeaders), Integer.MAX_VALUE); pipeline.addLast("websocket-protocol-handler", new WebSocketClientProtocolHandler(handShaker)); pipeline.addLast("websocket-frame-codec", new ByteBufToWebSocketFrameCodec()); }
Example #2
Source File: WebSocketIT.java From qonduit with Apache License 2.0 | 5 votes |
@Before public void setup() throws Exception { s = new Server(conf); s.run(); Connector con = mac.getConnector("root", "secret"); con.securityOperations().changeUserAuthorizations("root", new Authorizations("A", "B", "C", "D", "E", "F")); this.sessionId = UUID.randomUUID().toString(); AuthCache.getCache().put(sessionId, token); group = new NioEventLoopGroup(); SslContext ssl = SslContextBuilder.forClient().trustManager(InsecureTrustManagerFactory.INSTANCE).build(); String cookieVal = ClientCookieEncoder.STRICT.encode(Constants.COOKIE_NAME, sessionId); HttpHeaders headers = new DefaultHttpHeaders(); headers.add(HttpHeaderNames.COOKIE, cookieVal); WebSocketClientHandshaker handshaker = WebSocketClientHandshakerFactory.newHandshaker(LOCATION, WebSocketVersion.V13, (String) null, false, headers); handler = new ClientHandler(handshaker); Bootstrap boot = new Bootstrap(); boot.group(group).channel(NioSocketChannel.class).handler(new ChannelInitializer<SocketChannel>() { @Override protected void initChannel(SocketChannel ch) throws Exception { ch.pipeline().addLast("ssl", ssl.newHandler(ch.alloc(), "127.0.0.1", WS_PORT)); ch.pipeline().addLast(new HttpClientCodec()); ch.pipeline().addLast(new HttpObjectAggregator(8192)); ch.pipeline().addLast(handler); } }); ch = boot.connect("127.0.0.1", WS_PORT).sync().channel(); // Wait until handshake is complete while (!handshaker.isHandshakeComplete()) { sleepUninterruptibly(500, TimeUnit.MILLISECONDS); LOG.debug("Waiting for Handshake to complete"); } }
Example #3
Source File: WebSocketIT.java From timely with Apache License 2.0 | 5 votes |
@Before public void setup() throws Exception { s = new Server(conf); s.run(); Connector con = mac.getConnector("root", "secret"); con.securityOperations().changeUserAuthorizations("root", new Authorizations("A", "B", "C", "D", "E", "F")); this.sessionId = UUID.randomUUID().toString(); AuthCache.put(sessionId, TimelyPrincipal.anonymousPrincipal()); group = new NioEventLoopGroup(); SslContext ssl = SslContextBuilder.forClient().trustManager(InsecureTrustManagerFactory.INSTANCE).build(); String cookieVal = ClientCookieEncoder.STRICT.encode(Constants.COOKIE_NAME, sessionId); HttpHeaders headers = new DefaultHttpHeaders(); headers.add(HttpHeaderNames.COOKIE, cookieVal); WebSocketClientHandshaker handshaker = WebSocketClientHandshakerFactory.newHandshaker(LOCATION, WebSocketVersion.V13, (String) null, false, headers); handler = new ClientHandler(handshaker); Bootstrap boot = new Bootstrap(); boot.group(group).channel(NioSocketChannel.class).handler(new ChannelInitializer<SocketChannel>() { @Override protected void initChannel(SocketChannel ch) throws Exception { ch.pipeline().addLast("ssl", ssl.newHandler(ch.alloc(), "127.0.0.1", WS_PORT)); ch.pipeline().addLast(new HttpClientCodec()); ch.pipeline().addLast(new HttpObjectAggregator(8192)); ch.pipeline().addLast(handler); } }); ch = boot.connect("127.0.0.1", WS_PORT).sync().channel(); // Wait until handshake is complete while (!handshaker.isHandshakeComplete()) { sleepUninterruptibly(500, TimeUnit.MILLISECONDS); LOG.debug("Waiting for Handshake to complete"); } }
Example #4
Source File: GatewayHandler.java From arcusplatform with Apache License 2.0 | 5 votes |
@SuppressWarnings({ "unchecked", "rawtypes", "null" }) GatewayHandler(WebSocketClientHandshaker handshaker) { this.authorizedMessages = new SerializedSubject(PublishSubject.create()); this.registeredMessages = new SerializedSubject(PublishSubject.create()); this.platformMessages = new SerializedSubject(PublishSubject.create()); this.protocolMessages = new SerializedSubject(PublishSubject.create()); this.handshaker = handshaker; this.websocketFrameBuf = Unpooled.unreleasableBuffer(Unpooled.buffer(GatewayConnection.WEBSOCKETS_MAX_FRAME_LENGTH)); this.lastHubMsg = System.nanoTime(); this.lastPlatformMsg = System.nanoTime(); }
Example #5
Source File: DFWsClientHandler.java From dfactor with MIT License | 5 votes |
public DFWsClientHandler(WebSocketClientHandshaker handshaker,int actorIdDef, int requestId, int decodeType, DFActorTcpDispatcher dispatcher, DFTcpDecoder decoder, DFTcpEncoder encoder) { this.handshaker = handshaker; _actorIdDef = actorIdDef; _requestId = requestId; _decodeType = decodeType; _dispatcher = dispatcher; _decoder = decoder; _encoder = encoder; _mgrActor = DFActorManager.get(); }
Example #6
Source File: LBAwareSigV4WebSocketChannelizer.java From amazon-neptune-tools with Apache License 2.0 | 5 votes |
/** * Creates an instance of {@link WebSocketClientHandler} with {@link AwsSigV4ClientHandshaker} as the handshaker * for SigV4 auth. * @return the instance of clientHandler. */ private WebSocketClientHandler createHandler() { HandshakeRequestConfig handshakeRequestConfig = HandshakeRequestConfig.parse(cluster.authProperties().get(AuthProperties.Property.JAAS_ENTRY)); WebSocketClientHandshaker handshaker = new LBAwareAwsSigV4ClientHandshaker( connection.getUri(), WebSocketVersion.V13, null, false, EmptyHttpHeaders.INSTANCE, cluster.getMaxContentLength(), new ChainedSigV4PropertiesProvider(), handshakeRequestConfig); return new WebSocketClientHandler(handshaker); }
Example #7
Source File: WebSocketIT.java From timely with Apache License 2.0 | 4 votes |
public ClientHandler(WebSocketClientHandshaker handshaker) { this.handshaker = handshaker; }
Example #8
Source File: WebSocketIT.java From qonduit with Apache License 2.0 | 4 votes |
public ClientHandler(WebSocketClientHandshaker handshaker) { this.handshaker = handshaker; }
Example #9
Source File: WebSocketClientHandler.java From product-ei with Apache License 2.0 | 4 votes |
public WebSocketClientHandler(WebSocketClientHandshaker handshaker, CountDownLatch latch) { this.handshaker = handshaker; this.latch = latch; this.isOpen = true; }
Example #10
Source File: WampClientWebsocketHandler.java From GreenBits with GNU General Public License v3.0 | 4 votes |
public WampClientWebsocketHandler(WebSocketClientHandshaker handshaker) { this.handshaker = handshaker; }
Example #11
Source File: WebSocketClientHandler.java From netty4.0.27Learn with Apache License 2.0 | 4 votes |
public WebSocketClientHandler(WebSocketClientHandshaker handshaker) { this.handshaker = handshaker; }
Example #12
Source File: BitsoWebSocket.java From bitso-java with MIT License | 4 votes |
public WebSocketClientHandler(WebSocketClientHandshaker handshaker) { mHandshaker = handshaker; }
Example #13
Source File: WebSocketClientHandler.java From rsocket-java with Apache License 2.0 | 4 votes |
public WebSocketClientHandler(WebSocketClientHandshaker handshaker) { this.handshaker = handshaker; }
Example #14
Source File: WebSocketClientHandler.java From msf4j with Apache License 2.0 | 4 votes |
public WebSocketClientHandler(WebSocketClientHandshaker handshaker) { this.handshaker = handshaker; }
Example #15
Source File: WebSocketClientHandler.java From blynk-server with GNU General Public License v3.0 | 4 votes |
public WebSocketClientHandler(WebSocketClientHandshaker handshaker) { this.handshaker = handshaker; }
Example #16
Source File: AppWebSocketClientHandler.java From blynk-server with GNU General Public License v3.0 | 4 votes |
public AppWebSocketClientHandler(WebSocketClientHandshaker handshaker) { this.handshaker = handshaker; }
Example #17
Source File: WebSocketClientHandler.java From tinkerpop with Apache License 2.0 | 4 votes |
public WebSocketClientHandler(final WebSocketClientHandshaker handshaker) { this.handshaker = handshaker; }
Example #18
Source File: AbstractJsonRpcWebSocketClientHandler.java From kurento-java with Apache License 2.0 | 4 votes |
public AbstractJsonRpcWebSocketClientHandler(WebSocketClientHandshaker handshaker) { this.handshaker = handshaker; }
Example #19
Source File: JsonRpcClientNettyWebSocket.java From kurento-java with Apache License 2.0 | 4 votes |
public JsonRpcWebSocketClientHandler(WebSocketClientHandshaker handshaker) { super(handshaker); }
Example #20
Source File: WampClientWebsocketHandler.java From jawampa with Apache License 2.0 | 4 votes |
public WampClientWebsocketHandler(WebSocketClientHandshaker handshaker) { this.handshaker = handshaker; }
Example #21
Source File: WebSocketFrameTransport.java From qpid-broker-j with Apache License 2.0 | 4 votes |
WebSocketClientHandler(final WebSocketClientHandshaker handshaker) { _handshaker = handshaker; }
Example #22
Source File: WebSocketClientHandler.java From micro-integrator with Apache License 2.0 | 4 votes |
public WebSocketClientHandler(WebSocketClientHandshaker handshaker, CountDownLatch latch) { this.handshaker = handshaker; this.latch = latch; this.isOpen = true; }
Example #23
Source File: WebSocketClientHandler.java From tools-journey with Apache License 2.0 | 4 votes |
public WebSocketClientHandler(WebSocketClientHandshaker handshaker) { this.handshaker = handshaker; }
Example #24
Source File: WebSocketClientHandler.java From karate with MIT License | 4 votes |
public WebSocketClientHandler(WebSocketClientHandshaker handshaker, WebSocketListener listener) { this.handshaker = handshaker; this.listener = listener; }
Example #25
Source File: PoloniexWSSClientRouter.java From poloniex-api-java with MIT License | 4 votes |
public PoloniexWSSClientRouter(WebSocketClientHandshaker handshaker, Map<Double, IMessageHandler> subscriptions) { this.handshaker = handshaker; this.subscriptions = subscriptions; this.defaultSubscriptionMessageHandler = new LoggingMessageHandler(); this.gson = new Gson(); }
Example #26
Source File: ForwardClient.java From arthas with Apache License 2.0 | 4 votes |
public void start() throws URISyntaxException, SSLException, InterruptedException { String scheme = tunnelServerURI.getScheme() == null ? "ws" : tunnelServerURI.getScheme(); final String host = tunnelServerURI.getHost() == null ? "127.0.0.1" : tunnelServerURI.getHost(); final int port; if (tunnelServerURI.getPort() == -1) { if ("ws".equalsIgnoreCase(scheme)) { port = 80; } else if ("wss".equalsIgnoreCase(scheme)) { port = 443; } else { port = -1; } } else { port = tunnelServerURI.getPort(); } if (!"ws".equalsIgnoreCase(scheme) && !"wss".equalsIgnoreCase(scheme)) { logger.error("Only WS(S) is supported, uri: {}", tunnelServerURI); return; } final boolean ssl = "wss".equalsIgnoreCase(scheme); final SslContext sslCtx; if (ssl) { sslCtx = SslContextBuilder.forClient().trustManager(InsecureTrustManagerFactory.INSTANCE).build(); } else { sslCtx = null; } // connect to local server WebSocketClientHandshaker newHandshaker = WebSocketClientHandshakerFactory.newHandshaker(tunnelServerURI, WebSocketVersion.V13, null, true, new DefaultHttpHeaders()); final WebSocketClientProtocolHandler websocketClientHandler = new WebSocketClientProtocolHandler(newHandshaker); final ForwardClientSocketClientHandler forwardClientSocketClientHandler = new ForwardClientSocketClientHandler( localServerURI); Bootstrap b = new Bootstrap(); b.group(group).channel(NioSocketChannel.class).handler(new ChannelInitializer<SocketChannel>() { @Override protected void initChannel(SocketChannel ch) { ChannelPipeline p = ch.pipeline(); if (sslCtx != null) { p.addLast(sslCtx.newHandler(ch.alloc(), host, port)); } p.addLast(new HttpClientCodec(), new HttpObjectAggregator(8192), websocketClientHandler, forwardClientSocketClientHandler); } }); channel = b.connect(tunnelServerURI.getHost(), port).sync().channel(); logger.info("forward client connect to server success, uri: " + tunnelServerURI); }
Example #27
Source File: TunnelClient.java From arthas with Apache License 2.0 | 4 votes |
public ChannelFuture connect(boolean reconnect) throws SSLException, URISyntaxException, InterruptedException { QueryStringEncoder queryEncoder = new QueryStringEncoder(this.tunnelServerUrl); queryEncoder.addParam("method", "agentRegister"); if (id != null) { queryEncoder.addParam("id", id); } // ws://127.0.0.1:7777/ws?method=agentRegister final URI agentRegisterURI = queryEncoder.toUri(); logger.info("Try to register arthas agent, uri: {}", agentRegisterURI); String scheme = agentRegisterURI.getScheme() == null ? "ws" : agentRegisterURI.getScheme(); final String host = agentRegisterURI.getHost() == null ? "127.0.0.1" : agentRegisterURI.getHost(); final int port; if (agentRegisterURI.getPort() == -1) { if ("ws".equalsIgnoreCase(scheme)) { port = 80; } else if ("wss".equalsIgnoreCase(scheme)) { port = 443; } else { port = -1; } } else { port = agentRegisterURI.getPort(); } if (!"ws".equalsIgnoreCase(scheme) && !"wss".equalsIgnoreCase(scheme)) { throw new IllegalArgumentException("Only WS(S) is supported. tunnelServerUrl: " + tunnelServerUrl); } final boolean ssl = "wss".equalsIgnoreCase(scheme); final SslContext sslCtx; if (ssl) { sslCtx = SslContextBuilder.forClient().trustManager(InsecureTrustManagerFactory.INSTANCE).build(); } else { sslCtx = null; } WebSocketClientHandshaker newHandshaker = WebSocketClientHandshakerFactory.newHandshaker(agentRegisterURI, WebSocketVersion.V13, null, true, new DefaultHttpHeaders()); final WebSocketClientProtocolHandler websocketClientHandler = new WebSocketClientProtocolHandler(newHandshaker); final TunnelClientSocketClientHandler handler = new TunnelClientSocketClientHandler(TunnelClient.this); Bootstrap bs = new Bootstrap(); bs.group(eventLoopGroup).channel(NioSocketChannel.class).remoteAddress(host, port) .handler(new ChannelInitializer<SocketChannel>() { @Override protected void initChannel(SocketChannel ch) { ChannelPipeline p = ch.pipeline(); if (sslCtx != null) { p.addLast(sslCtx.newHandler(ch.alloc(), host, port)); } p.addLast(new HttpClientCodec(), new HttpObjectAggregator(8192), websocketClientHandler, handler); } }); ChannelFuture connectFuture = bs.connect(); if (reconnect) { connectFuture.addListener(new ChannelFutureListener() { @Override public void operationComplete(ChannelFuture future) throws Exception { if (future.cause() != null) { logger.error("connect to tunnel server error, uri: {}", tunnelServerUrl, future.cause()); } } }); } channel = connectFuture.sync().channel(); return handler.registerFuture(); }
Example #28
Source File: WebSocketClientHandler.java From zheshiyigeniubidexiangmu with MIT License | 4 votes |
public WebSocketClientHandler(WebSocketClientHandshaker handshaker,WebSocketService service,MoniterTask moniter) { this.handshaker = handshaker; this.service = service; this.moniter = moniter; }
Example #29
Source File: WebSocketClientHandler.java From zheshiyigeniubidexiangmu with MIT License | 4 votes |
public WebSocketClientHandler(WebSocketClientHandshaker handshaker,WebSocketService service,MoniterTask moniter) { this.handshaker = handshaker; this.service = service; this.moniter = moniter; }
Example #30
Source File: WebSocketClientHandler.java From netty-4.1.22 with Apache License 2.0 | 4 votes |
public WebSocketClientHandler(WebSocketClientHandshaker handshaker) { this.handshaker = handshaker; }