Android Question Issues with Internet requests in Start Service

Christian García S.

Active Member
Licensed User
Hello,

I have an application that uses geofences to alert users when they enter a certain place.

These geofences are added when you start the application, there is another service that runs when the phone is restarted to add the geofences.

When the user enters the geofence there is an alert with a PUSH (NB6), there are two ways to send the PUSH message.

1. Through a WEB Service you get the custom message from the Internet.
2. When the user does not have internet, the app will send a generic message, it is determined whether or not the user is connected to the internet by making a request through an HTTPJOB to a web service that returns "connected".

Geofence_Enter events are within Starter Service.

The problem is the following, I have performed tests with my phone which always has an Internet connection, and many times the phone throws the generic message, checking the logs that I save in a log file inside the phone I see that the HTTP request to the web service Internet connection fails.

Is there any cause that the starter service and the Geofence_Enter event when loading do not have access to the Internet? Or what could be the reason that when the request is made to the Web Service it fails ???

You can guide me in some way how to solve this

Thanks.
 

Christian García S.

Active Member
Licensed User
Thanks Erel,

This is the error:

java.net.SocketTimeoutException: failed to connect to www.domain.net/xx.xx.xx.xx (port 443) from /xx.xx.xx.xx (port 45904) after 10000ms

I increased the wait time to 100 seconds but the same thing happens.

I have other case with remote push notifications where I perform the same behavior (FirebaseMessaging service in fm_MessageArrived event), the notification arrives and I read the content in real time in a WS, but only 30% of people who have the APP reach the PUSH, I think the same thing is happening.

Thanks
 
Last edited:
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
I have other case with remote push notifications where I perform the same behavior (FirebaseMessaging service in fm_MessageArrived event), the notification arrives and I read the content in real time in a WS, but only 30% of people who have the APP reach the PUSH, I think the same thing is happening.
Doesn't sound related.

java.net.SocketTimeoutException: failed to connect to www.domain.net/xx.xx.xx.xx (port 443) from /xx.xx.xx.xx (port 45904) after 10000ms

I increased the wait time to 100 seconds but the same thing happens.
Increasing the time out will not help if the connection was not available when the request was sent. Try to resend the request after a few seconds.
 
Upvote 0

Christian García S.

Active Member
Licensed User
Thanks @Erel, do you think I can put a sleep with a 5 seconds before to send http request ?

Do you think it is better with sleep or if the request fails call the same function again(recursive)?
 
Upvote 0
Top