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

Cometd - Websocket open / active Connections count in real time

We are running jetty 9.2.9 on our production with cometd 3.0.1. We are trying to understand the current load on the system at any given point of time and estimate its maximum scale. Please suggest the best approach to accomplish the same. I tried…
0
votes
0 answers

How to implement connection failover in client side

I am trying to implement connection failover in android application. Basically I have list of URLs which application connect using websocket, In case of unable to connect with any url I need to try a second connection. API which I am using to…
user526206
0
votes
0 answers

how to register an endpoint listener?

i am using grails 3.0.9 , use javax.websocket to create a chatting application. this is my code... ` import grails.util.Environment import javax.servlet.ServletContext import javax.servlet.ServletContextEvent import…
Bobby Akyong
  • 231
  • 3
  • 14
0
votes
1 answer

Spring-Websocket: Send Updates to Subscribers when condition is met

I have the following method on a Spring @Controller: @MessageMapping("/comment/{id}") @SendTo("/topic/conversation/{id}") public OperationResult comment(Comment comment) throws Exception { //call @Service to add comment …
FourtyTwo
  • 734
  • 8
  • 19
0
votes
1 answer

Is it possible to send custom data with WebSocket handshake?

Let's say that I have my own customized web browser based on Java Chromium Embedded Framework (JCEF) and it internally runs a WebSocket server. Now my web app, running on my CustomWebBrowser, can use websockets to connect with the internal…
BlueChips23
  • 1,861
  • 5
  • 34
  • 53
0
votes
1 answer

Modifying/overriding a library class' methods properly

I'm using WebSocket Rails-Android library by ararog. I subscribe to a few channels in a loop based on data I receive from the server-side. I'm using the same WebSocketRailsDataCallback for all channels and the only varying thing is the channel name.…
Neria Nachum
  • 1,519
  • 1
  • 20
  • 37
0
votes
1 answer

Stopping a WebSocket from sending data

I am using Jetty's WebSocket API to stream data to a client. Once the client connects to the server, the server will send json data periodically to the client. @WebSocket public class WSHandler { // send data every 10 seconds public static…
oikonomiyaki
  • 7,691
  • 15
  • 62
  • 101
0
votes
0 answers

How can I connect to my websocket server running on my android emulator?

I have created a websocket server on android using Tootallnate java-websocket. I have hosted it in 10.0.2.2 and port number 15. How can I connect my client who is also running in the same emulator? When I use the below code, it connects even when…
AnOldSoul
  • 4,017
  • 12
  • 57
  • 118
0
votes
1 answer

Android WebView and WebSockets / Paho.MQTT

all similiar questions are already a few years ago so I might ask again: I made a website which includes the Paho.MQTT javascript client (mqttws31.js). It works fine on all browsers (also in Chrome on Android). Here's my code: var client = new…
0
votes
2 answers

getting "Handshake response not received." after closing websocket

I'm using tyrus websocket client (1.11) to connect to a websocket. compile 'org.glassfish.tyrus:tyrus-client:1.+' compile 'org.glassfish.tyrus:tyrus-container-grizzly-client:1.+' I'm running a local wscat server (wscat --listen) to test my…
copolii
  • 14,208
  • 10
  • 51
  • 80
0
votes
0 answers

Communication between Android web socket server with remote web socket client

I am working with web socket client in Android device, Able to communicating to a remote web socket server. But right now I want run web socket server on android device & I need connect it from a remote web socket client (like on the system…
0
votes
1 answer

Javascript cannot connect to websocket server endpoint

I have a java web application running on my private JVM on MochaHost. Application is running fine expect the websocket. I have a websocket endpoint on my JAVA application. I use annotations. @ServerEndpoint(value = "/websocket/chat/{room}",…
0
votes
1 answer

WebSocket immediately disconnects - Openshift

The WebSocket is working perfectly in localhost (tomcat) . but when i host (Openshift - tomcat) it immediately disconnects and not firing the onMessage method. I've checked the header and the status code is Status Code:101 Switching Protocols. Here…
theapache64
  • 10,926
  • 9
  • 65
  • 108
0
votes
0 answers

IBM Websphere Liberty profile: JSP attribute jdkSourceLevel is "15"

I just deployed a hello world kinda application on IBM WebShphere Liberty profile. The deployment was successful but I'm getting error when accessing the application. The application was bascically Java WebSocket implementation using Project Tyrus.…
pijushcse
  • 510
  • 9
  • 31
0
votes
2 answers

How to setup and deploy WebSocket on WSO2 AS 5.2.1?

I have a working JAX-RS webapp that implement some RESTfull services. I have developed it under WSO2 Studio and deployed it with WSO2 AS Web interface, all very simple. Now I want add on my WebApp the possibility to open a WebSocket. I don't have…
Elia
  • 1,417
  • 1
  • 18
  • 28