Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ice4j v2.0.0 hangs while checking AWS EC2 #141

Open
cmeng-git opened this issue Jun 21, 2018 · 8 comments
Open

Ice4j v2.0.0 hangs while checking AWS EC2 #141

cmeng-git opened this issue Jun 21, 2018 · 8 comments

Comments

@cmeng-git
Copy link

Trying to integrate using ice4j-2.0.0 release into aTalk with all the default settings, but facing problem with the following AwsCandidateHarvester#doTestEc2 in conn.getContent. The system just hangs in this execution without return. It seems that EC2_TEST_URL (http://169.254.169.254/latest/meta-data/) is not reachable.

    /**
     * Tries to connect to an Amazon EC2-specific URL in order to determine
     * whether we are running on EC2.
     *
     * @return <tt>true</tt> if the connection succeeded, <tt>false</tt>
     * otherwise.
     */
    private static boolean doTestEc2()
    {
        try
        {
            URLConnection conn = new URL(EC2_TEST_URL).openConnection();
            conn.setConnectTimeout(500); //don't hang for too long
            conn.getContent();

            return true;
        }
        catch(Exception exc)
        {
            //ah! I knew you weren't one of those ...
            return false;
        }
    }
@damencho
Copy link
Member

You can disable aws harvester using org.ice4j.ice.harvest.DISABLE_AWS_HARVESTER system property.

@cmeng-git
Copy link
Author

Yes, actually I already did that, and it works. But isn't that the system should not hangs even with the option disabled, at least it should auto exit on timeout?

@damencho
Copy link
Member

I havn't heard of such reports for jvb where this is not disabled. You can check the usage of ice4j there, I suppose it is in new thread or something.

@bgrozev
Copy link
Member

bgrozev commented Jun 22, 2018

Does it block for more than 500ms?

@cmeng-git
Copy link
Author

When the option is enabled, it does not return upon executed conn.getContent() or throw exception even after a long wait; although it seems to have set a 500mS timeout on connection.
By the way it aTalk is an android application. No sure if it makes a different when running on other OS.
I did a ping on Ubuntu to 169.254.169.254, look like the address is not reachable.

@bgrozev bgrozev reopened this Jun 23, 2018
@bgrozev
Copy link
Member

bgrozev commented Jun 23, 2018

Thanks for reporting. By design it should timeout after 500ms.

@ibauersachs
Copy link
Member

Try to set conn.setReadTimeout as well, or use the system properties for debugging:

System.setProperty("sun.net.client.defaultConnectTimeout", "500");
System.setProperty("sun.net.client.defaultReadTimeout", "500");

But note that the API states that non-standard implementations might ignore the timeouts.

@cmeng-git
Copy link
Author

The above two timer settings do not work for android aTalk. It seems that it requires java 1.8 and is not available in android OS.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants