RabbitMQ CreateConneciton issues - works in one app but not in another

Problem solved. It looks like it was something as simple as the Exception settings. For some reason the console app was set to not break on the connection exceptions and the WPF app was set to break. Everything now works.

Strange that the exceptions are being generated, especially about not resolving the server name or IP address but yet it still works.


It did because the exception setting, if you look into the RMQ .net client source code, at the beginning it will try to connect your ip address with IPv6 Protocol, if your are connecting an IPv4 address this step will fail and throw System.ArgumentException: No ip address could be resolved for 'your ip address', but the RMQ .net client will catch this exception and move forward to try connect your ip address with IPv4 Protocol.

 if (ShouldTryIPv6(endpoint))
        {
            try {
                m_socket = ConnectUsingIPv6(endpoint, socketFactory, connectionTimeout);
            } catch (ConnectFailureException)
            {
                m_socket = null;
            }
        }

        if (m_socket == null && endpoint.AddressFamily != AddressFamily.InterNetworkV6)
        {
            m_socket = ConnectUsingIPv4(endpoint, socketFactory, connectionTimeout);
        }

if yous set to break on the connection exceptions, your force the ArgumentException to throw.

  public virtual async Task ConnectAsync(string host, int port)
    {
        AssertSocket();
        var adds = await Dns.GetHostAddressesAsync(host).ConfigureAwait(false);
        var ep = TcpClientAdapterHelper.GetMatchingHost(adds, sock.AddressFamily);
        if (ep == default(IPAddress))
        {
            throw new ArgumentException("No ip address could be resolved for " + host);
        }

Tags:

C#

Wpf

Rabbitmq