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
0 answers

High latency when running a web server in java. bufferedReader.readLine() has 500ms+ runtime

So I've been making a server for broadcast control recently however I just ran into some issues with the reading of the lines. When the connect comes in I am creating a new thread and that is where the connection is processed. All the data is…
bcci152
  • 9
  • 2
0
votes
1 answer

Jetty WebSocket - onWebSocketClose session wanted

I'm struggling how to find out the session when receiving the onWebSocketClose event. Official docs: https://www.eclipse.org/jetty/javadoc/current/org/eclipse/jetty/websocket/api/WebSocketAdapter.html#onWebSocketClose(int,java.lang.String) It says…
DubZ
  • 580
  • 3
  • 12
0
votes
0 answers

Webbit server not working properly in android app

I'm trying to server an HTML file to users who are connected on the same network using the webbit library. This is what I expect: Pressing a button in the android app to start the HTTP server (HTML file is under assets/web/index.html) Any of the…
Nithis Kumar
  • 278
  • 2
  • 5
  • 21
0
votes
0 answers

Communication between Java and Python Script

I'm creating a chatbot using Thymeleaf and Logback-classic for Java ( web part, localhost ) and Tensorflow for my python script ( which is on the desk). My python script works as this: i.e: The user asks a question , the bot answers it. I want to…
elmachina
  • 23
  • 5
0
votes
1 answer

How to pass message to controller by @MessageMapping with specified user url?

I have such problem. When i try to send message from client side to server, it doesn't match with my @MessageMapping methods. I don't know how to intercept messages on controller layer. Client side sends message (it's react-stomp that uses…
0
votes
0 answers

Application using Omnifaces Socket is working fine on Wildfly but wont deploy on Weblogic

I'm developing chat app using OmniFaces version 2.7 o:socket and it works like a charm when I deploy it to WildFly 13.0.0 Final but it won't deploy on WebLogic Server Version: 12.2.1.3.0. Here is the stack trace I'm getting: Caused By:…
Kiki
  • 2,243
  • 5
  • 30
  • 43
0
votes
1 answer

There is no suitable serializer for class org.springframework.web.socket.adapter.standard.StandardWebSocketSession

One of the use cases of project is when user connects to the server with userId the session should be maintained. If any server events happen (a record added or in any business logic) we should notify the connected user. I'm trying to persist the…
mperle
  • 3,342
  • 8
  • 20
  • 34
0
votes
1 answer

Occasional NullPointerException when publishing STOMP message using SpringFramework

I am running into some occasional NPE when publishing STOMP messages using Spring (5.2.0). Unfortunately I cannot precisely provide the steps to reproduce but I was hoping to get some insight into how this could happen. I looked into the source and…
0
votes
0 answers

Why is the Java websocket server so slow?

I'm running a Java websocket server on an AWS server. To dispatch a message to clients (in my case, another AWS server I own in a different region), I use either of the following: // this javax.websocket.Session.getAsyncRemote().sendText("") // or…
Jase
  • 1,025
  • 1
  • 9
  • 34
0
votes
1 answer

Using RxJava for request response layer with WebSockets

I'm trying to implement a request -> response layer on top of websockets in Java. I recently stumbled across RxJava, which seems like a nice library to use for this. Down below is my current approach for handling the request response flow…
rosengrenen
  • 731
  • 6
  • 21
0
votes
0 answers

Print text from a java class method within a .jsp page in reel time

I'm trying to write the message received from the client connected to the WebsocketServer in a .jsp web page in real time using the onMessage method of java class. Please I need help. import java.io.IOException; import…
Sofia DM
  • 21
  • 3
0
votes
1 answer

javax.websocketclient : how to send large binary data from clientendpoint to serverendpoint

I'm trying to build a server client application using jetty. I have setup a jetty server and configured websockets. Sending text messages works fine between client and server. But how binary data as inputstream could be sent from client endpoint. I…
0
votes
1 answer

How can I listen to a Quarkus Websocket using Angular 9?

As the questions suggests, I want to build a service that syncs JSON data between users using a Websocket. But I am quite new to websockets, so I need your help. I use the following Versions: Frontend: Angular: 9.1.0 Backend: Quarkus: 1.3.2.Final +…
0
votes
0 answers

How to create a service in Spring to listen to request

I'm a newbie in Spring framework. I already have a Spring service which sends some requests to /topic/liveFeed. Here is the code for the existing service I have public class DataPublisher { @Autowired private SimpMessagingTemplate webSocket; …
HHH
  • 6,085
  • 20
  • 92
  • 164
0
votes
0 answers

JSF 2.3 onmessage listener function not firing

Since PrimeFaces have deprecated Push I'm trying to get JSF 2.3 working om GlassFish 5. I'm having trouble firing my listener though. I have the following code: @Inject @Push(channel = "notifyjsf") private PushContext…
zobbo
  • 117
  • 2
  • 13