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

websocket doesn't upgrade while hosted on IIS

I have a java application which use Websocket to communicate. Everything works fine in development environment but websocket doesn't work in production environment.Could anyone tell me the steps to config IIS. Now I have already enable websocket…
ye shi
  • 1
0
votes
2 answers

Websocket + Pretty Faces = AbstractMethodError

I'm building a simple JSF 2.3 app in tomcat 8.5. I got the websocket working, and then I added Pretty Faces. If I use them separately, they both work. I mean, if I remove Pretty Faces' dependencies from the pom, my websocket works. And if I keep the…
onzinsky
  • 541
  • 1
  • 6
  • 21
0
votes
0 answers

Is it possible to forward WebSocket streams inside Java Servlet?

I have a Java Servlet that is a web application firewall. It forwards all legitimate traffic to the backend application it protects in a very simple way: for (int length = 0; (length = input.read(byteBuffer)) > 0;) { output.write(byteBuffer, 0,…
Audrius Meškauskas
  • 20,936
  • 12
  • 75
  • 93
0
votes
1 answer

Websockets: and @ServerEndpoint

I'm currently digging into JSF 2.3 and websockets. The use of within xhtml pages and the definition of web socket endpoints using @ServerEndpoint is clear to me. But is there any way to combine those two to get to connect…
Thomas S.E.
  • 1,528
  • 16
  • 28
0
votes
1 answer

Java-WebSocket - Get Client certificate from Server for authentication

I've set up a websocket connection using Java-WebSocket with a working two-way TLS connection. However, to make Client Authentication possible I'd like to be able to get the information attached to the Client Certificate. This will contain some…
martijn p
  • 598
  • 4
  • 19
0
votes
0 answers

Java Websocket Server-Client decoder not working

I am creating a group chat functionality on my app and I am having some issues. Requirements are Java and Websockets in Java(both server and the client part). I have created both server and client WebSockets and communication by itself works(sending…
0
votes
0 answers

How to access a Managed Bean from WebSocket class

I want to access an @SessionScoped managed bean from WebSocket Endpoint class. I tried @ManagedProperty(value = "#{bean}") private Bean bean; in WebSocket class, but it throws: org.apache.tomcat.websocket.pojo.PojoEndpointBase onError …
0
votes
1 answer

Confirm data sent through socket had been received in the server

I defined the websocket in my android app as below: package com.oryx.geoop import android.content.Context import androidx.lifecycle.MutableLiveData import org.java_websocket.client.WebSocketClient import…
Hasan A Yousef
  • 22,789
  • 24
  • 132
  • 203
0
votes
0 answers

Send and receive data (say text) using web sockets between angular and java

i want to establish a backend to front end connection to view real time text on UI. For this i want angular as front end and java as backend (not considering spring right now as i am new to socketing). Communication should be to and fro...i.e. both…
0
votes
1 answer

JWT Bearer Token Authentication with Apache Camel AHC-WS Websocket Component

Context We are currently setting up a Springboot project using Apache Camel as the integration framework. At the end of our route we need to send messages with the WSS websocket protocol, where our application acts as the client and needs to send…
0
votes
1 answer

Deploy Websocket Client in Wildfly 13

I'm trying to deploy a Camel Route that use a Webscoket client as a consumer in Wildfly 13. When I try to run the project I got the follow error: Caused by: [java.lang.RuntimeException - Could not find an implementation class.]:…
vitorvr
  • 605
  • 1
  • 5
  • 19
0
votes
1 answer

Spring Websocket connection getting closed automatically with reason Invalid reserved bit

My spring websocket code runs in Liberty server. The code works fine in local. When I move to my server, when I try from 'Simple Websocket Client', I get an error like WebSocket connection to 'wss://url' failed: One or more reserved bits are on:…
0
votes
0 answers

Java Web Socket on Tomcat 9 - some problems

I am trying to implement Java Web Socket on localhost using Tomcat 9. I am following the example in the following link: https://examples.javacodegeeks.com/enterprise-java/tomcat/apache-tomcat-websocket-tutorial/#comments I was able to run Tomcat 9…
Zion Cohen
  • 182
  • 6
  • 19
0
votes
1 answer

how does code determine to use WebSphereRequestUpgradeStrategy vs TomcatRequestUpgradeStrategy?

I'm trying to use websockets and my spring app runs on Websphere Liberty. My Websockets connection does not work, and upon debugging with class libraries, I figured out that my code goes to TomcatRequestUpgradeStrategy and this one does not work,…
csharpnewbie
  • 789
  • 2
  • 12
  • 33
0
votes
0 answers

Making multiple same http request in optimized way

my code is looks like for (int i = 0; i < len; i++) { getResponse(); } I am making the request in for loop. Don't want to open the request every time and want to optimize this better way. How wan we do it in a better way? public static void…
user1023675
  • 289
  • 1
  • 4
  • 13