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

Spring WebFlux authenticated WebSocket connection

I have running Spring Boot@2.2.x server with exposed WebSocket endpoint. Here is my WebSocketConfiguration: @Slf4j @Configuration public class WebSocketConfiguration { private static final String WS_PATH = "/ws/notifications"; @Bean …
5
votes
3 answers

How to check is a Websocket connection is alive

I have a websocket connection to a server: import javax.websocket.*; import java.io.IOException; import java.net.URI; import java.net.URISyntaxException; @ClientEndpoint public class WebsocketExample { private Session userSession; private…
Ben
  • 6,321
  • 9
  • 40
  • 76
5
votes
2 answers

How to set proxy for Spring StandardWebSocketClient

I am trying to establish a WebSocket connection using Spring StandardWebSocketClient, but getting an error due to proxy settings as the server is running behind the proxy. Below is the code I am using. StandardWebSocketClient…
5
votes
1 answer

How do websockets work in detail?

There's a fantastic answer which goes into detail as to how REST apis work. How do websockets work in the similar detail?
Greg
  • 8,175
  • 16
  • 72
  • 125
5
votes
0 answers

opening handshake response is empty in socket io client Android

I am implementing nv-websocket-client for Android. I am getting an error in Log with like that. How to get connection successfully ? com.neovisionaries.ws.client.WebSocketException: The status line of the opening handshake response is empty. 09-18…
5
votes
1 answer

Spring Websocket Configuration: using WebSocketMessageBrokerConfigurationSupport and WebSocketConfigurer together - how?

I am configuring currently my Spring Websocket using the class public class WebSocketConfig extends WebSocketMessageBrokerConfigurationSupport now I came across the advice Spring STOMP Websockets: any way to enable permessage-deflate on server…
onkami
  • 8,791
  • 17
  • 90
  • 176
5
votes
1 answer

Websocket(Jetty) : How to handle the binary data on server side which is coming in chunks

I need to setup a websocket server which can receive audio data sent by the client. I am using Jetty for this. My handler code : { @OnWebSocketClose public void onClose(int statusCode, String reason) { } @OnWebSocketError public…
shantanu
  • 1,748
  • 3
  • 19
  • 34
5
votes
3 answers

Java websocket draft refuses handshake

I am working on android(Java) using TooTallNate's java websockets from this tutorial to consume websockets on android to connect with ws:// but I am getting error draft org.java_websocket.drafts.Draft_10@4560b1d0 refuses handshake. I tried their…
CookieMonster
  • 492
  • 6
  • 18
5
votes
0 answers

koush Websocket handshake failing

I am trying out the library by koush https://github.com/koush/AndroidAsync. @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); AsyncHttpClient.getDefaultInstance().websocket(uri, null, new…
user3133966
  • 193
  • 1
  • 12
5
votes
1 answer

How to initialize a WebSocket Endpoint with constructor parameters

I am using javax.websocket.* API right now but I don't know how to initialize an Endpoint with some constructor parameters after searching on the Internet. ServerContainer container = WebSocketServerContainerInitializer.configureContext(context);…
bitdancer
  • 1,215
  • 2
  • 19
  • 34
5
votes
2 answers

What are the available Java EE Websockets implementations?

For the JSR 356 - Java API for WebSocket i know the reference implementation is Tyrus. Are there any others? If not, then i guess Tyrus is the implementation in all Application Servers (Glassfish, JBossAS/Wildfly etc...)
SoftwareDeveloper
  • 1,094
  • 2
  • 15
  • 26
5
votes
1 answer

WebSocket guaranteed delivery free framework

I have some kind of system that send messages from Java back-end to Web front-end constantly. I use Openfire with XMPP protocol as a transport system. But XMPP is just a transport protocol, it do not guaranty delivery in case when Internet…
Eazy
  • 3,212
  • 5
  • 24
  • 40
4
votes
1 answer

How many total TCP connections are created for web socket call from browser to apache http server to web service

I would like to know how many TCP connections are created when WebSocket call is made from browser to apache http server to backend web service? Does it create a separate TCP connection from the browser to apache http server and from apache to the…
Shashank
  • 249
  • 2
  • 13
4
votes
1 answer

Expected HTTP 101 response but was '200 OK' when trying to connect echo/websocket

I am just working on an android application written in native Java. I am using a server in this application so I am working with WebSockets. I am getting this error java.net.ProtocolException: Expected HTTP 101 response but was '200 OK' while…
Daniel Eppler
  • 51
  • 1
  • 3
4
votes
1 answer

Send data via okHttp socket

I'm trying to connect with websocket and the test socket is working wss://echo.websocket.org with my code but my WebSocket is not working and getting failed but whenever I try with the browser it works. My Android code // val request: Request =…
Farhana Naaz Ansari
  • 7,524
  • 26
  • 65
  • 105
1 2
3
34 35