java-websocket

Difference between ws and wss?

让人想犯罪 __ 提交于 2019-11-30 04:34:39
What is the procedure to change ws into wss? Whether wss is make upgrade over normal HTTP or wss works only HTTPS? webSocket = new WebSocket("ws://localhost:port/Esv/ocp"); works fine, when I changed ws to wss webSocket = new WebSocket("wss://localhost:port/Esv/ocp"); it shows this error: Error in connection establishment: net::ERR_SSL_PROTOCOL_ERROR Short version To SSL or not SSL You may have a SSL certificate issue . The connection point rule can be summarized as : wss connects on https only ws connects on http and vice-versa: https accepts wss only http accepts ws only Errors Following

Java server JavaScript client WebSockets

▼魔方 西西 提交于 2019-11-29 15:11:42
问题 I'm trying to do a connection between a server in Java and a JavaScript client but I'm getting this error on client side: WebSocket connection to 'ws://127.0.0.1:4444/' failed: Connection closed before receiving a handshake response It maybe stays on OPENNING state because the connection.onopen function is never called. The console.log('Connected!') isn't being called. Could someone let me know what is going wrong here? Server import java.io.IOException; import java.net.ServerSocket; public

Accessing HttpServletRequest properties within a WebSocket @ServerEndpoint

南笙酒味 提交于 2019-11-28 06:25:31
问题 I need to access the HttpServletRequest properties to get the javax.servlet.request.X509Certificate which contains the X509Certificate array of certificates for TLS requests. From a JAX-RS ContainerRequestFilter I can easily extract this from the ContainerRequestContext.getProperty(String property) method, but I can't find a way to get it from the WebSocket Session nor the HandshakeRequest , from which I can access the HttpSession instance but not the HttpServletRequest one. Note: this is not

Tyrus websocket: IllegalStateException cannot set WriteListener for non-async request

Deadly 提交于 2019-11-28 02:17:52
I have a standard websocket endpoint based on Tyrus implementation which times to times triggers the java.lang.IllegalStateException: Cannot set WriteListener for non-async or non-upgrade request . We are running on Payara 4.1. My standard implementation @ServerEndpoint(value = "...", decoders=MessageDecoder.class, encoders=MessageEncoder.class) public class EndpointImpl extends AbstractEndpoint{ // onOpen, onClose, onMessage, onError methods } Where the abstract class is public abstract class AbstractEndpoint{ // irrelevant onOpen, onOpen handling method 117 protected void sendMessage(Session

Accessing ServletContext and HttpSession in @OnMessage of a JSR-356 @ServerEndpoint

旧巷老猫 提交于 2019-11-26 15:59:22
问题 I need to get the ServletContext from inside a @ServerEndpoint in order to find Spring ApplicationContext and lookup for a Bean. For the moment my best approach is to bind that bean in the JNDI naming context and lookup it in the Endpoint . Any better solution is welcome. I'm also looking for a reasonable way to sync servlet's HttpSession with websocket's Session . 回答1: The servlet HttpSession is in JSR-356 available by HandshakeRequest#getHttpSession() which is in turn available when a