B4J Question Filesize of incoming data

aaronk

Well-Known Member
Licensed User
Longtime User
Hi,

I know I asked this question once before (some time ago) but now I can't find the thread I posted and searched the forum for it, and can't remember the answer to the question..

I have a B4J app that is listening on a port and allows B4A, B4i apps to connect and send ASCII messages to this B4J app.

Let's say the B4A app sends the message hello1234 I want to then log the incoming data size in my B4J app. For Example 100 bytes, 100kb, 1MB etc. Then when the next message comes in then add to this file size.
 

aaronk

Well-Known Member
Licensed User
Longtime User
Sorry, should of said..

I am doing this with ServerSocket with AsyncStream.
 
Upvote 0

aaronk

Well-Known Member
Licensed User
Longtime User
This is a mistake. You should use one of the other more powerful solutions
Yeah, I am planning on using websockets in the future but just looking at using serversockets for now. Then I plan on looking into MQTT and learning on how it works but need to look into that.

So just confirming if I get a message test1234 then it should log 8, which would mean it just received 8 bytes?
 
Upvote 0

aaronk

Well-Known Member
Licensed User
Longtime User
Is there a way to receive the file size of the MQTT ?

Looking though the mosquito documentation it says:

Clients can find information about the broker by subscribing to topics in the $SYS hierarchy as follows. Topics marked as static are only sent once per client on subscription. All other topics are updated every sys_interval seconds. If sys_interval is 0, then updates are not sent.

Note that if you are using a command line client to interact with the $SYS topics and your shell interprets $ as an environment variable, you need to place the topic in single quotes '$SYS/...' or to escape the dollar symbol: \$SYS/... otherwise the $SYS will be treated as an environment variable.
$SYS/broker/bytes/received
The total number of bytes received since the broker started.
$SYS/broker/bytes/sent
The total number of bytes sent since the broker started.

I tried subscribing to $SYS/broker/bytes/received but it retuned nothing.

Am I doing something wrong, or is there another way in doing it ?
 
Upvote 0

aaronk

Well-Known Member
Licensed User
Longtime User
So there is no way in finding out how many messages, or how much data has been sent throughout the MQTT broker ?

The only way I guess in finding out is getting the B4J Client MQTT to subscribe to each topic so it can see all messages being sent.
 
Upvote 0
Top