Network timeout on Android

Discuss any general programming issues here
zylesea
Posts: 198
Joined: Tue Feb 16, 2010 12:50 am
Location: Westfalen/Germany
Contact:

Network timeout on Android

Post by zylesea » Thu Sep 01, 2016 11:11 pm

I use something like this to check if an update of my programs is available.

Code: Select all

If IsOnline();my_online=True
          data$=DownloadFile("http://www.myurl.de/versionnumber", {silentfail=True})
          If Not (my_version = data$) Then my_versioncheck=True
Works on MorphOS and Windows, but on Android it waits the entire time defined with SetNetworkTimeout (tried with times up to 20s) and writes "receive timeout reached!" to the variable.
But it does sucessfully ping the host at least which I tested with a simple .php script on my severspace.
Is this an Android issue, am I doing something wrong here or is it a bug?

User avatar
airsoftsoftwair
Posts: 2968
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: Network timeout on Android

Post by airsoftsoftwair » Wed Sep 07, 2016 9:17 pm

What exactly fails in the code you posted? Does IsOnline() fail or DownloadFile()? Does DownloadFile() fail generally or only with this particular URL?

zylesea
Posts: 198
Joined: Tue Feb 16, 2010 12:50 am
Location: Westfalen/Germany
Contact:

Re: Network timeout on Android

Post by zylesea » Thu Sep 08, 2016 1:06 am

It#s the downloadfile function that fails. I tried with different files (my own version files but also with e.g. some Aminet readme file). On my MorphOS machine it does what it should do but on my Nexus Lollipop tablet it does not download the file to the variable. But as said, the url itself does get pinged as i checked that with a small php counter.

User avatar
airsoftsoftwair
Posts: 2968
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: Network timeout on Android

Post by airsoftsoftwair » Sun Sep 11, 2016 5:21 pm

Hmm, I tested the following code here:

Code: Select all

data$=DownloadFile("http://www.airsoftsoftwair.de/images/products/hollywood/47_shot1.jpg")
vf$ = DefineVirtualFileFromString(data$, "image.jpg")
LoadBrush(1, vf$)
DisplayBrush(1, 0, 0)
UndefineVirtualStringFile(vf$)
data$ = Nil
WaitLeftMouse
End
I tested it both as an applet started with the Hollywood Player and as a stand-alone APK compiled by the Hollywood APK Compiler. It worked fine without any problems. Does this script work for you? What Android version are you on? Are you using the Hollywood Player or a stand-alone APK?

User avatar
airsoftsoftwair
Posts: 2968
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: Network timeout on Android

Post by airsoftsoftwair » Sun Sep 11, 2016 6:05 pm

Btw, tested it with both cellular and Wi-fi networks. Both worked fine with Android 6.

zylesea
Posts: 198
Joined: Tue Feb 16, 2010 12:50 am
Location: Westfalen/Germany
Contact:

Re: Network timeout on Android

Post by zylesea » Tue Sep 13, 2016 1:42 am

Your code freezes on my tablet. A white screen opens and nothing happens, hollywood player gets irresponsive and Android says "Hollywood reagiert nicht".
On MorphOS the same code snippet works flawlessly.
The devices are within the same WLAN, Android is V 5.1.1.
Strange, isn't it?

