Bad internet connection verification test

Hi. :slight_smile:

My issue is the following: I use the following code to verify the connection with the internet whether to show or not the ads, but dependind on the speed of connection of the users, it yields to a weird delay while verifying and it seems the app is broken, so it comes back again and the app works fine.

Is there a more effective way and less slow to verify internet connection than this one?

Thanks. :) 

module(..., package.seeall) local socket = require("socket"); function test() local connection = socket.tcp(); connection:settimeout(1); local result = connection:connect("www.google.com", 80); connection:close(); if(result)then return true; end return false; end

Do you really need to do this?

If no network connection is available, trying to display ads will just silently (and gracefully) not show them without affecting game-play.

I’ll try it. Thanks. :slight_smile:

Do you really need to do this?

If no network connection is available, trying to display ads will just silently (and gracefully) not show them without affecting game-play.

Hi

I found sometimes the app will hang and cannot do anything until the result of connection:connect was confirmed.

This HANG problem is much more obviously while the 3G signal is very weak.

If there is no 3G signal or no wifi, the failed result of connection:connect can be returned very quickly, but if the 3G signal is very weak, mobile phone has “3G” indicator appeared but network status actually is bad, using connection:connect will hang whole the system.

This status is tested in HTC Desire V. I have no idea how to improve it.

I’ll try it. Thanks. :slight_smile:

Hi

I found sometimes the app will hang and cannot do anything until the result of connection:connect was confirmed.

This HANG problem is much more obviously while the 3G signal is very weak.

If there is no 3G signal or no wifi, the failed result of connection:connect can be returned very quickly, but if the 3G signal is very weak, mobile phone has “3G” indicator appeared but network status actually is bad, using connection:connect will hang whole the system.

This status is tested in HTC Desire V. I have no idea how to improve it.

Hi,

I am using the following code to test the internet connection.

module(…, package.seeall)
local socket = require(“socket”);

function test()
    local connection = socket.tcp();
    connection:settimeout(1);
    local result = connection:connect(“www.google.com”, 80);
    connection:close();
    if(result)then
        return true;
    end
    return false;
end

but my app is hanged and cannot do anything until the result of connection:connect was confirmed.

how to test internet connection so that app will not hang?

corona sdk: 2014.2511

please help me out in this issue.

That shouldn’t last any longer than 1 second since you’ve set the time out to be 1 second.

Rob

I confirm binitCamp issue. On bad or non internet connections

 connection:connect() last more than the speciified timeout.

Hi,

I am using the following code to test the internet connection.

module(…, package.seeall)
local socket = require(“socket”);

function test()
    local connection = socket.tcp();
    connection:settimeout(1);
    local result = connection:connect(“www.google.com”, 80);
    connection:close();
    if(result)then
        return true;
    end
    return false;
end

but my app is hanged and cannot do anything until the result of connection:connect was confirmed.

how to test internet connection so that app will not hang?

corona sdk: 2014.2511

please help me out in this issue.

That shouldn’t last any longer than 1 second since you’ve set the time out to be 1 second.

Rob

I too ran into this - and its been bugging me.

It appears that connection:settimeout(1) was for the old lua socket 

It seems to need the following (it worked for me):

connection:settimeout(1,send)

connection:settimeout(1,receive)

connection:settimeout(1,accept)

Found it here:  http://w3.impa.br/~diego/software/luasocket/tcp.html#settimeout

PS: Wrong login - should have been posted with my brindleware user…  :-)

@brindleware

:huh: Sorry, I don’t get it.

send, receive and accept are methods on the connection object, not modes.

The modes to settimeout are still ‘b’ and ‘t’ and nil (where ‘b’ is the default).

Ahhh yep - I was a tad over zealous in my post. Thanks for pointing it out  

Strange I got no warnings of the methods, not modes from corona/lua - and it did appear top be better when I ran it.

Changed it to:

connection:settimeout(1,b)

connection:settimeout(1,t)

And I can most assuredly report - that my hang problems are now gone.

Good to hear that you’ve solved the issue!

(I assume that your example above has a typo as “b” and “t” have no quotes, otherwise they would translate to nil which would make the timeout block indefinitely)

correct no quotes

with the added bonus of the form software turning it into a smiley

I confirm binitCamp issue. On bad or non internet connections

 connection:connect() last more than the speciified timeout.

I too ran into this - and its been bugging me.

It appears that connection:settimeout(1) was for the old lua socket 

It seems to need the following (it worked for me):

connection:settimeout(1,send)

connection:settimeout(1,receive)

connection:settimeout(1,accept)

Found it here:  http://w3.impa.br/~diego/software/luasocket/tcp.html#settimeout

PS: Wrong login - should have been posted with my brindleware user…  :-)

@brindleware

:huh: Sorry, I don’t get it.

send, receive and accept are methods on the connection object, not modes.

The modes to settimeout are still ‘b’ and ‘t’ and nil (where ‘b’ is the default).