Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java (Android) WebSocket Client Libraries [closed]

There are some libraries to implement WebSocket usage in an unobtrusive fashion. Apparently, there are many libraries out, but what I really looking is a modern and small library which I can use on Android or Java in generall to implement my WebSocket usage from the client side.

So far I have found:

  • AndroidAsync
  • Play Framework
  • JAX-RS 2.0

I am missing a bit the differences of the differnet libraries. JAX-RS 2.0 for instance seems to be a great foundation for a lot of implementations, but I also went with Square's Retrofit for my RESTful Client because it was just leaner and easy to integrate.

like image 711
RevMoon Avatar asked May 22 '14 11:05

RevMoon


People also ask

What causes WebSockets to close?

This is likely due to client security rules in the WebSocket spec to prevent abusing WebSocket. (such as using it to scan for open ports on a destination server, or for generating lots of connections for a denial-of-service attack).

Can I reopen a closed WebSocket?

Once the original connection has been closed, you need to create a new websocket object with new event listeners: var SERVER = 'ws://localhost:8080' var ws = new WebSocket(SERVER) ws.

Can Android use WebSockets?

The WebSocket protocol paved the way to a truly realtime web. At the time of writing this article, the Android SDK does not have native support for WebSockets. However, it relies on the Java Development Kit (JDK), which includes support for WebSockets as part of javax. websocket package.

How long WebSockets stay open?

However, the connection between a client and your WebSocket app closes when no traffic is sent between them for 60 seconds.


1 Answers

I just work on one of my first web socket app in android. So I do lot of R&D before I starting and at last I found these two libs are very simple and useful for my requirement.

1 ) AndroidAsync (For clients )

2 ) Java-WebSocket (https://github.com/TooTallNate/Java-WebSocket ) for Server

Both are very simple and easy to use.

like image 82
khurram Avatar answered Oct 17 '22 17:10

khurram