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

how can we send a message to particular WebSocket connection from server side

how can we send a message to particular WebSocket connection.
0
votes
0 answers

Can't Access Atmosphere MetaBroadcaster in Spring Boot Controller

I have a simple chat application set up using Spring Boot (1.3.2) and Atmosphere (2.4.2). Here is my WebSocketConfigurer: package com.chat.shared.websocket; import java.util.Collections; import javax.servlet.ServletContext; import…
Matthew Vita
  • 213
  • 2
  • 14
0
votes
1 answer

javax / websocket / CloseReason $ CloseCode

I refer to this tutorial https://blazemeter.com/blog/websocket-testing-apache-jmeter I run websocket java in jmeter ,but jmeter log responsed like this - jmeter.JMeter: Uncaught exception: java.lang.NoClassDefFoundError: javax / websocket /…
blue
  • 217
  • 6
  • 18
0
votes
1 answer

setBroadcaster(Broadcaster) from the type SimpleWebSocket is not visible in Grizzly java

I use Grizzly to setup websocket server in java. My problem is that I can't set broadcaster to websocket to use optimized one by overriding WebSocketApplication. I followed the way the documentation describe. But I got that error. The method…
Arkar Aung
  • 3,554
  • 1
  • 16
  • 25
0
votes
1 answer

WebSocket connection to 'ws://*' failed: Error during WebSocket handshake: Unexpected response code: 404

You can find the all the code below, started the tomcat server and It's perfectly working. But While making websocket request I'm getting 404 error. This is the error in chrome console : WebSocket connection to…
mahem
  • 1
  • 1
  • 4
0
votes
0 answers

No active contexts for scope type javax.enterprise.context.RequestScoped

when I run this code I go this error No active contexts for scope type javax.enterprise.context.RequestScoped any help please , what should I do? I'm using this code to do chatting between different user so I'm the servlet bean extract different…
steve.vai
  • 49
  • 1
  • 6
0
votes
1 answer

How to get remote client address in javax.websocket server?

I have a jetty 9.3.6 server that runs a websocket webapp. I would like to get the client IP address for bookeeping purposes, and I can see it is there in the javax.websocket.Session object, but I don't know how to get it as the API doesn't allow for…
Sonny
  • 2,103
  • 1
  • 26
  • 34
0
votes
1 answer

Several connections remain open with websocket client inspite of websocket close

I am using socket.io-client 0.6.3 https://github.com/socketio/socket.io-client-java for making websocket client. I have written a connect method as below:- public void connect(String host, int port) throws Exception { socket =…
ashishgupta_mca
  • 578
  • 6
  • 27
0
votes
1 answer

How to get WebSocket Instances from embedded JettyEmbedded

I'm creating new jetty javax.websocket server dynamically in the following code. ServerEndpointConfig serverEndpointConfig = ServerEndpointConfig.Builder.create( WebSocketVpnServerChannel.class, "/" + path +…
Roberto
  • 169
  • 9
0
votes
1 answer

WebSocket - Javascript client says connected, but Java server doesn't

I have very simple code, yet, it doesn't work perfectly. In Java server it just says Hello and Bye when opening and closing a connection and prints a sent message: @ApplicationScoped @ServerEndpoint("/tictactoe") public class WebSocketServer { …
Humberd
  • 2,794
  • 3
  • 20
  • 37
0
votes
1 answer

Tomcat 7: WebSocket upgrade doesn't work

I am trying to run my WebSockets Application on my Raspberry PI. I've downloaded and unpacked Tomcat 7.0.67. Then I started the Tomcat-Manager and deployed my "wsock.jar" that only contains one file: // ChatServer.java package wsock; import…
user5444681
0
votes
1 answer

Does WebSocket's ClientEndpoint receive data in the same order it was sent by the ServerEndpoint?

I'm using RemoteEndpoint.Async's sendText() method in a loop to send some data to the ClientEndPoint. As the data is sent asynchronously from the ServerEndpoint, will it be received by the ClientEndpoint in the same order as it was sent ?
UnahD
  • 867
  • 2
  • 10
  • 25
0
votes
1 answer

Store data in ServerEndpoint

I'm developing a simple app with WebSockets. Client side you can send input texts, while the server side is implemented via a Java class with annotated as ServerEndpoint. Here the input texts received get decoded and sent to all of the open…
user3673449
  • 347
  • 2
  • 5
  • 20
0
votes
1 answer

jetty 9 add websockets handler to handler list

All handlers in that example work apart from the websockets handler WebSocketHandler wsHandler = new WebSocketHandler() { @Override public void configure(WebSocketServletFactory factory) { …
user3732793
  • 1,699
  • 4
  • 24
  • 53
0
votes
0 answers

grails 3.0.9 WebSocket 404 error

i am trying to create chat application with grails. i am using grails 3.0.9 and tomcat-8.0.28 Sorry for duplicate i read this question and this... but thats not solve my problem.. i already change javax.websocket-api to provided like this : provided…
user2809386