jsr356

Java WebSockets: The remote endpoint was in state [TEXT_FULL_WRITING]

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-21 09:08:44
问题 I am trying to implement some application based on websockets which will communicate with JS clients quite intensively. The code to send the message is quite primitive: synchronized (session) { if (session.isOpen()) { session.getBasicRemote().sendText(message); } } For rare sending it works just fine, but when few threads are trying to send some messages by the same session (socket), next exception is thrown (please note that it is not multithreading issue because code block is synchronized

Java WebSockets: The remote endpoint was in state [TEXT_FULL_WRITING]

廉价感情. 提交于 2019-12-21 09:08:26
问题 I am trying to implement some application based on websockets which will communicate with JS clients quite intensively. The code to send the message is quite primitive: synchronized (session) { if (session.isOpen()) { session.getBasicRemote().sendText(message); } } For rare sending it works just fine, but when few threads are trying to send some messages by the same session (socket), next exception is thrown (please note that it is not multithreading issue because code block is synchronized

Websocket JSR-356 fail with Jetty 9.4.1

吃可爱长大的小学妹 提交于 2019-12-17 20:32:28
问题 My current web server is embedded Jetty 9.1.5. It works well with JSR-356 to create websocket. These days, I am trying to upgrade to Jetty 9.4.1. Everything works nicely except websocket. My code like below: Embedded Jetty and Websocket libs: <dependency> <groupId>org.eclipse.jetty</groupId> <artifactId>jetty-server</artifactId> <version>9.4.1.v20170120</version> </dependency> <dependency> <groupId>org.eclipse.jetty</groupId> <artifactId>jetty-webapp</artifactId> <version>9.4.1.v20170120<

Java/Tomcat: how to handle WebSocket setup completion

我的梦境 提交于 2019-12-10 21:57:39
问题 I have the following scenario: few Tomcat instances with the same application need to connect between each other on startup. For connection between servers, WebSockets (JSR-356) are used. When Tomcat has started, I need to initiate the establishment with another server. How can I handle the most correctly, that internal WebSockets mechanism is up and I can start using WebSockets? Application is based on Spring 4. I tried this Execute method on startup in spring, this How to add a hook to the

Ignore certificate validation - Tomcat8 WebSocket (JSR-356)

落花浮王杯 提交于 2019-12-10 15:54:45
问题 SslContextFactory sec = new SslContextFactory(); sec.setValidateCerts(false); WebSocketClient client = new WebSocketClient(sec); The above code is implemented for Jetty WebSockets, to tell the java client to disable certificate validation. Is there any way I can achieve the same in Java API for Tomcat8 WebSockets (JSR-356)? PS: I have tried this method. It didn't work for Secure WebSocket connection of Tomcat WebSockets 回答1: Did you generate self signed certificate and trying to use it? Then

Access UserAgent in Websocket session?

点点圈 提交于 2019-12-10 10:15:11
问题 Using the Tyrus reference implementation of Java's "JSR 356 - Java API for WebSocket", I cannot find a way to access the HTTP connection that was used for the Websocket upgrades. Thus, I cannot access the HTTP headers that the browser sent. Is there a way to read the HTTP UserAgent header? Casting a "Session" object to "TyrusSession" or similar would be acceptable, I have to do it to get the Remote Address anyway. Sending the UserAgent again as a message inside the Websocket connection would

Using Java API for WebSocket (JSR-356) with Spring Boot

白昼怎懂夜的黑 提交于 2019-12-07 00:21:11
问题 I'm new to Spring (and asking questions on stackoverflow). I'd like to start an embedded (Tomcat) server via Spring Boot and register a JSR-356 WebSocket endpoint to it. This is the main method: @ComponentScan @EnableAutoConfiguration public class Server { public static void main(String[] args) { SpringApplication.run(Server.class, args); } } This is how the configuration looks: @Configuration public class EndpointConfig { @Bean public EchoEndpoint echoEndpoint() { return new EchoEndpoint();

Access UserAgent in Websocket session?

荒凉一梦 提交于 2019-12-06 05:18:45
Using the Tyrus reference implementation of Java's "JSR 356 - Java API for WebSocket", I cannot find a way to access the HTTP connection that was used for the Websocket upgrades. Thus, I cannot access the HTTP headers that the browser sent. Is there a way to read the HTTP UserAgent header? Casting a "Session" object to "TyrusSession" or similar would be acceptable, I have to do it to get the Remote Address anyway. Sending the UserAgent again as a message inside the Websocket connection would be my fallback solution. WARNING: ServerEndpointConfig is shared among all endpoint instances and

Using Java API for WebSocket (JSR-356) with Spring Boot

半世苍凉 提交于 2019-12-05 03:14:29
I'm new to Spring (and asking questions on stackoverflow). I'd like to start an embedded (Tomcat) server via Spring Boot and register a JSR-356 WebSocket endpoint to it. This is the main method: @ComponentScan @EnableAutoConfiguration public class Server { public static void main(String[] args) { SpringApplication.run(Server.class, args); } } This is how the configuration looks: @Configuration public class EndpointConfig { @Bean public EchoEndpoint echoEndpoint() { return new EchoEndpoint(); } @Bean public ServerEndpointExporter endpointExporter() { return new ServerEndpointExporter(); } } The

Java WebSockets: The remote endpoint was in state [TEXT_FULL_WRITING]

喜欢而已 提交于 2019-12-04 03:05:09
I am trying to implement some application based on websockets which will communicate with JS clients quite intensively. The code to send the message is quite primitive: synchronized (session) { if (session.isOpen()) { session.getBasicRemote().sendText(message); } } For rare sending it works just fine, but when few threads are trying to send some messages by the same session (socket), next exception is thrown (please note that it is not multithreading issue because code block is synchronized by session): java.lang.IllegalStateException: The remote endpoint was in state [TEXT_FULL_WRITING] which