Questions tagged [jsr356]

JSR 356, Java API for WebSocket, specifies the API that Java developers can use when they want to integrate WebSockets into their applications—both on the server side as well as on the Java client side. Every implementation of the WebSocket protocol that claims to be compliant with JSR 356 must implement this API.

JSR 356 defines a standard API for creating WebSocket applications (as standardize by IETF in protocol RFC 6455) enabling Web clients or native clients leveraging any WebSocket implementation to easily communicate with a Java back end.

JSR 356 provide support in the Java EE platform for:

  • Creating WebSocket Java components to handle bi-directional WebSocket conversations
  • Initiating and intercepting WebSocket events
  • Creation and consumption of WebSocket text and binary messages
  • The abililty to define WebSocket protocols and content models for an application
  • Configuration and management of WebSocket sessions, like timeouts, retries, cookies, connection pooling
  • Specification of how WebSocket application will work within the Java EE security model

See:

55 questions
9
votes
2 answers

Tomcat8 WebSockets (JSR-356) with Guice 3.0

I am trying to @Inject a Guice service into a @ServerEndpoint. I am using Tomcat 8.0.15 as the JSR-356 implementation. However, the dependency injection isn't working. Is there any additional configuration that needs to be done in order to enable…
Aritra
  • 1,184
  • 11
  • 19
9
votes
1 answer

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

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…
qwtel
  • 2,831
  • 1
  • 15
  • 12
9
votes
3 answers

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

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()) { …
walv
  • 2,237
  • 2
  • 25
  • 35
8
votes
5 answers

Integrating JSR-356 WebSocket @ServerEndpoint with Spring 3 beans

I'm using Spring 3.2.5 without full new JSR-356 WebSockets support. I would like to have singleton-bean reference in my @ServerEndpoint WebSocket server, which is instantiated by servlet container itself, not in Spring context. What is the clean way…
Piotr Müller
  • 4,845
  • 3
  • 45
  • 79
7
votes
1 answer

Howto add request header to Tyrus annotation based client

I'm trying to access a websocket server endpoint using a tyrus standalone client (tyrus-standalone-client-1.9) with an annotation based client endpoint. I was mainly following this example. That is, my client endpoint currently looks like…
dpr
  • 8,675
  • 3
  • 32
  • 57
7
votes
3 answers

JSR-356 WebSockets with Tomcat - How to limit connections within single IP address?

I made a JSR-356 @ServerEndpoint in which I want to limit alive connections from single IP address, to prevent simple DDOS attacks. Note that I'm search for Java solution (JSR-356, Tomcat or Servlet 3.0 specs). I have tried custom endpoint…
Piotr Müller
  • 4,845
  • 3
  • 45
  • 79
6
votes
1 answer

Tomcat: using servlet and websocket (jsr356) in same web app

I create a sample webapp using Guice-servlets and websocket in tomcat, now once guice filter is used websocket stop working Basic information: In my web.xml, i initialized the Guiceservlet using GuiceBasedListener
Bhuvan
  • 3,509
  • 5
  • 26
  • 70
5
votes
3 answers

Springboot @ServerEndPoint "Failed to find the root WebApplicationContext."

I'm having trouble using spring with @ServerEndPoint annotated class i'm using Springboot 1.2.3 and i'm trying to figure it out how to have a single instance of the endpoint @SpringBootApplication @EnableJpaRepositories @EnableWebSocket public…
Y.M.
  • 589
  • 4
  • 16
4
votes
1 answer

Implement gzip compression on messages exchanged between Websocket Server and Client Endpoints written in Java

I don't see specific documentation around javax.websocket.Session's getBasicRemote() and getAsyncRemote()'s sendText() and sendBinary() methods as to how one could use gzip compression to transfer messages. I am writing a high performance messaging …
4
votes
1 answer

Ignore certificate validation - Tomcat8 WebSocket (JSR-356)

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…
UnahD
  • 667
  • 2
  • 7
  • 23
4
votes
1 answer

Java/Tomcat: how to handle WebSocket setup completion

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…
walv
  • 2,237
  • 2
  • 25
  • 35
4
votes
1 answer

Add header on WebSocket handshake with modifyHandshake

I'm trying to send a custom header during the handshake. I can intercept the handshake with the ServerEndpointConfig.Configurator and override modifyHandshake. public class WebsocketConfigurator extends ServerEndpointConfig.Configurator { …
Dominic
  • 3,063
  • 30
  • 46
3
votes
1 answer

Tomcat throws "The remote endpoint was in state [BINARY_FULL_WRITING] ..." when trying to write to websocket session concurrently

I am using tomcat 8.0.23 to terminate my websocket connections. I have the following code to take care of the incoming messages: @OnMessage public void onMsg(Session session, byte[] request) { executorService.execute(() -> …
kaptan
  • 2,850
  • 5
  • 27
  • 43
3
votes
1 answer

Access UserAgent in Websocket session?

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…
lathspell
  • 2,350
  • 1
  • 22
  • 41
3
votes
1 answer

How to test ServerEndPoint, ClientEndPoint?

I have implemented ServerEndPoint and ClientEndPoint, how can i test it? For example, i have Connection wrappers over Session and i want to test it behavior which depends on session data, also i want to test messaging between client and server. Note…
1
2 3 4