org.springframework.web.socket.server.HandshakeFailureException Java Examples

The following examples show how to use org.springframework.web.socket.server.HandshakeFailureException. 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: AbstractTyrusRequestUpgradeStrategy.java    From spring-analysis-note with MIT License 6 votes vote down vote up
private Object createEndpoint(ServerEndpointRegistration registration, ComponentProviderService provider,
		WebSocketContainer container, TyrusWebSocketEngine engine) throws DeploymentException {

	DirectFieldAccessor accessor = new DirectFieldAccessor(engine);
	Object sessionListener = accessor.getPropertyValue("sessionListener");
	Object clusterContext = accessor.getPropertyValue("clusterContext");
	try {
		if (constructorWithBooleanArgument) {
			// Tyrus 1.11+
			return constructor.newInstance(registration.getEndpoint(), registration, provider, container,
					"/", registration.getConfigurator(), sessionListener, clusterContext, null, Boolean.TRUE);
		}
		else {
			return constructor.newInstance(registration.getEndpoint(), registration, provider, container,
					"/", registration.getConfigurator(), sessionListener, clusterContext, null);
		}
	}
	catch (Exception ex) {
		throw new HandshakeFailureException("Failed to register " + registration, ex);
	}
}
 
Example #2
Source File: UndertowRequestUpgradeStrategy.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
private ConfiguredServerEndpoint createConfiguredServerEndpoint(String selectedProtocol,
		List<Extension> selectedExtensions, Endpoint endpoint, HttpServletRequest servletRequest) {

	String path = servletRequest.getRequestURI();  // shouldn't matter
	ServerEndpointRegistration endpointRegistration = new ServerEndpointRegistration(path, endpoint);
	endpointRegistration.setSubprotocols(Arrays.asList(selectedProtocol));
	endpointRegistration.setExtensions(selectedExtensions);

	EncodingFactory encodingFactory = new EncodingFactory(
			Collections.<Class<?>, List<InstanceFactory<? extends Encoder>>>emptyMap(),
			Collections.<Class<?>, List<InstanceFactory<? extends Decoder>>>emptyMap(),
			Collections.<Class<?>, List<InstanceFactory<? extends Encoder>>>emptyMap(),
			Collections.<Class<?>, List<InstanceFactory<? extends Decoder>>>emptyMap());
	try {
		return (endpointConstructorWithEndpointFactory ?
				endpointConstructor.newInstance(endpointRegistration,
						new EndpointInstanceFactory(endpoint), null, encodingFactory, null) :
				endpointConstructor.newInstance(endpointRegistration,
						new EndpointInstanceFactory(endpoint), null, encodingFactory));
	}
	catch (Exception ex) {
		throw new HandshakeFailureException("Failed to instantiate ConfiguredServerEndpoint", ex);
	}
}
 
Example #3
Source File: WebSphereRequestUpgradeStrategy.java    From spring-analysis-note with MIT License 6 votes vote down vote up
@Override
public void upgradeInternal(ServerHttpRequest httpRequest, ServerHttpResponse httpResponse,
		@Nullable String selectedProtocol, List<Extension> selectedExtensions, Endpoint endpoint)
		throws HandshakeFailureException {

	HttpServletRequest request = getHttpServletRequest(httpRequest);
	HttpServletResponse response = getHttpServletResponse(httpResponse);

	StringBuffer requestUrl = request.getRequestURL();
	String path = request.getRequestURI();  // shouldn't matter
	Map<String, String> pathParams = Collections.<String, String> emptyMap();

	ServerEndpointRegistration endpointConfig = new ServerEndpointRegistration(path, endpoint);
	endpointConfig.setSubprotocols(Collections.singletonList(selectedProtocol));
	endpointConfig.setExtensions(selectedExtensions);

	try {
		ServerContainer container = getContainer(request);
		upgradeMethod.invoke(container, request, response, endpointConfig, pathParams);
	}
	catch (Exception ex) {
		throw new HandshakeFailureException(
				"Servlet request failed to upgrade to WebSocket for " + requestUrl, ex);
	}
}
 
Example #4
Source File: UndertowRequestUpgradeStrategy.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
private Handshake getHandshakeToUse(ServletWebSocketHttpExchange exchange, ConfiguredServerEndpoint endpoint) {
	Handshake handshake = new JsrHybi13Handshake(endpoint);
	if (handshake.matches(exchange)) {
		return handshake;
	}
	handshake = new JsrHybi08Handshake(endpoint);
	if (handshake.matches(exchange)) {
		return handshake;
	}
	handshake = new JsrHybi07Handshake(endpoint);
	if (handshake.matches(exchange)) {
		return handshake;
	}
	// Should never occur
	throw new HandshakeFailureException("No matching Undertow Handshake found: " + exchange.getRequestHeaders());
}
 
Example #5
Source File: AbstractTyrusRequestUpgradeStrategy.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
@Override
public Object createdEndpoint(ServerEndpointRegistration registration, ComponentProviderService provider,
		WebSocketContainer container, TyrusWebSocketEngine engine) throws DeploymentException {

	DirectFieldAccessor accessor = new DirectFieldAccessor(engine);
	Object sessionListener = accessor.getPropertyValue("sessionListener");
	Object clusterContext = accessor.getPropertyValue("clusterContext");
	try {
		if (constructorWithBooleanArgument) {
			// Tyrus 1.11+
			return constructor.newInstance(registration.getEndpoint(), registration, provider, container,
					"/", registration.getConfigurator(), sessionListener, clusterContext, null, Boolean.TRUE);
		}
		else {
			return constructor.newInstance(registration.getEndpoint(), registration, provider, container,
					"/", registration.getConfigurator(), sessionListener, clusterContext, null);
		}
	}
	catch (Exception ex) {
		throw new HandshakeFailureException("Failed to register " + registration, ex);
	}
}
 
Example #6
Source File: WebSphereRequestUpgradeStrategy.java    From java-technology-stack with MIT License 6 votes vote down vote up
@Override
public void upgradeInternal(ServerHttpRequest httpRequest, ServerHttpResponse httpResponse,
		@Nullable String selectedProtocol, List<Extension> selectedExtensions, Endpoint endpoint)
		throws HandshakeFailureException {

	HttpServletRequest request = getHttpServletRequest(httpRequest);
	HttpServletResponse response = getHttpServletResponse(httpResponse);

	StringBuffer requestUrl = request.getRequestURL();
	String path = request.getRequestURI();  // shouldn't matter
	Map<String, String> pathParams = Collections.<String, String> emptyMap();

	ServerEndpointRegistration endpointConfig = new ServerEndpointRegistration(path, endpoint);
	endpointConfig.setSubprotocols(Collections.singletonList(selectedProtocol));
	endpointConfig.setExtensions(selectedExtensions);

	try {
		ServerContainer container = getContainer(request);
		upgradeMethod.invoke(container, request, response, endpointConfig, pathParams);
	}
	catch (Exception ex) {
		throw new HandshakeFailureException(
				"Servlet request failed to upgrade to WebSocket for " + requestUrl, ex);
	}
}
 
Example #7
Source File: AbstractTyrusRequestUpgradeStrategy.java    From java-technology-stack with MIT License 6 votes vote down vote up
private Object createEndpoint(ServerEndpointRegistration registration, ComponentProviderService provider,
		WebSocketContainer container, TyrusWebSocketEngine engine) throws DeploymentException {

	DirectFieldAccessor accessor = new DirectFieldAccessor(engine);
	Object sessionListener = accessor.getPropertyValue("sessionListener");
	Object clusterContext = accessor.getPropertyValue("clusterContext");
	try {
		if (constructorWithBooleanArgument) {
			// Tyrus 1.11+
			return constructor.newInstance(registration.getEndpoint(), registration, provider, container,
					"/", registration.getConfigurator(), sessionListener, clusterContext, null, Boolean.TRUE);
		}
		else {
			return constructor.newInstance(registration.getEndpoint(), registration, provider, container,
					"/", registration.getConfigurator(), sessionListener, clusterContext, null);
		}
	}
	catch (Exception ex) {
		throw new HandshakeFailureException("Failed to register " + registration, ex);
	}
}
 
