Page 1 of 1
Network Timeout When Connecting To An Android Server
Posted: Wed Mar 25, 2020 3:16 am
by PEB
Try this server code:
Code: Select all
CreateServer(1)
SystemRequest("Server", "This is the port: "..GetLocalPort(1, #NETWORKSERVER), "OK")
Function p_ClientConnect()
SystemRequest("Connection Established", "We have connection!", "OK")
EndFunction
InstallEventHandler({OnConnect=p_ClientConnect})
Repeat
WaitEvent
Forever
For the client just use
OpenConnection() with the correct IP address and whatever port is auto-chosen and displayed by the server. This works fine between my Amiga and my wife's Windows machine. But if the server code is run on an Android device, I cannot connect to it with
OpenConnection()---I always get a timeout error.
Re: Network Timeout When Connecting To An Android Server
Posted: Sat Mar 28, 2020 12:26 pm
by airsoftsoftwair
Hmm, I'm not sure if security restrictions allow Android apps to open ports. What port does it report if you run this code on Android?
Re: Network Timeout When Connecting To An Android Server
Posted: Sat Mar 28, 2020 5:49 pm
by PEB
It doesn't let you open a low number port (like 25); but if you let it choose a port, it will open one with a number such as 57016.
Re: Network Timeout When Connecting To An Android Server
Posted: Sat Mar 28, 2020 11:44 pm
by p-OS
Could be a Android Firewall issue / security Limitation. Or maybe the port is already used by some other service on the Android device
Re: Network Timeout When Connecting To An Android Server
Posted: Sun Mar 29, 2020 1:29 am
by PEB
I suppose it could be an Android Firewall issue. And if that's the case, I'm not sure how/if I can work around it.
Has anyone tried the code at the top of this thread on an Android device? Anyone had success?
Re: Network Timeout When Connecting To An Android Server
Posted: Sun Mar 29, 2020 11:23 am
by plouf
hi i modify just to check
i get protocol = 1 (ak ipv4) and i receive "we have connection"
tested hollywood with player 8.0, AndroidOne 9 OS, the port opened was 45291
CreateServer(1)
SystemRequest("Server", "This is the port: "..GetLocalPort(1, #NETWORKSERVER)
..Chr(10).."IP "..GetLocalIP(1,#NETWORKSERVER)
..Chr(10).."Protocol "..GetLocalProtocol(1,#NETWORKSERVER)
, "OK")
Function p_ClientConnect()
SystemRequest("Connection Established", "We have connection!", "OK")
EndFunction
InstallEventHandler({OnConnect=p_ClientConnect})
Repeat
WaitEvent
Forever
Re: Network Timeout When Connecting To An Android Server
Posted: Sun Mar 29, 2020 6:15 pm
by PEB
That's great! (Thanks for testing.)
So I guess that means it's a firewall issue on my Android device? Any ideas how to change that (assuming that's the problem)?
Re: Network Timeout When Connecting To An Android Server
Posted: Sun Mar 29, 2020 8:22 pm
by plouf
i am not aware of firewall in adroid... have you run my test? it is in protocol 1 ?
how certain you are for android IP and the fact that it is connected in local wifi ONLY (4g data are disabled ?)
Re: Network Timeout When Connecting To An Android Server
Posted: Sun Mar 29, 2020 11:22 pm
by PEB
I tested it on my wife's Samsung, and it worked immediately. (That was exciting.)
On my Android tablet (where the test failed consistently before), running LineageOS 15.1, I played around with the security settings (not sure exactly what I was doing), and now the test also works on that tablet!
So I'm really not sure why, but now it seems to be working.
Thanks everyone for your feedback and suggestions!