Android Question Force WiFi To Stay Connected on Samsung S8

scsjc

Well-Known Member
Licensed User
Longtime User
Hello,
When I use the app with the sleeping at phone Samsung S8 with android 7.0, at 5 minutes the app disconnects from wifi (even when it is debugmode disconnects from b4a)

Im use a Socket and AsyncStreams, and get this error:
B4X:
java.net.SocketException: Software caused connection abort
    at java.net.SocketInputStream.socketRead0(Native Method)
    at java.net.SocketInputStream.read(SocketInputStream.java:151)
    at java.net.SocketInputStream.read(SocketInputStream.java:120)
    at java.net.SocketInputStream.read(SocketInputStream.java:106)
    at anywheresoftware.b4a.randomaccessfile.AsyncStreams$AIN.run(AsyncStreams.java:195)
    at java.lang.Thread.run(Thread.java:762)
java.net.SocketException: Software caused connection abort
    at java.net.SocketInputStream.socketRead0(Native Method)
    at java.net.SocketInputStream.read(SocketInputStream.java:151)
    at java.net.SocketInputStream.read(SocketInputStream.java:120)
    at java.io.BufferedInputStream.fill(BufferedInputStream.java:235)
    at java.io.BufferedInputStream.read(BufferedInputStream.java:254)
    at anywheresoftware.b4a.shell.ShellConnector.readControlData(ShellConnector.java:191)
    at anywheresoftware.b4a.shell.ShellConnector.connect(ShellConnector.java:186)
    at anywheresoftware.b4a.shell.ShellConnector.run(ShellConnector.java:119)
    at java.lang.Thread.run(Thread.java:762)
java.net.SocketException: Software caused connection abort
    at java.net.SocketInputStream.socketRead0(Native Method)
    at java.net.SocketInputStream.read(SocketInputStream.java:151)
    at java.net.SocketInputStream.read(SocketInputStream.java:120)
    at java.net.SocketInputStream.read(SocketInputStream.java:206)
    at anywheresoftware.b4a.remotelogger.Connector.readData(Connector.java:123)
    at anywheresoftware.b4a.remotelogger.Connector.mainLoop(Connector.java:84)
    at anywheresoftware.b4a.remotelogger.Connector.run(Connector.java:53)
    at java.lang.Thread.run(Thread.java:762)
writer error
java.lang.InterruptedException


I've tried this solution this post : http://www.b4x.com/android/forum/threads/httpserver-problem-solved.30968/#post-180606 and dont work

I think it is some from data-saving or anything... anyone know how can lock wifi when phone is locked, and don't disconnect?

thanks
 
Last edited:

scsjc

Well-Known Member
Licensed User
Longtime User
As I know it might be a SW issue with your phone or a energy saving setting.

Do other apps like WhatsApp have any problems? (do you get notifications?)

Thanks for your answer....
yes i get the notifications from whatsapp
 
Upvote 0

scsjc

Well-Known Member
Licensed User
Longtime User
I found a dirty solution executing every 4 minutes :

B4X:
    Dim PhoneWakeState1 As PhoneWakeState
    PhoneWakeState1.KeepAlive(True)
    Sleep(1000)
    PhoneWakeState1.ReleaseKeepAlive

If someone have a good solution please tell me.
thanks.
 
Last edited:
Upvote 0

scsjc

Well-Known Member
Licensed User
Longtime User
Sometimes I need to disconnect, sleep, and wake up.... I see everything more clearly.

I am a fool, the fault was not the wifi connection,...
i use a service where I have open the socket.... and this service stoped at 5min... because I had not put "Service.StartForeground"
 
Upvote 0
Top