Example #8
Source File: WebSphereRequestUpgradeStrategy.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
@Override
public void upgradeInternal(ServerHttpRequest httpRequest, ServerHttpResponse httpResponse,
		String selectedProtocol, List<Extension> selectedExtensions, Endpoint endpoint)
		throws HandshakeFailureException {

	HttpServletRequest request = getHttpServletRequest(httpRequest);
	HttpServletResponse response = getHttpServletResponse(httpResponse);

	StringBuffer requestUrl = request.getRequestURL();
	String path = request.getRequestURI();  // shouldn't matter
	Map<String, String> pathParams = Collections.<String, String> emptyMap();

	ServerEndpointRegistration endpointConfig = new ServerEndpointRegistration(path, endpoint);
	endpointConfig.setSubprotocols(Collections.singletonList(selectedProtocol));
	endpointConfig.setExtensions(selectedExtensions);

	try {
		ServerContainer container = getContainer(request);
		upgradeMethod.invoke(container, request, response, endpointConfig, pathParams);
	}
	catch (Exception ex) {
		throw new HandshakeFailureException(
				"Servlet request failed to upgrade to WebSocket for " + requestUrl, ex);
	}
}
 
Example #9
Source File: AbstractStandardUpgradeStrategy.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
@Override
public void upgrade(ServerHttpRequest request, ServerHttpResponse response,
		String selectedProtocol, List<WebSocketExtension> selectedExtensions, Principal user,
		WebSocketHandler wsHandler, Map<String, Object> attrs) throws HandshakeFailureException {

	HttpHeaders headers = request.getHeaders();
	InetSocketAddress localAddr = request.getLocalAddress();
	InetSocketAddress remoteAddr = request.getRemoteAddress();

	StandardWebSocketSession session = new StandardWebSocketSession(headers, attrs, localAddr, remoteAddr, user);
	StandardWebSocketHandlerAdapter endpoint = new StandardWebSocketHandlerAdapter(wsHandler, session);

	List<Extension> extensions = new ArrayList<Extension>();
	for (WebSocketExtension extension : selectedExtensions) {
		extensions.add(new WebSocketToStandardExtensionAdapter(extension));
	}

	upgradeInternal(request, response, selectedProtocol, extensions, endpoint);
}
 
Example #10
Source File: WebLogicRequestUpgradeStrategy.java    From java-technology-stack with MIT License 5 votes vote down vote up
private Writer newInstance(Object webSocket, boolean isProtected) {
	try {
		return (Writer) constructor.newInstance(webSocket, null, isProtected);
	}
	catch (Exception ex) {
		throw new HandshakeFailureException("Failed to create TyrusServletWriter", ex);
	}
}
 
Example #11
Source File: GlassFishRequestUpgradeStrategy.java    From java-technology-stack with MIT License 5 votes vote down vote up
private Writer newServletWriter(TyrusHttpUpgradeHandler handler) {
	try {
		return (Writer) constructor.newInstance(handler);
	}
	catch (Exception ex) {
		throw new HandshakeFailureException("Failed to instantiate TyrusServletWriter", ex);
	}
}
 
Example #12
Source File: JettyRequestUpgradeStrategy.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Override
public void upgrade(ServerHttpRequest request, ServerHttpResponse response,
		String selectedProtocol, List<WebSocketExtension> selectedExtensions, Principal user,
		WebSocketHandler wsHandler, Map<String, Object> attributes) throws HandshakeFailureException {

	Assert.isInstanceOf(ServletServerHttpRequest.class, request, "ServletServerHttpRequest required");
	HttpServletRequest servletRequest = ((ServletServerHttpRequest) request).getServletRequest();

	Assert.isInstanceOf(ServletServerHttpResponse.class, response, "ServletServerHttpResponse required");
	HttpServletResponse servletResponse = ((ServletServerHttpResponse) response).getServletResponse();

	Assert.isTrue(this.factory.isUpgradeRequest(servletRequest, servletResponse), "Not a WebSocket handshake");

	JettyWebSocketSession session = new JettyWebSocketSession(attributes, user);
	JettyWebSocketHandlerAdapter handlerAdapter = new JettyWebSocketHandlerAdapter(wsHandler, session);

	WebSocketHandlerContainer container =
			new WebSocketHandlerContainer(handlerAdapter, selectedProtocol, selectedExtensions);

	try {
		containerHolder.set(container);
		this.factory.acceptWebSocket(servletRequest, servletResponse);
	}
	catch (IOException ex) {
		throw new HandshakeFailureException(
				"Response update failed during upgrade to WebSocket: " + request.getURI(), ex);
	}
	finally {
		containerHolder.remove();
	}
}
 
