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
9
votes
1 answer

Spring WebSocket MessageMapping not working

I need to write chat. But I have a problem, I can't trigger MessageMapping controller. App contains of 2 parts, front-end which runs on 4200 port and back-end which is running on 8080 port. I have set all the configuration, but @MessageMapping…
9
votes
1 answer

How to test a Java EE7 Websocket

I have implemented a WebSocket using the api provided with Java EE 7. Additionally I have implemented a client that requests my WebSocket without any problems. To be sure this remains working when performing some code changes I want to implement…
J. Su.
  • 451
  • 1
  • 6
  • 18
9
votes
2 answers

What is the maximum size of data that can be passed through a WebSocket?

I am new to websockets and when I tried to pass a JSON with a length greater than 8192, the websocket disconnected immediately. However JSON with length <= 8191 works fine. Is there any MAX SIZE/ LIMIT of data that can be passed through a WebSocket?…
theapache64
  • 10,926
  • 9
  • 65
  • 108
8
votes
2 answers

Multithreading with websockets

This is more a design question. I have the following implementation Multiple Client connections -----> Server ------> Corresponding DB conns The client/server communication is done using web sockets. It's a single threaded application currently.…
user3616977
  • 527
  • 2
  • 5
  • 14
7
votes
1 answer

How to connect a java client to SignalR Hub using only websockets?

I need to access a websocket server that runs with SignalR Hub, from my Java desktop application. There is a library that does exactly that, but it's dead. There are lots of issues and pull requests and it hasn't been updated since 2015. I also…
7
votes
2 answers

How to properly report an error to client through WebSockets

How do I properly close a websocket and and provide a clean, informative response to the client when an internal error occurs on my server? In my current case, the client must provide a parameter when it connects, and I am trying to handle incorrect…
Saturn5
  • 108
  • 1
  • 7
7
votes
0 answers

Spring websockets without STOMP and SockJs but with message broker and routing support

Is there a way to use the facilities provided by Spring to have a webSocket connection without using SockJS and STOMP? I need to implement a proprietary webSocket protocol so I cannot use either one at the moment. I have implemented/hacked together…
Kaloyan Pashov
  • 155
  • 2
  • 11
7
votes
2 answers

What are the usecases of encoder list or decoder list in the WebSocket EndPoints annotation?

I am learning tyrus WebSocket implementation. But I don't understand why and when do we need more then one encoders or decoders in the websocket endpoints. For example: @ServerEndpoint(value = "/subscribe", decoders = {…
6
votes
1 answer

How to give certificate to Java Websocket?

Forgive me for the newb question, but I am confused and obviously not understanding the fundamentals or explanations of how to use a Websocket server hosted over HTTPS. Everything I find online leads me to have more questions than answers. I have a…
mcool
  • 457
  • 4
  • 29
6
votes
2 answers

Deploying game to server results in strange behaviour

I developed a breakout alike game with a friend using HTML5 WebSockets and java as backend and recently deployed my game on a Glassfish server that's running on the 20$ Digitalocean droplet (3GB ram, 2cpu's). When developing the game I worked with…
josephzigler
  • 285
  • 3
  • 13
6
votes
1 answer

Java Websockets - confused by the different options

I've been working on writing a Web Socket server in Java and this point has confused me for a while now. On GitHub there's this library by TooTallNate that's a "barebones WebSocket client and server implementation in 100% Java":…
rococo
  • 2,280
  • 2
  • 22
  • 37
6
votes
1 answer

Test websocket in spring boot application

I don't understand how properly write a test case for websocket in springboot application. I have a class that implement WebSocketHandler and I add this handler in WebSocketConfigurer: @Configuration @EnableWebSocket public class WebSocketConfig…
dzrkot
  • 543
  • 2
  • 4
  • 23
6
votes
2 answers

Spring Boot Stomp WebSocket

I seem to be running into an issue bumping up against the 8k size limit that embedded tomcat has for stomp websocket messages. When sending a message from server to client I am getting the following error. Based on the documentation I've read, it…
6
votes
1 answer

Tomcat closes websocket conection with an error

For a customer we build a HTML5 websocket application with Tomcat 8.0.29. If we start the application from our network or from our home network all works fine. But if the customer starts the application from his network, after a certain time the…
Daniel
  • 61
  • 1
  • 5
6
votes
1 answer

WebSocket Session closes after not receiving input for some time

So I have a Websocket Session that reads information from a server. However if I cut off the information that it's receiving completely, after about a minute or so it will stop receiving new information, and won't do anything, even when the output…
shadowarcher
  • 3,265
  • 5
  • 21
  • 33
1
2
3
34 35