B4J Question send and receive binary with websockets

narek adonts

Well-Known Member
Licensed User
Longtime User
Hi,

I am making a mesanging application and I decided to make the backend in b4j.

I was thinking to using mqtt broker as the server but without some events of the broker it is not possible (authorizations,...)

And I decided to use jServer with websockets. But it seems that in jServer websockets only support support String to send and receive data.

Is there a way to send/receive bytes instead of string?

Narek
 

OliverA

Expert
Licensed User
Longtime User
Is there a way to send/receive bytes instead of string?
B4J's jServer WebSocket implementation does not support binary data directly. One way around that would be to Base64 encode the data. Note that jServer has a limit on how much can be transferred at one time via WebSockets (the limit can be changed. See https://www.b4x.com/android/forum/threads/websocket-received-data-exceeds-limit.90678/). You could also use WebSockets for textual communications and regular server handlers for binary transfers (see https://www.b4x.com/android/forum/threads/sending-binary-data-over-websocket.44776/#post-273894).
 
Upvote 0

narek adonts

Well-Known Member
Licensed User
Longtime User
B4J's jServer WebSocket implementation does not support binary data directly. One way around that would be to Base64 encode the data. Note that jServer has a limit on how much can be transferred at one time via WebSockets (the limit can be changed. See https://www.b4x.com/android/forum/threads/websocket-received-data-exceeds-limit.90678/). You could also use WebSockets for textual communications and regular server handlers for binary transfers (see https://www.b4x.com/android/forum/threads/sending-binary-data-over-websocket.44776/#post-273894).

Thank u. I know this )) I thought that maybe we could add some Java code to add the functionality
 
Upvote 0

narek adonts

Well-Known Member
Licensed User
Longtime User
B4J's jServer WebSocket implementation does not support binary data directly. One way around that would be to Base64 encode the data. Note that jServer has a limit on how much can be transferred at one time via WebSockets (the limit can be changed. See https://www.b4x.com/android/forum/threads/websocket-received-data-exceeds-limit.90678/). You could also use WebSockets for textual communications and regular server handlers for binary transfers (see https://www.b4x.com/android/forum/threads/sending-binary-data-over-websocket.44776/#post-273894).
The problem is not only authorization. Some backend work like add to database, notification, ... lot of things must be done. ACL file is not a good solution if the ACL file is too large, so if the users increase it will be an issue
 
Upvote 0
Top