Example #13
Source File: NettyRequestUpgradeStrategy.java    From spring-boot-protocol with Apache License 2.0 5 votes vote down vote up
@Override
protected void upgradeInternal(ServerHttpRequest request, ServerHttpResponse response, String selectedProtocol,
                               List<Extension> selectedExtensions, Endpoint endpoint) throws HandshakeFailureException {
    HttpServletRequest servletRequest = getHttpServletRequest(request);
    ServletHttpServletRequest httpServletRequest = ServletUtil.unWrapper(servletRequest);
    if(httpServletRequest == null) {
        throw new HandshakeFailureException(
                "Servlet request failed to upgrade to WebSocket: " + servletRequest.getRequestURL());
    }

    WebSocketServerContainer serverContainer = getContainer(servletRequest);
    Principal principal = request.getPrincipal();
    Map<String, String> pathParams = new LinkedHashMap<>(3);

    ServerEndpointRegistration endpointConfig = new ServerEndpointRegistration(servletRequest.getRequestURI(), endpoint);
    endpointConfig.setSubprotocols(Arrays.asList(WebSocketServerHandshaker.SUB_PROTOCOL_WILDCARD,selectedProtocol));
    if(selectedExtensions != null) {
        endpointConfig.setExtensions(selectedExtensions);
    }

    try {
        handshakeToWebsocket(httpServletRequest, selectedProtocol, maxFramePayloadLength, principal,
                selectedExtensions, pathParams, endpoint,
                endpointConfig, serverContainer);
    } catch (Exception e) {
        throw new HandshakeFailureException(
                "Servlet request failed to upgrade to WebSocket: " + servletRequest.getRequestURL(), e);
    }
}
 
Example #14
Source File: AbstractTyrusRequestUpgradeStrategy.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Override
public void register(TyrusWebSocketEngine engine, Object endpoint) {
	try {
		registerMethod.invoke(engine, endpoint);
	}
	catch (Exception ex) {
		throw new HandshakeFailureException("Failed to register " + endpoint, ex);
	}
}
 
Example #15
Source File: AbstractTyrusRequestUpgradeStrategy.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Override
public void unregister(TyrusWebSocketEngine engine, Object endpoint) {
	try {
		unRegisterMethod.invoke(engine, endpoint);
	}
	catch (Exception ex) {
		throw new HandshakeFailureException("Failed to unregister " + endpoint, ex);
	}
}
 
Example #16
Source File: AbstractTyrusRequestUpgradeStrategy.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Override
public void register(TyrusWebSocketEngine engine, Object endpoint) {
	try {
		registerMethod.invoke(engine, endpoint);
	}
	catch (Exception ex) {
		throw new HandshakeFailureException("Failed to register " + endpoint, ex);
	}
}
 
Example #17
Source File: WebLogicRequestUpgradeStrategy.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
private Object newInstance(HttpServletRequest request, Object httpSocket) {
	try {
		Object[] args = (WLS_12_1_3 ? new Object[] {httpSocket} :
				new Object[] {httpSocket, null, subjectHelper.getSubject(request)});
		return constructor.newInstance(args);
	}
	catch (Exception ex) {
		throw new HandshakeFailureException("Failed to create TyrusMuxableWebSocket", ex);
	}
}
 
