B4R Question AsyncStreams size limit


Active Member
Licensed User
Longtime User
I'm sending data using and ESP32 and prefix mode AsyncStreams and the B4Rserializer to a B4A app. It's several KB worth of log data.

It's working but only if the bytes sent and received are under 250 bytes give or take. Is there a reason for this? There isn't any MaxBufferSize in B4A as there is in B4R. Is the buffer limited to 256 bytes? Somewhere on the forum I've read that there is no size limit but my experience seems to indicate otherwise. I'd like to sen at least a few KB at a time although 200B at a time does the trick.

Has anybody else done this? Any ideas?

B4R code looks like this. Stack and MaxBufferSize is plenty large. bsize is how much to send at a time.

Private Sub snd_log
    Private bsize As UInt = 200
    Private fs As ESP8266FileSystem
    If fs.Exists("/logs.txt") Then
        Private fl As File
        Private b(bsize) As Byte
        Private ret As UInt      
        For i = 0 To fl.Size Step bsize
            astream2.Write(ser.ConvertArrayToBytes(Array As Object("logs",fl.Size,ret,b)))
    End If
End Sub

On the B4A app code looks like this. It receives and stores a chunk with each message and stores it to a file when it knows it has received it all.

Sub astream_NewData (Buffer() As Byte)
    Private data() = ser.ConvertBytesToArray(Buffer) As Object

    Select data(0)
        Case "logs"       
            If data.Length=4 Then
                Private b() As Byte = data(3)
                If logbuff.Length >= data(1) Then
                    File.WriteString(File.DirRootExternal, "log.txt",logbuff.ToString)
                End If
            End If
    End Select
End Sub