{"id":290,"date":"2012-09-18T10:46:00","date_gmt":"2012-09-18T14:46:00","guid":{"rendered":"http:\/\/blog.domb.net\/?p=290"},"modified":"2012-09-18T15:09:21","modified_gmt":"2012-09-18T19:09:21","slug":"rabbitmq-ipv6-dns-names","status":"publish","type":"post","link":"https:\/\/blog.domb.net\/?p=290","title":{"rendered":"RabbitMQ ipv6 DNS names Solved"},"content":{"rendered":"<p>Last week I was building up a RabbitMQ cluster with shovel from New York to Los Angeles. As we use a dual stack environment ipv4\/v6, I expected that RabbitMQ would resolve the ipv6 address\u00a0 first as normal Linux systems do. So I begun to do my tests and realized, that it didn&#8217;t.<\/p>\n<p>My publisher\u00a0 (see code below) sends messages to the following host: &#8220;<em><strong>&#8216;rabbitmq0.domb.net<\/strong><\/em>&#8216;&#8221;<\/p>\n<p>[cc lang=&#8221;python&#8221;]<br \/>\nfrom amqplib import client_0_8 as amqp<br \/>\nimport sys<\/p>\n<p>conn = amqp.Connection(&#8216;rabbitmq0.domb.net&#8217;, userid=&#8221;logger&#8221;, password=&#8221;test&#8221;, virtual_host=&#8221;\/&#8221;, insist=False)<br \/>\nchan = conn.channel()<\/p>\n<p>for i in range(1000):<br \/>\n#msg = amqp.Message(sys.argv[1])<br \/>\nsendmsg = &#8220;paket ny:&#8221; + str(i)<br \/>\nmsg = amqp.Message(sendmsg)<br \/>\nmsg.properties[&#8220;delivery_mode&#8221;] = 2<br \/>\nchan.basic_publish(msg,exchange=&#8221;incoming_orders&#8221;,routing_key=&#8221;warehouse&#8221;)<br \/>\nchan.close()<br \/>\nconn.close()<\/p>\n<p>[\/cc]<\/p>\n<p>Executing that code I got the following error:<\/p>\n<div>&#8220;<em><strong>{{badmatch,{error,econnrefused}}<\/strong><\/em>,<\/div>\n<div>[{rabbit_shovel_worker,make_conn_and_chan,1},<br \/>\n{rabbit_shovel_worker,handle_cast,2},<br \/>\n{gen_server2,handle_msg,2},<br \/>\n{proc_lib,init_p_do_apply,3}]}<\/p>\n<div>&#8220;<\/div>\n<div>It looked like rabbit does not get the ipv6 address back. To be sure I looked at the DNS logs and traced the request with tcpdump and got the confirmation that it resolve ipv4 addresses first. So I was wondering what if I add an ipv6 address does it work?<\/div>\n<\/div>\n<p>Here an example with a ipv6 address:<\/p>\n<p>[cc lang=&#8221;python&#8221;]<br \/>\nfrom amqplib import client_0_8 as amqp<br \/>\nimport sys<\/p>\n<p>conn = amqp.Connection(&#8216;[2625:103:2012::205a]:5672&#8217;, userid=&#8221;logger&#8221;, password=&#8221;test&#8221;, virtual_host=&#8221;\/&#8221;, insist=False)<br \/>\nchan = conn.channel()<\/p>\n<p>for i in range(1000):<br \/>\n#msg = amqp.Message(sys.argv[1])<br \/>\nsendmsg = &#8220;paket ny:&#8221; + str(i)<br \/>\nmsg = amqp.Message(sendmsg)<br \/>\nmsg.properties[&#8220;delivery_mode&#8221;] = 2<br \/>\nchan.basic_publish(msg,exchange=&#8221;incoming_orders&#8221;,routing_key=&#8221;warehouse&#8221;)<br \/>\nchan.close()<br \/>\nconn.close()<\/p>\n<p>[\/cc]<\/p>\n<p>Yes it does.<\/p>\n<p>As I need ipv6 and couldn&#8217;t find the code where the erlang parameter gets passed I wrote to the RabbitMQ mailing list.<\/p>\n<p>http:\/\/comments.gmane.org\/gmane.comp.networking.rabbitmq.general\/18437<\/p>\n<p>And got a fast response and a fix from Emile Joubert from rabbitmq 4 days later. Thank you very much!!!\u00a0 Will test the patch this week.<\/p>\n<p>Here is the patch<\/p>\n<p>http:\/\/hg.rabbitmq.com\/rabbitmq-erlang-client\/rev\/7f53561c0c11<\/p>\n<p>If you don&#8217;t know howto rebuild the rpm you can have mine until the official comes out. Use it at your own risk!<\/p>\n<p><a href=\"http:\/\/blog.domb.net\/downloads\/rabbitmq-server-2.8.6-1fixipv6.el6.noarch.rpm\">rabbitmq-server-2.8.6-1fixipv6.el6.noarch.rpm<\/a> <\/p>\n","protected":false},"excerpt":{"rendered":"<p>Last week I was building up a RabbitMQ cluster with shovel from New York to Los Angeles. As we use a dual stack environment ipv4\/v6, I expected that RabbitMQ would resolve the ipv6 address\u00a0 first as normal Linux systems do. So I begun to do my tests and realized, that it didn&#8217;t. My publisher\u00a0 (see&#8230;<\/p>\n","protected":false},"author":2,"featured_media":308,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_themeisle_gutenberg_block_has_review":false,"footnotes":""},"categories":[3],"tags":[7],"class_list":["post-290","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-linux","tag-rabbitmq"],"_links":{"self":[{"href":"https:\/\/blog.domb.net\/index.php?rest_route=\/wp\/v2\/posts\/290","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.domb.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.domb.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.domb.net\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.domb.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=290"}],"version-history":[{"count":22,"href":"https:\/\/blog.domb.net\/index.php?rest_route=\/wp\/v2\/posts\/290\/revisions"}],"predecessor-version":[{"id":311,"href":"https:\/\/blog.domb.net\/index.php?rest_route=\/wp\/v2\/posts\/290\/revisions\/311"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.domb.net\/index.php?rest_route=\/wp\/v2\/media\/308"}],"wp:attachment":[{"href":"https:\/\/blog.domb.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=290"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.domb.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=290"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.domb.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=290"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}