Example #18
Source File: WebLogicRequestUpgradeStrategy.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
private void upgrade(Object webSocket, Object httpSocket, ServletContext servletContext) {
	try {
		upgradeMethod.invoke(webSocket, httpSocket, servletContext);
	}
	catch (Exception ex) {
		throw new HandshakeFailureException("Failed to upgrade TyrusMuxableWebSocket", ex);
	}
}
 
Example #19
Source File: WebLogicRequestUpgradeStrategy.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
private void registerForReadEvent(Object webSocket) {
	try {
		readEventMethod.invoke(webSocket);
	}
	catch (Exception ex) {
		throw new HandshakeFailureException("Failed to register WebSocket for read event", ex);
	}
}
 
Example #20
Source File: WebLogicRequestUpgradeStrategy.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
public Object getSubject(HttpServletRequest request) {
	try {
		ServletContext servletContext = request.getServletContext();
		Object securityContext = securityContextMethod.invoke(servletContext);
		Object subject = currentUserMethod.invoke(null, securityContext, request);
		if (subject == null) {
			Object securityProvider = providerMethod.invoke(null);
			subject = anonymousSubjectMethod.invoke(securityProvider);
		}
		return subject;
	}
	catch (Exception ex) {
		throw new HandshakeFailureException("Failed to obtain SubjectHandle", ex);
	}
}
 
Example #21
Source File: WebLogicRequestUpgradeStrategy.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
private Writer newInstance(HttpServletResponse response, Object webSocket, boolean isProtected) {
	try {
		Object[] args = (WLS_12_1_3 ?
				new Object[] {webSocket, response, null, isProtected} :
				new Object[] {webSocket, null, isProtected});

		return (Writer) constructor.newInstance(args);
	}
	catch (Exception ex) {
		throw new HandshakeFailureException("Failed to create TyrusServletWriter", ex);
	}
}
 
Example #22
Source File: UndertowRequestUpgradeStrategy.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Override
protected void upgradeInternal(ServerHttpRequest request, ServerHttpResponse response,
		String selectedProtocol, List<Extension> selectedExtensions, final Endpoint endpoint)
		throws HandshakeFailureException {

	HttpServletRequest servletRequest = getHttpServletRequest(request);
	HttpServletResponse servletResponse = getHttpServletResponse(response);

	final ServletWebSocketHttpExchange exchange = createHttpExchange(servletRequest, servletResponse);
	exchange.putAttachment(HandshakeUtil.PATH_PARAMS, Collections.<String, String>emptyMap());

	ServerWebSocketContainer wsContainer = (ServerWebSocketContainer) getContainer(servletRequest);
	final EndpointSessionHandler endpointSessionHandler = new EndpointSessionHandler(wsContainer);

	final ConfiguredServerEndpoint configuredServerEndpoint = createConfiguredServerEndpoint(
			selectedProtocol, selectedExtensions, endpoint, servletRequest);

	final Handshake handshake = getHandshakeToUse(exchange, configuredServerEndpoint);

	exchange.upgradeChannel(new HttpUpgradeListener() {
		@Override
		public void handleUpgrade(StreamConnection connection, HttpServerExchange serverExchange) {
			Object bufferPool = ReflectionUtils.invokeMethod(getBufferPoolMethod, exchange);
			WebSocketChannel channel = (WebSocketChannel) ReflectionUtils.invokeMethod(
					createChannelMethod, handshake, exchange, connection, bufferPool);
			if (peerConnections != null) {
				peerConnections.add(channel);
			}
			endpointSessionHandler.onConnect(exchange, channel);
		}
	});

	handshake.handshake(exchange);
}
 
Example #23
Source File: UndertowRequestUpgradeStrategy.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
private ServletWebSocketHttpExchange createHttpExchange(HttpServletRequest request, HttpServletResponse response) {
	try {
		return (this.peerConnections != null ?
				exchangeConstructor.newInstance(request, response, this.peerConnections) :
				exchangeConstructor.newInstance(request, response));
	}
	catch (Exception ex) {
		throw new HandshakeFailureException("Failed to instantiate ServletWebSocketHttpExchange", ex);
	}
}
 
