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 to send an image using websockets in java?

I am trying to send an image by drag and drop in send message area but its failing to do so. I dont know how to send an image in this code. Can someone please help me out? ChatEndpoint.java This is serverendpoint of websocket.I have four…
0
votes
1 answer

Update Data in Real Time when getting from server into RecylerView

I am getting json from Websockets and showing in recyler view. How do i update the list in real time when getting data from websockets? My WebSocket Class public final class EchoWebSocketListener extends WebSocketListener { private static…
0
votes
1 answer

Getting Non-Printing Characters, Preceded by NAK, from Java Socket using ASCII protocol

This is a strange one. I have a Runnable tasked with sending a message to a socket and retrieving the response. When I create a test class that simply creates an instance of the Runnable, sends the message and gets the response, I get the expected…
Agi Hammerthief
  • 2,114
  • 1
  • 22
  • 38
0
votes
2 answers

WebSocket through Apache and Tomcat 500 Error : java.lang.UnsupportedOperationException: HTTP upgrade is not supported by this protocol

I was implementing Web Socket using JavaScript on the client and Java/Tomcat on the server. It works very fine on localhost but when I deploy on my remote host it fails. Checking the console, I get 500 error on the Web socket request. Hence i check…
ayez1389
  • 58
  • 7
0
votes
1 answer

Java Websocket with tomcat localhost

I don't know if this is the right one to post to, correct me and I will switch! I am using java with eclipse photon with Apache tomcat 9. I am making a application that will be connected to server (local host or make a local host on the pc) and then…
user3038404
  • 331
  • 5
  • 14
0
votes
0 answers

How to use omnifaces socket without CDI?

I would like to use Omnifaces Socket as an alternative solution for Primefaces Push which is on the way to remove in the future. I already checked the showcase(http://showcase.omnifaces.org/push/socket) and found that it needs the CDI to init the…
0
votes
1 answer

Connect to ssl web socket as a client on wss://ws.luno.com/api/1/stream/:pair

I am trying to connect to wss://ws.luno.com/api/1/stream/:pair Instructions are at https://www.luno.com/en/api towards the bottom of the page I have successfully run the accepted answer from Connecting to a secured websocket However when I replace…
0
votes
1 answer

Web sockets and Rest API in same Tomcat based application

I have read up on web sockets providing full duplex connections over TCP which can be used in scenarios where long polling was used to get live updates to client from server. Now I have a Tomcat based application which serves multiple REST based web…
HariJustForFun
  • 521
  • 2
  • 8
  • 17
0
votes
1 answer

WebSocket in Java Servlet (Tomcat 9) without classpath scanning

I'm trying to set up WebSocket in Java Servlet (Tomcat 9) without classpath scanning, but I'm stuck with this error: javax.websocket.DeploymentException: Multiple Endpoints may not be deployed to the same path [/test/{accountId}] : existing…
wiradikusuma
  • 1,930
  • 4
  • 28
  • 44
0
votes
0 answers

Context.xml file is broken. what purpose of context.xml of java webapplication?

ant -f D:\Documents\Documents\PRJ321\WebApp -Dnb.internal.action.name=run -Ddirectory.deployment.supported=true -DforceRedeploy=false -Dnb.wait.for.caches=true -Dbrowser.context=D:\Documents\Documents\PRJ321\WebApp run init: deps-module-jar: …
0
votes
0 answers

java websockets & ping

I am discovering java API for websockets (JSR 365), and I would like to write a test that would verify that the server is run. my question is simple : if I ping the IP adress of the computer with the server' port , will I get an answer? thank you ps…
lolveley
  • 1,659
  • 2
  • 18
  • 34
0
votes
2 answers

TCP socket doesn't throw any exception when sending messages even though network connection is dropped

I have created a TCP web socket client in Java and connected it to a remote TCP server. In normal conditions it is working properly. I need to detect the socket disconnection and handle some logic once disconnection triggers. I'm planning to detect…
diyath.nelaka
  • 193
  • 14
0
votes
1 answer

Trying to connect websocket to a client endpoint that is secure throws error: XNIO000100: 'https' URL scheme chosen but no SSL provider given

I'm trying to create a websocket in java that listens to a local application on the endpoint f.ex. "wss://localhost.localapp.com:8080/". The application do send through that websocket information about what is happening. When I run the…
OuuGiii
  • 1,053
  • 1
  • 11
  • 31
0
votes
1 answer

Message handling in onMessage WebSocket

I'm trying to implement a WebSocket client. My code is here: import org.json.JSONObject; import javax.websocket.*; import java.io.IOException; public class MyClientEndpoint extends Endpoint { private Session session; @Override public void…
Dina Bogdan
  • 4,345
  • 5
  • 27
  • 56
0
votes
2 answers

"import javax.websocket.*;" showing error on android studio

I'm trying to get some data from a trading platform (https://www.binary.com). The code samples for getting data from them is provided at the developers' site (https://developers.binary.com/demos/). Since I was using android studio, I opted for…