Quantcast
Channel: Appcelerator Developer Center Q&A Tag Feed (android)
Viewing all articles
Browse latest Browse all 7655

Titanium SDK 3.2 Android HttpClient socket timeout connection

$
0
0

Hello Community,

Thanks for giving lot of solution in sdk 3.2.i really appreciate that we have covered lot of things in 3.2 sdk. I am facing one major issue and i can't publish my android app due to this issue.

please review below thing which i am doing at my end.

Titanium SDK 3.2.1

Android Devices Samsung Galaxy S3, Micromax canvas, Samsung Fame, Sony Xperia, LG-Optimus.

Android 4.3, Android 4.4.2

my problem is very critical and i know community will provide me a solution for it.

1.i am making an HttpClient request to a server.

2.every thing works fine.

3.i am getting socket connection timeout error in android device and be very honest out of 10 time, 4 time i get this error.

  1. i changed my server url to other server url but problem still exist.

  2. i tested application in many android devices but same problem.

  3. i used timeout but it does not affect the response and i can't believe it works in IOS but not in android.

i used setTimeout and timeout but nothing works and response comes delay.

7.I discussed and reviewed my code and everything is correct but i also need experts suggestion what i have to do in case of android.

8.Titanium really stuck on android OS and there is no consistency in response.

Please review below code and tell me what is wrong at my end.

9.everything works fine but not every time while on server a simple name print statement we used for finding the issue.

10.before making request to server i am checking the network connection and also making a log of request and believe me some time HttpClient is taking 6-10 second at requesting.

var xhr = Titanium.Network.createHTTPClient();

xhr.timeout =20000;

var notify_url = "http://server.secugo.com/secugo/index.php/timed";
xhr.open("POST", notify_url);
//ADD your URL

var param = {
    "userID" : userID,
    "currentLat" : currentLat,
    "currentLng" : currentLng,
    "alertType" : 1,
    "notifyStatus" :2,
    "apiKey"  : apiKey,
    "reqTime" : reqTime 
};

Ti.API.info('Params' + JSON.stringify(param));
xhr.send(param);
xhr.onload = function() {
    alert("sent");// it comes but not every time

};
xhr.onerror = function(e) {
    alert(JSON.stringify(e));//it gives code -1 and comes 4 time out of 10 time

    Ti.API.error('Bad Sever =>' + e.error);
};

I know i will get a solution from community.

Thanks a ton in advance.


Viewing all articles
Browse latest Browse all 7655

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>