Example #24
Source File: GlassFishRequestUpgradeStrategy.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
private Writer newInstance(TyrusHttpUpgradeHandler handler) {
	try {
		return (Writer) constructor.newInstance(handler);
	}
	catch (Exception ex) {
		throw new HandshakeFailureException("Failed to instantiate TyrusServletWriter", ex);
	}
}
 
Example #25
Source File: JettyRequestUpgradeStrategy.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Override
public void upgrade(ServerHttpRequest request, ServerHttpResponse response,
		String selectedProtocol, List<WebSocketExtension> selectedExtensions, Principal user,
		WebSocketHandler wsHandler, Map<String, Object> attributes) throws HandshakeFailureException {

	Assert.isInstanceOf(ServletServerHttpRequest.class, request);
	HttpServletRequest servletRequest = ((ServletServerHttpRequest) request).getServletRequest();

	Assert.isInstanceOf(ServletServerHttpResponse.class, response);
	HttpServletResponse servletResponse = ((ServletServerHttpResponse) response).getServletResponse();

	Assert.isTrue(this.factory.isUpgradeRequest(servletRequest, servletResponse), "Not a WebSocket handshake");

	JettyWebSocketSession session = new JettyWebSocketSession(attributes, user);
	JettyWebSocketHandlerAdapter handlerAdapter = new JettyWebSocketHandlerAdapter(wsHandler, session);

	WebSocketHandlerContainer container =
			new WebSocketHandlerContainer(handlerAdapter, selectedProtocol, selectedExtensions);

	try {
		wsContainerHolder.set(container);
		this.factory.acceptWebSocket(servletRequest, servletResponse);
	}
	catch (IOException ex) {
		throw new HandshakeFailureException(
				"Response update failed during upgrade to WebSocket: " + request.getURI(), ex);
	}
	finally {
		wsContainerHolder.remove();
	}
}
 
Example #26
Source File: AbstractTyrusRequestUpgradeStrategy.java    From java-technology-stack with MIT License 5 votes vote down vote up
private void unregister(TyrusWebSocketEngine engine, Object endpoint) {
	try {
		unRegisterMethod.invoke(engine, endpoint);
	}
	catch (Exception ex) {
		throw new HandshakeFailureException("Failed to unregister " + endpoint, ex);
	}
}
 
Example #27
Source File: WebLogicRequestUpgradeStrategy.java    From spring-analysis-note with MIT License 5 votes vote down vote up
public Object getSubject(HttpServletRequest request) {
	try {
		ServletContext servletContext = request.getServletContext();
		Object securityContext = this.securityContextMethod.invoke(servletContext);
		Object subject = this.currentUserMethod.invoke(null, securityContext, request);
		if (subject == null) {
			Object securityProvider = this.providerMethod.invoke(null);
			subject = this.anonymousSubjectMethod.invoke(securityProvider);
		}
		return subject;
	}
	catch (Exception ex) {
		throw new HandshakeFailureException("Failed to obtain SubjectHandle", ex);
	}
}
 
Example #28
Source File: WebLogicRequestUpgradeStrategy.java    From spring-analysis-note with MIT License 5 votes vote down vote up
private Writer newInstance(Object webSocket, boolean isProtected) {
	try {
		return (Writer) constructor.newInstance(webSocket, null, isProtected);
	}
	catch (Exception ex) {
		throw new HandshakeFailureException("Failed to create TyrusServletWriter", ex);
	}
}
 
Example #29
Source File: GlassFishRequestUpgradeStrategy.java    From spring-analysis-note with MIT License 5 votes vote down vote up
private Writer newServletWriter(TyrusHttpUpgradeHandler handler) {
	try {
		return (Writer) constructor.newInstance(handler);
	}
	catch (Exception ex) {
		throw new HandshakeFailureException("Failed to instantiate TyrusServletWriter", ex);
	}
}
 
Example #30
Source File: WebLogicRequestUpgradeStrategy.java    From spring-analysis-note with MIT License 5 votes vote down vote up
private void registerForReadEvent(Object webSocket) {
	try {
		readEventMethod.invoke(webSocket);
	}
	catch (Exception ex) {
		throw new HandshakeFailureException("Failed to register WebSocket for read event", ex);
	}
}