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

Failed to resolve compile "org.java-websocket:java-websocket:1.3.2"

I am developing chat application based on a demo from github. They used java-webocket:1.3.2, I was using java-websocket:1.3.1 but I got error because in 1.3.1 there is no setSocket() method. Then I changed in the gradle my version and suddenly I got…
Abdurakhmon
  • 2,813
  • 5
  • 20
  • 41
0
votes
1 answer

Web Sockets in multiple page web project

i'm looking for nice tutorial or, maybe, some tips how to implements web sockets in multi-page web project. For example i have welcome page and some link here. When i press on link i should be redirected to www.domainname.com/anypath with another…
Darthoo
  • 301
  • 1
  • 2
  • 14
0
votes
0 answers

How to read websocket response code through automation scripts

Suppose I have a resource that is hosted on a websocket server, and I wish to validate the response status code 101, after the connection is upgraded, how and which libraries to use. Im currently looking at jayway response library, when I connect to…
MrKickass
  • 93
  • 1
  • 13
0
votes
0 answers

How to write a proxy pass in Grizzly Server without using apache or nginx

I have two Grizzly servers running my environment. 1. Grizzly server (A) private(internal) with Web socket. 2. Grizzly server (B) public server. web socket client should access the web socket server via the server B . Does anyone knows , is it…
0
votes
1 answer

Add topic/subscription after stomp client is connected

I am currently using https://github.com/NaikSoftware/StompProtocolAndroid to connect websocket using STOMP. I have a simple implementation as public class TestActivity extends AppCompatActivity { private StompClient…
SarojMjn
  • 569
  • 1
  • 7
  • 23
0
votes
1 answer

Define Websocket in Jetty Embedded in Karaf

I am using Apache Karaf 4.0.7 to create a server application using Websockets to communicate with a client application to send/receive data. I want to define a Websockets endpoint for the embedded Jetty server already running in Karaf. Here is the…
0
votes
1 answer

NoClassDefFoundError with Java Web Start and Websockets

My applet works in Eclipse when I run it with "Run As -> Java Applet", but when I try to launch it with a JNLP file, I get a NoClassDefFoundError. Im trying to use the javax.websocket-api inside my application, which uses the tyrus…
Jakob
  • 1,156
  • 3
  • 15
  • 26
0
votes
1 answer

Can Java websocket server ignore large messages rather than closing the connection?

Specs: Java 1.8 Tomcat 8.0.39 WebSocket API 1.1 Occasionally one of my clients will send a large payload (greater than the default 8192 byte buffer size) and when this happens the server kills the connection with a CloseReason of 1009 (Too Large).…
preston.m.price
  • 646
  • 1
  • 10
  • 17
0
votes
2 answers

Is the Java Websockets send method async or does it wait?

I am using the Java Websockets library from https://github.com/TooTallNate/Java-WebSocket. I would like to calculate the latency between sending messages. When using the send(message); function, will that wait until the server receives the packet…
Ajay
  • 437
  • 7
  • 22
0
votes
0 answers

Send message to a specific socket id from android/ java client using Socket.IO java client library

Connect to socket through Socket.io api successfully done. Send message via "socket.emit(event,msg)" succeed. How to get socket id after connected to socket? Java (client) code snippet: IO.Options opts = new IO.Options(); opts.forceNew =…
0
votes
1 answer

WebSocket Handshake on Tomcat returns Unexpected Response Code 500

I have a WebSocket application that registers the endpoint programmatically, without the use of Annotations. The relevant code is: ServerEndpointConfig.Configurator configurator = …
isapir
  • 21,295
  • 13
  • 115
  • 116
0
votes
1 answer

jetty-maven-plugin closes websocket with CloseReason[1006,WebSocket Read EOF] on any message send to client

I've got java server application which uses jetty-maven-plugin in its pom.xml org.eclipse.jetty jetty-maven-plugin 9.3.14.v20161028
Mark Vilkel
  • 55
  • 1
  • 5
0
votes
2 answers

Uri path param in jetty 9 websocket

I have created websocket using spark 2.5 runs on jetty 9 server on client side URI looks like in websocket client : ws://localhost:8004/myservice/clientid on Server Websocket , @websocketconnect i want to build logic using 'clientid' How to capture…
prateem tadas
  • 33
  • 1
  • 6
0
votes
0 answers

binary file from java to javascript via websocket

I have a Java-Server with an open websocket connection to the javascript client. I want to transfer a binary file from the java server to the javascript client so that the user just has to save the file somewhere in the filesystem. On client side I…
eventhorizon
  • 2,977
  • 8
  • 33
  • 57
0
votes
1 answer

Format to send and receive data using wss (websocket)

I am working on Websocket currently. So do I send and receive data using wss protocol? I am already using HTTP post and get but need to upgrade to wss. Please help. Thanks in advance
Daisy_s
  • 109
  • 9