• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Frits Walraven
Bartenders:
  • Carey Brown
  • salvin francis
  • Claude Moore

WebSocket Client 'Forcibly Closing' Connection  RSS feed

 
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I am attemting to use WebSockets for the first time, server-side using Tomcat, and client-side using 'Java-WebSocket' (https://github.com/TooTallNate).  The client application successfully connects to the Tomcat hosted webapp, sends it a serialised object (WebSocketConnectionRequest), but by the time the webapp responds a few seconds later with a serialised object of its own (WebSocketConnectionResponse) the client appears to have closed the connection.

Is there anyone here who has perhaps used the 'Java-WebSocket' library, and can explain why it is forcibly closing the connection rather than waiting to receive the ByteBuffer response?

Below is a log excerpt from the server-side webapp.  It seems to be a time out thing, as once in a while the client remains connected just long enough to receive and process the server response.

 
Christopher Dodunski
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi again.

Is there anyone here who has perhaps used the 'Java-WebSocket' library?

I've not yet found an explanation or solution to this problem.

Thanks,

Chris.
 
Saloon Keeper
Posts: 5395
143
Android Firefox Browser Mac OS X Safari Tomcat Server VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not familiar with that particular library, but have you gotten web sockets to work at all with your server setup? If not, a simple client/server example web app (for both web sockets and server-sent events) can be found at https://coderanch.com/t/685060/java/web-app-Server-Events-SSE
 
Christopher Dodunski
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Tim Moores wrote:I'm not familiar with that particular library, but have you gotten web sockets to work at all with your server setup? If not, a simple client/server example web app (for both web sockets and server-sent events) can be found at https://coderanch.com/t/685060/java/web-app-Server-Events-SSE



Hi Tim,

Yes, the connection initially works, but quickly closes.  The whole idea of using web-sockets is to keep connections open so that the server can push data to the client as and when needed, so a little annoying that it keeps closing.  I'm thinking it must be a configuration oversight.  I was expecting the library to work straight out of the box.

I'll take a look at the code you linked to for some clues, and change libraries if necessary.

Thanks,

Chris.
 
We should throw him a surprise party. It will cheer him up. We can use this tiny ad:
Create Edit Print & Convert PDF Using Free API with Java
https://coderanch.com/wiki/703735/Create-Convert-PDF-Free-Spire
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!