Will try with an .apk as well (don't have access to the compiler machine tonight though), but doubt that will change behaviour. But I may catch an output from the usb android debug console, maybe there's a hint in there.

User avatar
airsoftsoftwair
Posts: 2968
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: Network timeout on Android

Post by airsoftsoftwair » Tue Sep 13, 2016 9:38 pm

Ok, I've now tested it on an Android 4 device since I don't have an Android 5 device here and indeed, on Android 4 it doesn't work and freezes the program. I'll examine what's going on there.

zylesea
Posts: 198
Joined: Tue Feb 16, 2010 12:50 am
Location: Westfalen/Germany
Contact:

Re: Network timeout on Android

Post by zylesea » Wed Sep 14, 2016 1:45 am

I ran the script while running adb.exe logcat. But I don't see an error or alert there. Then again I am not too experienced with reading such a log. Anyway, here it is, maybe it's useful to you:

Code: Select all

I/LogTag  (22461): HollywoodPlayer 6.1 [Android] (c) by Andreas Falkenhahn
I/LogTag  (22461): The Cross-Platform Multimedia Application Layer
I/LogTag  (22461):
I/LogTag  (22461): Opening script online_test.hwa...
I/LogTag  (22461): done
I/LogTag  (22461): Compiling script...
I/LogTag  (22461): done
I/LogTag  (22461): Loading applet online_test.hwa...
I/LogTag  (22461): done
I/LogTag  (22461): Preparing display...
I/threaded_app(22461): NativeWindowResized: 0x41dc7ea0 -- 0x5ab047b0
I/LogTag  (22461): done
I/LogTag  (22461): And Action!
I/LogTag  (22461):
I/LogTag  (22461): *** APP_CMD_WINDOW_RESIZED
E/WifiStateMachine(  471): WifiStateMachine CMD_START_SCAN source -2 txSuccessRa
te=2,38 rxSuccessRate=0,75 targetRoamBSSID=c8:0e:14:fa:33:72 RSSI=-65
E/WifiStateMachine(  471): WifiStateMachine starting scan for "Lillifee"WPA_PSK
with 2412
D/ConnectivityService(  471): updateNetworkScore for NetworkAgentInfo [WIFI () -
 105] to 60
D/ConnectivityService(  471): rematching NetworkAgentInfo [WIFI () - 105]
D/ConnectivityService(  471): Network NetworkAgentInfo [WIFI () - 105] was alrea
dy satisfying request 1. No change.
D/ConnectivityService(  471): notifyType AVAILABLE for NetworkAgentInfo [WIFI ()
 - 105]
D/ConnectivityManager.CallbackHandler(  678): CM callback handler got msg 524290

D/ConnectivityManager.CallbackHandler(27842): CM callback handler got msg 524290

D/ConnectivityManager.CallbackHandler( 1252): CM callback handler got msg 524290

D/ConnectivityManager.CallbackHandler( 3783): CM callback handler got msg 524290

E/WifiStateMachine(  471): WifiStateMachine CMD_START_SCAN source -2 txSuccessRa
te=1,05 rxSuccessRate=0,55 targetRoamBSSID=c8:0e:14:fa:33:72 RSSI=-62
E/WifiStateMachine(  471): WifiStateMachine starting scan for "Lillifee"WPA_PSK
with 2412
I/DownloadManagerWrapper(  952): onReceive() : Charging = true
E/WifiStateMachine(  471): WifiStateMachine CMD_START_SCAN source -2 txSuccessRa
te=0,50 rxSuccessRate=0,25 targetRoamBSSID=c8:0e:14:fa:33:72 RSSI=-62
E/WifiStateMachine(  471): WifiStateMachine starting scan for "Lillifee"WPA_PSK
with 2412
E/WifiStateMachine(  471): WifiStateMachine CMD_START_SCAN source -2 txSuccessRa
te=6,50 rxSuccessRate=8,00 targetRoamBSSID=c8:0e:14:fa:33:72 RSSI=-63
E/WifiStateMachine(  471): WifiStateMachine starting scan for "Lillifee"WPA_PSK
with 2412
E/WifiStateMachine(  471): WifiStateMachine CMD_START_SCAN source -2 txSuccessRa
te=1,02 rxSuccessRate=0,52 targetRoamBSSID=c8:0e:14:fa:33:72 RSSI=-62
E/WifiStateMachine(  471): WifiStateMachine starting scan for "Lillifee"WPA_PSK
with 2412
I/DownloadManagerWrapper(  952): onReceive() : Charging = true
E/WifiStateMachine(  471): WifiStateMachine CMD_START_SCAN source -2 txSuccessRa
te=0,50 rxSuccessRate=0,25 targetRoamBSSID=c8:0e:14:fa:33:72 RSSI=-63
E/WifiStateMachine(  471): WifiStateMachine starting scan for "Lillifee"WPA_PSK
with 2412
E/WifiStateMachine(  471): WifiStateMachine CMD_START_SCAN source -2 txSuccessRa
te=1,00 rxSuccessRate=0,50 targetRoamBSSID=c8:0e:14:fa:33:72 RSSI=-63
E/WifiStateMachine(  471): WifiStateMachine starting scan for "Lillifee"WPA_PSK    

User avatar
airsoftsoftwair
Posts: 2968
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: Network timeout on Android

Post by airsoftsoftwair » Wed Sep 14, 2016 11:11 pm

Hmm, sucks, now I'm unable to reproduce it on Android 4. It's working fine again, even with a stress test of constantly calling DownloadFile(). No issues at all. Maybe it was just a network error yesterday. I'm afraid the only way to solve this would be some sort of remote debugging on your device. I'd have to send you a build with debug output which you can then send to me to investigate into what's going wrong there.

zylesea
Posts: 198
Joined: Tue Feb 16, 2010 12:50 am
Location: Westfalen/Germany
Contact:

Re: Network timeout on Android

Post by zylesea » Thu Sep 15, 2016 12:36 am

airsoftsoftwair wrote:Hmm, sucks, now I'm unable to reproduce it on Android 4. It's working fine again, even with a stress test of constantly calling DownloadFile(). No issues at all. Maybe it was just a network error yesterday. I'm afraid the only way to solve this would be some sort of remote debugging on your device. I'd have to send you a build with debug output which you can then send to me to investigate into what's going wrong there.
If i can be of any help I am happy to do so. Just drop me a message when you have a build to test.

Post Reply