Questions tagged [java-websocket]

Use this tag for questions related to Java based server side implementation of WebSocket.

Java SE has no standard API for WebSocket, there's a 3rd party library: Java-WebSocket.

Writing your own WebSocket Server

The org.java_websocket.server.WebSocketServer abstract class implements the server-side of the WebSocket Protocol. A WebSocket server by itself doesn't do anything except establish socket connections though HTTP. After that it's up to your subclass to add purpose.

Writing your own WebSocket Client

The org.java_websocket.server.WebSocketClient abstract class can connect to valid WebSocket servers. The constructor expects a valid ws:// URI to connect to. Important events onOpen, onClose, onMessage and onIOError get fired throughout the life of the WebSocketClient, and must be implemented in your subclass.


Java EE has a standard API for server side implementation of WebSocket: JSR356.

524 questions
0
votes
1 answer

Using CDI/injection in Tomcat Websocket / Serverendpoint

i am using tomcat 9.0.4 and Java 1.8. In the same project, jersey is providing an webservice. I can use @Inject from the webservice classes without any problem. I am trying to get injection working from my websocket endpoint display…
Mr Mueseli
  • 55
  • 7
0
votes
1 answer

Howto update a data table cell via mdb-> websocket in jee-7? (db pk, clientId mapping)

I have a jsf-2.2 primefaces datatable with paging. One column displays a status of a network component and on table loading I asynchronously query an external service over a resource adapter. When the data table is loaded the status cells are…
Jochen Buchholz
  • 370
  • 1
  • 16
0
votes
0 answers

OnClose not called in ServerEndpoint with Java EE websocket

I have a simple websocket endpoint, using the javax.websocket library, but the method intercepting with the OnClose annotation is never called even though OnOpen and OnMessage are called. I've tried subclassing ServerEndpoint as well without any…
Jesper
  • 472
  • 1
  • 4
  • 14
0
votes
1 answer

Prevent Tomcat from sending header "Connection: close"

My Tomcat Websocket Server has the attribute "Connection" double in the reply header for connections via https: "upgrade" and "close". Not for connections via http, only "upgrade" here. This will cause Safari to disconnect. How can I prevent…
Jan Knoblauch
  • 219
  • 1
  • 3
  • 20
0
votes
1 answer

How to receive message from Akka Http Web-socket Client?

Currently, we are using this to send the message to Client Flow[Message] .mapConcat(_ ⇒ Seq.empty[String].toList) .merge(source) // Stream the data we want to the client .map(data => TextMessage(data)) val source =…
S.K
  • 480
  • 1
  • 4
  • 19
0
votes
1 answer

How can I get the port of session.getRequestURI() in a Java EE @ServerEndpoint

In my Java EE - Eclipse Oxygen environment with tomcat9 the port is always -1(should be 62114)! @OnOpen @Encoded public void onOpen(@PathParam("BenutzerID") Long BenutzerID, @PathParam("Grad") long Kontaktgrad, @PathParam("Accesskey") String…
0
votes
0 answers

Tomcat Secure Websocket iOS 'Connection' header value is not 'Upgrade'

My website connects with JavaScript to a JavaServer Websocket (Tomcat 7.0.76). I use Secure Websocket (wss) and all works as expected on Chrome (Windows/Linux), Android and older iOS devices, but on newer iOS devices, I get the following…
Jan Knoblauch
  • 219
  • 1
  • 3
  • 20
0
votes
1 answer

How to get message from javax websocket server when connection has been opened

I had been wrote a simple javax websocket app. I'm trying to send data from @OnOpen method via session to client like this @OnOpen public void onOpen(Session session) throws IOException { session.getBasicRemote().sendText("Client…
Nesquik27
  • 234
  • 1
  • 7
  • 18
0
votes
1 answer

session is not getting timeout after specified time when adding servlet filter in java websocket

I have websocket in one of my webapplication used to populate the notification message. The entire application is a ear file and we have multipe war file in it and this websocket endpoint is one war file. It contains below: …
0
votes
1 answer

Jetty websockets and abstracthandler

I am trying to get a normal AbstractHandler and WebSocketAdapter to work at the same time. jetty-version: jetty-9.4.8.v20171121, I have a simple class Foo that extends org.eclipse.jetty.server.handler.AbstractHandler. Also a class Bar that extends…
user2329125
0
votes
0 answers

how a spring boot websocket server transfers a file from an external resource, not other clients

I am new in spring boot and web services. I am supposed to create a websocket in spring boot so that it could transfer XML files from server to its connected clients. As I understood, the server only bypasses the file/messages to clients that it…
setiabb
  • 529
  • 1
  • 5
  • 13
0
votes
1 answer

Tomcat 9 web socket examples

I am tring to compile (javac) the Tomcat examples specifically the echo endpoint.java examples /WEB-INF/classes folder has an echoendpoint.class file. I must assume it came precompiled in the zip file for tomcat9 since I cant seem to get it to…
0
votes
1 answer

check java websocket authentication after login to the application and before @OnOpen connection

I am implementing avax.websocket to update the count for message as below in my application. I want to secure the websocket endpoint and I used the below in web.xml and weblogic.xml but it did not work. After that I tried to use custom…
0
votes
0 answers

WebSocket with Service has create new Connection every time startService

I am beginner with using service and webSocket. I am trying to connect and send String on webSocket using Service in Android but when calling StartService(), it gives me anew Connection every time.I need to send text string every time without…
0
votes
0 answers

how I know if client received or no

I have this code for client class CCLI { public static void main(String args[]) throws Exception { CCLI ccli = new CCLI() ; BufferedReader inFromUser = new BufferedReader(new InputStreamReader(System.in)); …