Android Question Return HttpJob

Cleidson

Member
Hello everybody,
I would like to inform you right away that I am a complete layman when it comes to networks. My knowledge in this area is limited.
I was studying FCM and, through research on the forums and the responses I received to a post (https://www.b4x.com/android/forum/threads/about-fcm.160392/) I set up a server in B4J with the examples from Erel (https://www.b4x.com/android/forum/threads/b4x-firebase-push-notifications-2023.148715/) and Alexander Stolte(https://www.b4x.com/android/forum /threads/firebase-service-server-example.91191/).

To send the push message, in B4A, I use the following call:

B4X:
Notify(topic, "Message")

B4X:
Public Sub Notify(topic As String, note As String)
    
    Try
        Dim job As HttpJob
        job.Initialize("job", Me)
        Log(topic)
        job.PostString(linkNotificacao, $"topic=${topic}&title=title&body=${note}"$)
        Wait For (job) JobDone(j As HttpJob)
        If j.Success Then
            Log(j.Response.StatusCode)
            'Log("OK")
        Else
            Log(j.Response.StatusCode)
            Log("No success!")
        End If
        job.Release
    Catch
        Log("Last:" & LastException)
    End Try
End Sub

I receive push messages normally. But, after 30 seconds the following message returns:
ResponseError. Reason: java.net.SocketTimeoutException: timeout, Response:

j.Response.StatusCode return -1

I even read some topics that deal with this return, but the answers were not satisfactory.
The B4J server is installed on a VPS.

I might think it's normal since I receive the messages, but, thinking about networks and information security, I come to ask you, who have more experience:
Is this structure right or is there something I can improve in the code?
 

Cleidson

Member
Erel and Aeric,
Thanks for the tips. I will turn my attention and studies to the server. I hadn't thought about these possibilities because the application was sending push messages normally.
 
Upvote 0
Top