Android Question AStreams connection lost after phone idle time

gruizelgruis

Member
Licensed User
Longtime User
Hello,

I'm using astreams to connect to a server written in VB6.
Everything works great. But when I leave the phone alone for 15 min or so. The connection gets terminated.

On the VB6 server program The winsock_error routine gets fired.

But no "AStreams_Terminated" on the app.

As I thought is is the wlan connection on the phone that is going idle
I tried using both
WS.KeepAlive(True)
WS.PartialLock
from the PhoneWakeState

But still the problem occurs.

PLease help.
 

gruizelgruis

Member
Licensed User
Longtime User
Is the screen on and the activity in the foreground when it happens?

Are you handling AsyncStreams_Error event?
-Yes : The screen is on, and the activity is in the foreground.
- No : I'm not aware of teh error event. will try right away
 
Upvote 0

gruizelgruis

Member
Licensed User
Longtime User
When the error_event gets raised, then
LastException.Message = libcore.io.ErrnoException: recvfrom failed...

please advice
 
Upvote 0

gruizelgruis

Member
Licensed User
Longtime User
This did the trick for me

B4X:
Sub AStreams_error

'// verbindinig is verbroken. Nieuwe verbinding proberen te maken.
    Tmr.Initialize("Tmr1",3000) '/ seconden wachten (wait)
    Tmr.Enabled = True
    ToastMessageShow("Opniew verbinden .. ",True)
End Sub
Sub Tmr1_Tick
    '// reconnecting
    Socket1.Initialize("Socket1") '// <-- dit moet
    Socket1.Connect(Var_ServerIp,Var_ServerPoort,1001)
    Tmr.Enabled = False
    ToastMessageShow("Opniew verbinden .. ",True)
End Sub
 
Upvote 0

gruizelgruis

Member
Licensed User
Longtime User
I have created some logs on this issue. It seems the connection gets lost every 15min.
I'm still looking to prevent this from hapening.

I'm handeling the occasionaly communication breakdown in code now, and that works fine.

Is there a way to disable wlan powersave ?
I think thats causing it
 
Upvote 0

gruizelgruis

Member
Licensed User
Longtime User
Thank you hogiebaer.
I do have all the "Astreams" code as a sevice.
Could you post some code. Maybe I'm doing it all wrong.

thanks in advance
 
Upvote 0

hogiebaer

Active Member
Licensed User
Longtime User
ok. if you use your communication in services, the problem is that the wifi goto sleep (erel is right;)).
You can use the solution from the "erel-link" or go to the settings of the phone and change the wifi state to "never go sleep".

great success :)
 
Upvote 0

gruizelgruis

Member
Licensed User
Longtime User
Hi all, Just to follow up on this.
I found on the serverside computer
that the network card also has an option to save energy.


upload_2015-6-7_8-40-10.png
 
Upvote 0
Top