B4J Library jWebSocketClient library

Note: this library depends on jetty_b4j.jar, which is included in jServer3.zip: https://www.b4x.com/android/forum/threads/jserver3.141323/#content

With this library you can implement WebSocket clients. The API is identical to the B4A library: http://www.b4x.com/android/forum/threads/websocket-client-library.40221/#content (except of the object name which is WebSocketClient).

It is based on Jetty WebSocket client implementation.

The push client example was ported to B4J: http://www.b4x.com/android/forum/threads/custom-websocket-based-push-framework.40272/




This means that you can now implement an (almost) always connected solution with bi-directional communication running on Androids, desktops and browsers.

This is an internal library.

v1.13 - New SendTextAsync and SendBinaryAsync methods. Do not use SendText / SendBinary. By mistake they are sending the messages on the main thread which can lead to bad things. The old methods are kept for backward compatibility.


  • WebSocketPush.zip
    5.8 KB · Views: 2,419
  • jWebSocketClient.zip
    6 KB · Views: 324
Last edited:


Well-Known Member
Licensed User
Longtime User
Hi Erel,

As far as I know the library already existed for a few weeks: is there anything new in this library that made you create this post about an hour ago ?
Or has the B4J client library been added ?



Licensed User
Longtime User
Hi Erel can you give me the code of your server in the samples? ws://basic4ppc.com:51042/push/b4a_ws2 this one

KY Leng

Licensed User
Longtime User
Hi Erel,

I am not sure whether the server can be implemented on android device or not?
Secondly, do we need static IP for the server or only hosting is enough ?

Best regards,


Active Member
Licensed User
Longtime User
Does the library work with B4J v9.8? I can't get it to connect to a websocket jServer.


It turns out to be the new filter I added which causes the problem.

Public Sub Filter(req As ServletRequest, resp As ServletResponse) As Boolean
    Return False
End Sub