Android 4.0.3 3g connection JSON problem

You must Login before you can answer or comment on any questions.

Hi,

do you know why my application works fine on android 2.3.5 using mobile connection vhen getting data from server in JSON format. Now when my phone get version 4.0.3 (ICS) OS my application can't work if not on WiFI ... mobile netvork (3g .. or similar) fails parse JSON.

Work fine on WiFi .. not works on mobile connection.

I get "The connection was refused by the host" ERROR.

My srver is on static IP not on register domain.

Nice day, Matej

— asked 11 months ago by Matej Zimic
5 Comments
  • can you post some code

    — commented 11 months ago by Arian Caraballo

  • I'm using a basic xhr.onload function I found in kitchensink. Nothing special.

    The point is that I'we done the app 6 months ago when there was no android 4.0.3 version. The app work perfect on iOS (iPhone, iPad) and Android less or equal than 2.3.5. On 3.0 I didn't try. When 2 months ago came android version 4.0.3 the app works only on WiFi on this version.

    I could put some code, but first I hawe to edit it, that it would be readable. Try to do that soon.

    — commented 11 months ago by Matej Zimic

  • Here is the code in app.js file:

    Titanium.App.Properties.setString("naslov_serverja","http://97.144.33.66:8899/");   
    
    var buttonLogin = Ti.UI.createButton({
        id:'button_header_footer',
        title:'Login',
        right:5
    });
    
    mainViewHeader.add(buttonLogin);
    
    var loginReq = Titanium.Network.createHTTPClient();
    
    loginReq.onload = function()
    {
        var json = JSON.parse(this.responseText);
        var data = json.data;
        var st_el = json.length;
    
        if( data == 2 ){
            alert("Username or Password not valid");
        }
        else if( data == 1 ){
            alert("You do not heave access to the plants");
        }
        else        
        {
            username.blur();
            password.blur();
    
            var loged_in_Window = Ti.UI.createWindow({
                url:'logedin.js',
                backgroundColor:'#CCC',
                navBarHidden:true,
                jsonPodatki:this.responseText
    
            });
        loged_in_Window.open();
        }
     working_v_app.hide();
    };
    
    buttonLogin.addEventListener('touchstart',function(e)
    {
        if (username.value != '' && password.value != '')
        {
            loginReq.open("POST",Titanium.App.Properties.getString("naslov_serverja")+"Elek/login.php");
                var params = {
                funkcija: 'login',
                username: username.value,
                password: Titanium.Utils.md5HexDigest(password.value)
            };
            loginReq.send(params);
        }
        else
        {
            alert("Username or Password is not valid");
        }
    });
    

    — commented 11 months ago by Matej Zimic

  • Show 2 more comments

1 Answer

Hi, I had similar problems with my app. Simple app with DefaultHttpClient connection to a server at port 8081. Works fine over WiFi on 2.2.1, 3.5, 4.0.3 and 4.0.4m but when using 3G network only works on 2.2.1, 3.5. For 4.0.3 and 4.0.4 I get >>connection refused by the host<<. I solved the problem with deleting ip address of Proxy server in my APN settings for mobile network and 4.0.4 started to receive data. (I am using Si.mobil network). By the way: If I used port 8080 for server it worked fine on all platforms on 3G or WiFI.

Your Answer

Think you can help? Login to answer this question!