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

Websocket endpoint returns 404

I am new to the Java EE 7 websocket principle. I have a Java EE 7 server deployed on Wildfly 10. I have configured a context path and an application path. I am able to reach the server by…
cayz
  • 1
  • 2
0
votes
1 answer

EnityManager Injection via HK2 in WebSockets

I have written 2 WebSocket ServerEndpoints that inject Services that themselves interact with the Database using injected instances of the JPA EntityManager. The application is a web application deployed on a Tomcat Server, using Jersey as JAX-RS…
John Reese
  • 583
  • 2
  • 6
  • 17
0
votes
1 answer

how to set TOS flag using websockets in java

i want to use websockets in my java application, but have to specify the TOS flag. Is there a common way to do this properly? how do i configure socket settings typically? thanks in advance!
Thomas
  • 1
0
votes
1 answer

How to refresh the view using websocket getting the data from database

I need to refresh a part of my view without refreshing the whole page. At my index.html page I have three panels, where one shows the number of Tickets by their status, I need to refresh this number every time a new ticket is created or updated. I…
0
votes
1 answer

Injection variable to websocket annotation @ServerEndpoint("/myVar")

I have chat which mapping to static URL. I need get the opportunity creating rooms for user. How to inject variable in annotation @ServerEndpoint("/myVariable") when app already running? class SomeClass{ public void createRoom(User user) { …
Pavel
  • 2,005
  • 5
  • 36
  • 68
0
votes
1 answer

Java8 Secure WebSocket Handshake Problems (Tyrus and Jetty)

I'm attempting to implement a WebSocket Client in an application that supports secure transmissions through SSL. The application already supports standard SSL connections over HTTP, by implementing custom Key and Trust managers (these custom…
Robert K
  • 472
  • 4
  • 17
0
votes
0 answers

How to handle javascript object blob of unknown type

I am trying to do an experiment to stream screen content on an Android device to a remote web browser. I am using web socket to stream the content. I am using this library to implement a websocket server on Android device side:…
darklord
  • 5,077
  • 12
  • 40
  • 65
0
votes
1 answer

Java Websocket Server with Java websocket client

I am trying to write a java based crawler which authenticates over https and then once authentication completes the client has to invoke an https request to upgrade the connection to websocket Host: User-Agent: Mozilla/5.0 (Macintosh; Intel…
simple
  • 23
  • 3
0
votes
2 answers

How to re-render Wicket component after the Event reception

I have a Wicket component which is listening for some event (IEvent). If such event arrives, I want to re-render the component with a changed model. There are no active controls on the page, like AjaxLink, which can trigger the re-rendering. Is…
Vít Kotačka
  • 1,472
  • 1
  • 15
  • 40
0
votes
0 answers

Getting time out in jmeter

I am trying for a webscoket connection using websocket sampler. For that for that firstly I am adding a http request for websocket server since my application internally binded with ws and externally can view with http.I am getting…
anu shaji
  • 39
  • 3
  • 8
0
votes
1 answer

How to implement Websocket using jetty

I need some idea to start a small task. Basically, I want to create a single WebSocket client and server in which server send multiple requests to the client and then client process these request and reply it back. I am using a Jetty API for both…
user526206
0
votes
2 answers

How to authenticate request made to camel webscoket

We are using camel web socket component for publishing real time data. We want to authenticate clients so if user is authorised then he/she should be able to access that websocket url. Please let me know is there any standard way which camel…
user1047873
  • 230
  • 3
  • 8
  • 28
0
votes
0 answers

How do I inject an event into a servlet in JavaEE7?

I have a @ServerEndpoint that adds web socket sessions and I want it to @Observes an event that will be fired by a servlet and then broadcast a message to all the web sockets. I get a NullPointerException in my servlet when I try to use the event…
Don Rhummy
  • 24,730
  • 42
  • 175
  • 330
0
votes
1 answer

Establish websocket communication between two Tomcats

I'm learning websockets. What I have done is established a websocket connection with Tomcat as server endpoint and for client side I have used JavaScript. Everything is fine. What I want to know is if it is possible to have another Tomcat…
javaworld
  • 427
  • 1
  • 9
  • 19
0
votes
1 answer

netty LoggingHandler prints multpile messages in one frame and counts length too big

I have built a WebSocket client to keep sending same message to an echo server and count the received bytes. The sever returns message like : WebSocketData[received message] But when I check the log printed by LoggingHandler, the received messages…
ayw
  • 1
  • 1