How to troubleshoot failure to open a socket - amqp / rabbitmq-c

3.3k Views Asked by At

I am trying to Hello World the rabbitmq-c implementation of AMQP.

I have a small script adopted from the example included with the rabbitmq-c source. Here's a snippet:

  socket = amqp_tcp_socket_new(conn);
  if (!socket) {
    die("creating TCP socket");
  }

  status = amqp_socket_open(socket, hostname, port);
  if (status) {
        die(amqp_error_string2(status));
  }
  printf ("Error opening socket: %s\n",strerror(errno));

If I run this on the same host as the rabbitmq server process (i.e., hostname is localhost), then the script connects and sends a message which is received by a listener. If I run this same program on a different box and supply the hostname of the box running Rabbit, then it dies when it tries to open the socket with a -9, which is just "a socket error occurred". "errno" is just the EINPROGRESS which is expected when I try to open a non-blocking socket. (It's the same error I see as when the program succeeds).

On failure, nothing shows up in the rabbitmq server log.

While I'd love it if someone could tell me specifically what's going wrong here, I'm really in need of a fishing pole. I have no idea how to get the information I need from the system here, not even really where to begin. I've never really done unix I/O before. Could anyone make some suggestions about debugging next steps?

1

There are 1 best solutions below

3
On

i can't really offer any direct advice on what to look for next... but from your description, it sounds like the machine that is hosting rabbitmq is not allowing the proper TCP/IP ports for communication.

i ran in to this when i installed RabbitMQ on RedHat Linux, a few months ago. I had to configure various security settings in the firewall and in the selinux security setup to allow the proper ports