Bug? OkHttpUtils2 v3.02 + Firebase receiver

JCO

Active Member
Licensed User
Longtime User
Hello,

I have a project that needs to do some checking to a server when it opens, so it has a couple of HttpJobs calls from Activity_Create
It also uses Firebase messaging, and so the Starter service has this:
B4X:
Sub Service_Create()
    CallSubDelayed(FirebaseMessaging, "SubscribeToTopics")
End Sub

Sometimes (depending on Firebase's time of response, the token refresh happens after the jobs have been received.
When that happens, the jobs never end, that is, the Wait For never gets passed, so I can't know there's an error

I've tried postponing the job launch with sleep, then with a timer. That works most of the time, but sometimes the tokenRefresh takes longer and one can't never know.
The log looks like this:

Log when the issue happens:
Logger connected to: d9b0a1040aa4570e
--------- beginning of main--------- beginning of system
** Activity (main) Create  **
** Activity (main) Resume **
** Activity (main) Create  **
** Activity (main) Resume **
** Activity (main) Resume **
Copying updated assets files (34)
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create (first time) **
https://fm.serverhere:4443/connect.php?jas={"jsonpackage"} '<-- Here's where the http job has been sent
** Activity (main) Resume **
sending message to waiting queue of uninitialized activity (subscribetotopics)
sending message to waiting queue of uninitialized activity (submitjob)
https://fm.serverhere:4443/connect.php?jas={"anotherpackage"} '<-- Here's where another http job has been sent
sending message to waiting queue of uninitialized activity (submitjob)
*** Receiver (firebasemessaging) Receive (first time) ***
*** Receiver (httputils2service) Receive (first time) ***
TokenRefresh: eDsKqEyESOiSjf3lRoyUlR.... '<-- The firebase token has been refreshed AFTER the job was received...
*** Receiver (httputils2service) Receive  *** '<-- ... it never processes the previous jobs

Logs when working fine:
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create (first time) **
https://server/connect.php?jas={"thepackage"}
** Activity (main) Resume **
*** Receiver (firebasemessaging) Receive (first time) ***
*** Receiver (httputils2service) Receive (first time) ***
TokenRefresh: eDsKqEyESOiSjf3lRoyUlR:A... '<-- The firebase token has been refreshed BEFORE the job was received...
Server response time: 0.328 '<-- Right after Wait For Job
*** Service (sync) Create *** '<-- Launched by the code after Wait For Job
** Service (sync) Start **
'.... Everything fine here
 

JCO

Active Member
Licensed User
Longtime User
Thanks Erel.

I was afraid that it would be something like that. Can't afford now to rewrite the whole project to B4XPages, so I guess I'll just try my luck with timers
 

JCO

Active Member
Licensed User
Longtime User
Works like a charm! Many thanks 👍
 
Top