App type: mobile Titanium SDK: 4.1.0 Platform & Version: iOS 8.1, Android 4.4.4 Device: Galaxy A3, Iphone 4s Host Operating System: OSX 10.10.3 Yosemite Appcelerator Studio build: 4.1.1.201507141126
First of all, thanks a lot for your time to provide support on this request.
Consider a simple app ( code posted bellow ) , which calls an also very simple "teste.php" server script every second and places the returned content at the center of the mobile screen.
The php server script is a one line code that echoes back the current server time - echo time() ; - . This script runs on a well known web hosting provider in my country.
This app works perfectly under 3G connections for several devices running it simultaneously. Tested with 5 devices..all went ok, never saw a problem!
The Apache server shows the log bellow for every successful script call: XXX.XXX.XXX.XX - - [27/Jul/2015:20:19:16 -0300] "GET /teste.php HTTP/1.1" 200 10 "-" "Appcelerator Titanium/4.1.0 (SM-A300M; Android API Level: 19; pt-BR;)"
Now, consider only two mobile devices with this same app under ANY public or private wifi network, connected to the internet.
The app on the first device starts ok...but immediately after I start the same app on the second device, the first one starts to receive timeouts with messages like the following one:
[ERROR] : TiHttpClient: (TiHttpClient-143) [4035,261341] HTTP Error (org.apache.http.conn.ConnectTimeoutException): Connect to /XX.XX.XX.XX:80 timed out
If I shutdown the app on the second device, I have to wait exactly 60 seconds, and then the app on the first device starts receiving again the correct information from the server.
Important to mention the fact that a call to the same php script from any PC browser on the same wifi network is always successful, and it has the same effect on the app, causing it to timeout.
In fact, if I call any script on the same server from any device on the same wifi network, I will cause the timeout on the app, and will have to wait for more 60 seconds for it to resume normal operation.
It looks like the titanium httpclient lib is weak ?!...or maybe there is a sort of standard firewall policy that causes the described behaviour.
Please, I need help, my major app is based on the same httpclient connectivity as described on this example, and it requires a scenario with several users sharing the same wifi hotspot.
thanks in advance.
APP CODE:
// TestHTTP var win = Ti.UI.createWindow({}); var timeserver = Ti.UI.createLabel({ textAlign: Ti.UI.TEXT_ALIGNMENT_CENTER }); win.add(timeserver); function testhttp(){ var website = "http://www.autorizei.com/teste.php"; var xhr=Titanium.Network.createHTTPClient(); xhr.timeout = 20000; xhr.open("GET", website); xhr.send(); xhr.onload = function(e){ timeserver.text = this.responseText ; xhr = null; setTimeout(function(){ testhttp(); }, 1000); }; xhr.onerror = function(e) { timeserver.text = e.error ; xhr = null; setTimeout(function(){ testhttp(); }, 1000); }; } win.open(); testhttp();