I am trying to get SRV records from a DNS server using JNDI.
Hashtable<String, String> env = new Hashtable<String, String>();
env.put("java.naming.factory.initial", "com.sun.jndi.dns.DnsContextFactory");
env.put("java.naming.provider.url", "dns://dns.server.com");
DirContext ctx = new InitialDirContext(env);
Attributes attributes = ctx.getAttributes("_sip._udp", new String [] { "SRV" });
return attributes;
But when trying to get attributes I get the following exception
DNS error [Root exception is java.net.PortUnreachableException: ICMP Port Unreachable]; remaining name '_sip._udp'
I have verified host -t srv _sip._udp.server.com returns valid SRV record.
Any reason as why this might happen?