Skip to content

Use cloudflare DNS for session server IP lookup #1010

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

Closed
wants to merge 2 commits into from

Conversation

heisluft
Copy link
Contributor

This PR fixes an issue where the client would be kicked with the message: internal error during login. The server complains about not being able to reach the mojang session server, failing with a timeout exception. This is because netty's DefaultDnsServerAddressStreamProvider which uses Googles DNS servers (8.8.8.8 and 8.8.4.4) for IP lookup. This PR changes the DNS servers tou cloudflare's (1.1.1.1) thus resolving the issue.

This has been tested many times (it was frustrating to not be able to play on my server for 2 months now) and is proven to solve my issue (Thanks for your fast support on Discord, that really helped :D)

@CLAassistant
Copy link

CLAassistant commented Jan 28, 2019

CLA assistant check
All committers have signed the CLA.

@smartboyathome
Copy link
Contributor

Nice find, but is it possible to use the system's configured DNS server? I don't believe we should be ignoring what is configured in the system. Alternatively, if it's not possible to use the system's configured DNS, we should change these to be configurable rather than hardcoding defaults to a single provider that, for one reason or another, someone may object to.

@heisluft
Copy link
Contributor Author

heisluft commented Jan 28, 2019

Will address that as soon as i got time again (hopefully tomorrow). It seems like DefaultDnsServerAddressStreamProvider first tries to resolve the systems dns servers and uses google as fallback:
excerpt from DefaultDnsServerAddressStreamProvider:

 // Using jndi-dns to obtain the default name servers.
        //
        // See:
        // - http://docs.oracle.com/javase/8/docs/technotes/guides/jndi/jndi-dns.html
        // - http://mail.openjdk.java.net/pipermail/net-dev/2017-March/010695.html
        Hashtable<String, String> env = new Hashtable<String, String>();
        env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.dns.DnsContextFactory");
        env.put("java.naming.provider.url", "dns://");
        try {
            DirContext ctx = new InitialDirContext(env);
            String dnsUrls = (String) ctx.getEnvironment().get("java.naming.provider.url");
            // Only try if not empty as otherwise we will produce an exception
            if (dnsUrls != null && !dnsUrls.isEmpty()) {
                String[] servers = dnsUrls.split(" ");

But this raises the question why it wouldn't be able to resolve the session servers:
curling them gives me back correct results, so it can't be my DNS config (or something is REALLY broken on my end).

@mastercoms
Copy link
Member

These defaults do not respect your host's machines defaults.

The docs suggest otherwise.

Copy link
Member

@mastercoms mastercoms left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would recommend using a MultiDnsServerAddressStreamProvider collection of the following:

  1. SequentialDnsServerAddressStreamProvider initialized from glowstone.yml optional user overrides.
  2. UnixResolverDnsServerAddressStreamProvider to attempt to use the system DNS servers on Linux.
  3. SequentialDnsServerAddressStreamProvider of 1.1.1.1, 1.0.0.1, 8.8.8.8, 8.8.4.4.

@heisluft
Copy link
Contributor Author

Appearantly, I was able to reach the sessionserver both with using cloudflare and google dns servers... The error seems to be the java excerpt I posted above. I looked into the matter and there is literally no way of solving the issue on Window using pure Java. If we decide it to be worth the effort I could write a C lib and do some JNI magic... However I'm not familiar with Maven at all and don't know how I tell Maven to compile this mess.

@mastercoms
Copy link
Member

That can be done later, but for now, I think what I proposed above is fine.

@mastercoms
Copy link
Member

Superseded by d486808.

@mastercoms mastercoms closed this Mar 17, 2019
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

Successfully merging this pull request may close these issues.

4 participants