RABBITMQ CLIENT 4.0.1 AutomaticRecovery FAILS WHEN USING DOMAIN NAME

403 views
Skip to first unread message

giu...@gmail.com

unread,
Jan 17, 2017, 10:14:35 AM1/17/17
to rabbitmq-users
Hi All,
I'm testing the AutomaticRecovery  feature unplugging and plugging my pc network cable.
After plugging again the cable my api client  fails firing this exception:

15:53:53.221 [AMQP Connection 185.107.196.53:5672] ERROR com.rabbitmq.client.impl.ForgivingExceptionHandler - Caught an exception during connection recovery!
java.net.UnknownHostException: feedcentremq.uat.betgenius.com: Nome o servizio sconosciuto
    at java.net.Inet6AddressImpl.lookupAllHostAddr(Native Method)
    at java.net.InetAddress$1.lookupAllHostAddr(InetAddress.java:901)
    at java.net.InetAddress.getAddressesFromNameService(InetAddress.java:1293)
    at java.net.InetAddress.getAllByName0(InetAddress.java:1246)
    at java.net.InetAddress.getAllByName(InetAddress.java:1162)
    at java.net.InetAddress.getAllByName(InetAddress.java:1098)
    at com.rabbitmq.client.DnsRecordIpAddressResolver.resolveIpAddresses(DnsRecordIpAddressResolver.java:83)
    at com.rabbitmq.client.DnsRecordIpAddressResolver.getAddresses(DnsRecordIpAddressResolver.java:73)
    at com.rabbitmq.client.impl.recovery.RecoveryAwareAMQConnectionFactory.newConnection(RecoveryAwareAMQConnectionFactory.java:56)
    at com.rabbitmq.client.impl.recovery.AutorecoveringConnection.recoverConnection(AutorecoveringConnection.java:531)
    at com.rabbitmq.client.impl.recovery.AutorecoveringConnection.beginAutomaticRecovery(AutorecoveringConnection.java:494)
    at com.rabbitmq.client.impl.recovery.AutorecoveringConnection.access$000(AutorecoveringConnection.java:53)
    at com.rabbitmq.client.impl.recovery.AutorecoveringConnection$1.recoveryCanBegin(AutorecoveringConnection.java:435)
    at com.rabbitmq.client.impl.AMQConnection.notifyRecoveryCanBeginListeners(AMQConnection.java:693)
    at com.rabbitmq.client.impl.AMQConnection.doFinalShutdown(AMQConnection.java:687)
    at com.rabbitmq.client.impl.AMQConnection$MainLoop.run(AMQConnection.java:577)
    at java.lang.Thread.run(Thread.java:745)

Strangely this happens only when in factory.setHost I use a domain name.
Using direct ip, api reconnects without  exceptions.
Unfortunately the mq server uses an ip pool so I need to set in my client a dns address.
Can someone help me out?

Regards,
Giuseppe.

 

Michael Klishin

unread,
Jan 17, 2017, 10:27:50 AM1/17/17
to rabbitm...@googlegroups.com
Take a look at what the exception says: the hostname fails to resolve.
--
You received this message because you are subscribed to the Google Groups "rabbitmq-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rabbitmq-user...@googlegroups.com.
To post to this group, send email to rabbitm...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

giu...@gmail.com

unread,
Jan 17, 2017, 10:55:40 AM1/17/17
to rabbitmq-users
Hi,
it not seems a os (Linux Fedora 22 distro)  related issue.
if I lookup the domain name when api fires exception,
the lookup works out.

Regards,
Giuseppe.

Michael Klishin

unread,
Jan 17, 2017, 11:02:44 AM1/17/17
to rabbitm...@googlegroups.com
`java.net.UnknownHostException` is unambiguous and RabbitMQ client library does not
control hostname resolution.

To unsubscribe from this group and stop receiving emails from it, send an email to rabbitmq-users+unsubscribe@googlegroups.com.
To post to this group, send email to rabbitmq-users@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
MK

Staff Software Engineer, Pivotal/RabbitMQ

giu...@gmail.com

unread,
Jan 17, 2017, 11:11:16 AM1/17/17
to rabbitmq-users
Hi,
could be something related to java cache?
I tried to set -Dsun.net.inetaddr.ttl=0  but didn't work out

Regards,
Giuseppe.

Arnaud Cogoluègnes

unread,
Jan 17, 2017, 11:24:56 AM1/17/17
to rabbitm...@googlegroups.com
You can provide your own AddressResolver implementation (default is DnsRecordIpAddressResolver in 4.0) and add some logging to see what going on during (re)connection.

To unsubscribe from this group and stop receiving emails from it, send an email to rabbitmq-users+unsubscribe@googlegroups.com.
To post to this group, send email to rabbitmq-users@googlegroups.com.

giu...@gmail.com

unread,
Jan 18, 2017, 2:50:13 AM1/18/17
to rabbitmq-users
Hi Arnaud,
I don't use custom AddressResolver,
this is my log:


Connection 185.107.196.53:5672] ERROR com.rabbitmq.client.impl.ForgivingExceptionHandler - Caught an exception during connection recovery!
java.net.UnknownHostException: feedcentremq.uat.betgenius.com
    at java.net.Inet4AddressImpl.lookupAllHostAddr(Native Method)

    at java.net.InetAddress$1.lookupAllHostAddr(InetAddress.java:901)
    at java.net.InetAddress.getAddressesFromNameService(InetAddress.java:1293)
    at java.net.InetAddress.getAllByName0(InetAddress.java:1246)
    at java.net.InetAddress.getAllByName(InetAddress.java:1162)
    at java.net.InetAddress.getAllByName(InetAddress.java:1098)
    at com.rabbitmq.client.DnsRecordIpAddressResolver.resolveIpAddresses(DnsRecordIpAddressResolver.java:83)
    at com.rabbitmq.client.DnsRecordIpAddressResolver.getAddresses(DnsRecordIpAddressResolver.java:73)

DnsRecordIpAddressResolver.resolveIpAddresses seems to call  underlying java net api and it fires exception.
But trying at the same time:

[peppe@localhost ~]$ telnet feedcentremq.uat.betgenius.com 5672
Trying 185.107.196.53...
Connected to feedcentremq.uat.betgenius.com.
Escape character is '^]'.

Connection is established.
Problem seems confined in  java environment.Currently I not able to figure out if inside raqbbitmq api or outside.

Regards,
Giuseppe.

Arnaud Cogoluègnes

unread,
Jan 18, 2017, 3:47:27 AM1/18/17
to rabbitm...@googlegroups.com
I was suggesting to use your own AddressResolver, e.g. to add logging. The default AddressResolver tries to resolve the hostname itself. You can try a simpler AddressResolver that doesn't do any resolution:

Connection connection = connectionFactory.newConnection(
  new ListAddressResolver(Arrays.asList(new Address("feedcentremq.uat.betgenius.com", 5672)))
);

The resolution will take place elsewhere anyway (when the socket is created), but it's worth trying.

You can also try to isolate the problem, with a simple loop that does the InetAddress.getAllByName(hostName), unplug the cable, and see what happens. Then we'll know if it's related to the RabbitMQ Java client or to the Java environment.

To unsubscribe from this group and stop receiving emails from it, send an email to rabbitmq-users+unsubscribe@googlegroups.com.
To post to this group, send email to rabbitmq-users@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages