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

Hot wo specify a custom DNS Resolver #859

Closed
carter-ya opened this issue Feb 19, 2019 · 5 comments · Fixed by #906
Closed

Hot wo specify a custom DNS Resolver #859

carter-ya opened this issue Feb 19, 2019 · 5 comments · Fixed by #906

Comments

@carter-ya
Copy link

Describe what you would like to know or do
I want to specify a custome DNS resolver, like apache http client

/**
 * Users may implement this interface to override the normal DNS lookup offered
 * by the OS.
 *
 * @since 4.2
 */
public interface DnsResolver {

    /**
     * Returns the IP address for the specified host name, or null if the given
     * host is not recognized or the associated IP address cannot be used to
     * build an InetAddress instance.
     *
     * @see InetAddress
     *
     * @param host
     *            The host name to be resolved by this resolver.
     * @return The IP address associated to the given host name, or null if the
     *         host name is not known by the implementation class.
     */
    InetAddress[] resolve(String host) throws UnknownHostException;

}

@marci4
Copy link
Collaborator

marci4 commented Feb 20, 2019

Hello @liukefeng2008,

could you please describe your usecase and what you are trying to achieve?

Best regards,
Marcel

@carter-ya
Copy link
Author

carter-ya commented Feb 21, 2019

Hello, I want to access some websocket resources, eg: (wss://api.fcoin.com/v2/ws).
In some countries,The default dns parsing behavior will resolve the wrong ip address, So I want to specify a custom dns resolver.

  1. how-to-configure-hostname-resolution-to-use-a-custom-dns-server-in-java
  2. how-to-override-dns-in-http-connections-in-java

I want to use the second way, but this library(Java-WebSocket) does not support this method. Is it possible to add a custom dns resolver?

@marci4
Copy link
Collaborator

marci4 commented Feb 21, 2019

Hello @liukefeng2008

Thank you for a feedback.
Do I understand you correctly, you just need an API to set a InetAddress instead of an URL?

Best regards,
Marcel

@carter-ya
Copy link
Author

carter-ya commented Feb 24, 2019

I can't set the IP directly. Because the server only respond by the host.
If url wss://api.fcoin.com/v2/ws, it's work for me.
If url wss://x.x.x.x/v2/ws, it's not work.

@marci4 look forward to your reply

@marci4
Copy link
Collaborator

marci4 commented Jun 12, 2019

I am not really sure if there are reallife usecases for this.

If someone has the time, feel free to implement a solution and we discuss it on the PR.

Best regards,
Marcel

@marci4 marci4 added this to the Release 1.4.1 milestone Jun 14, 2019
marci4 added a commit that referenced this issue Jun 23, 2019
Implemented a custom DNS resolver, see #859
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants