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

WebSocketServlet in a WAR-file: Bad character 13 for SelectChannelEndPoint

On Mac with Oracle java "1.8.0_45" I have create a Jetty base dir with: # java -jar /Users/afarber/jetty-distribution-9.3.10.v20160621/start.jar jetty.home=/Users/afarber/jetty-distribution-9.3.10.v20160621 jetty.base=/Users/afarber/jetty-base…
Alexander Farber
  • 21,519
  • 75
  • 241
  • 416
0
votes
0 answers

jetty 9.3 not sending all text messages through websocket

I have a websocket server based on Jetty v9.3.9 The server sends text messages to clients from different Threads. A single client can receive multiple simultaneous messages from 2 different threads. For example: Thread 1: "message A" Thread 2:…
Doua Beri
  • 10,612
  • 18
  • 89
  • 138
0
votes
1 answer

In jetty, what class is used to create client connection to the server in java

Am very New to jetty. I have a sample code that am practicing with. But i dont seem to understand which of the jetty classes in my code is used to create the client connection to the jetty server. For example in core java socket programming, the…
Young Emil
  • 2,220
  • 2
  • 26
  • 37
0
votes
1 answer

wss web socket creation issue

I got - closed connection -1 , draft org.java_websocket.drafts.Draft_17@75599672 refuses handshake , false - then changed the code as below: Socket creation coode webClient = new APICWebClient(new URI(getWebSocketUrl(currentApic.IPAddress,…
Prakash
  • 145
  • 1
  • 13
0
votes
0 answers

Multiple responses from a REST call when expecting one

In our project we have implemented spring websockets(4.1.7) functionality but using xhr streaming. UI is developed in angular-JS. From the time we implemented the websockets, we observed lot of exceptions in catalina.out. We are using sockJS…
Milind
  • 531
  • 2
  • 12
  • 24
0
votes
1 answer

What's the third request that serversockt accept from?

I learn the code from the first example of . here is the index.html Welcome to BrainySoftware
Welcome to BrainySoftware. I know…
user4259440
0
votes
0 answers

Debug Client - Server application in Android Studio

I am trying to create a client-server application. I use Libgdx framework and develop the app by using Android Studio. My problems are: 1) How can I debug client and server in Android studio? I do not mind using android devices as clients and my…
0
votes
1 answer

How to get a specific Value or Data using the API in Java

Sorry if the question is a bit simple. I am new to this and i am currently trying to fetch some values using a websites API. I will drop a link below. Here is the issue. The code i have is the exact code the website provided. I want to take the…
0
votes
0 answers

Android waiting websocket response

In my application I have a websocket https://github.com/TakahikoKawasaki/nv-websocket-client. I send some commands to the server in my AsyncTask and showed progressBar. So I need to wait 60 seconds for response from the server after sending…
0
votes
1 answer

Creating a Secure Websocket (wss) Server in Java

My main objective is to maintain TLS on a secure website. I'm currently running ws on an https site, the "SSL Lock" in Chrome is appearing red/broken because I am using a non-authenticated source from an https website. I need to secure the WebSocket…
skamazin
  • 757
  • 5
  • 12
0
votes
1 answer

websocket api - image encoding yields no image type on client side

I have a web socket server on tomcat 8 with the following binary use: sess.getBasicRemote().sendBinary(bf); where bf is a simple image to bytes conversion as follows: BufferedImage img = ImageIO.read(...); ByteArrayOutputStream baos = new…
0
votes
0 answers

WebSocket for message notification is not working for some browser

I have implementing message notification system in play 2.4 using WebSocket. When i tested this on chrome Version 48.0.2564.116 (64-bit) (windows 8 and mac) + mozilla (windows 8 and mac), it's working. But when i tested it on windows 7 chrome…
visingh
  • 233
  • 3
  • 17
0
votes
2 answers

First client server project

I'm trying to develop my first Client-Server project using Netbeans, whose task is to take news from various websites and then sending them to an Android App(client). The Problem is, this is the first time i'm doing something like this. I've studied…
someCoder
  • 185
  • 3
  • 15
0
votes
1 answer

Jwebsocket : How to send the request to a specific client by name

I am trying to establish a connection between a single server and lots of clients(more than 100). I am using websocket for the client and jwebsocket for the server. The clients should always stay connected and the server should send request to a…
user880386
  • 2,737
  • 7
  • 33
  • 41
0
votes
1 answer

WebSocket Handshake Error with AWS

I'm running a Java server (Jetty, to be specific) on an AWS EC2 instance using WebSocket to connect to a client's browser. When I do this locally (hosting the server on my computer, not AWS), it runs fine. However, when I move the code to an EC2…