我使用..\rabbitmq-c\examples
的示例代码来创建到http://localhost:15672
的连接。从下面的代码块中,我得到:Logging in: socket is closed
输出
amqp_socket_t *socket = NULL;
amqp_connection_state_t conn;
hostname = "localhost";
port = 131072; // 15672 // 131072
username = "guest";
password = "guest";
exchange = "testExchange";
bindingKey = "testMessage";
queueName = "testQueue";
routingKey = "testMessage";
messageBody = "testMessageBody";
conn = amqp_new_connection();
socket = amqp_tcp_socket_new(conn);
if (!socket)
{
die("Creating TCP socket ERROR");
}
status = amqp_socket_open(socket, hostname, port);
if (!status)
{
die("Opening TCP socket ERROR");
}
die_on_amqp_error(amqp_login(conn, "/", 0, 131072, 0, AMQP_SASL_METHOD_PLAIN,
"guest", "guest"),
"Logging in");
amqp_channel_open(conn, 1);
die_on_amqp_error(amqp_get_rpc_reply(conn), "Opening channel");
rabbitmq-c
是用VS2015编译的,我有rabbitmq-server 3.7.6
,它已经在运行了。
1条答案
按热度按时间ubbxdtey1#
RabbitMQ在
5672
端口上运行,您正在尝试连接到131072
端口。考虑到TCP允许的最大端口是65535
,这是不可能的。将您的代码更改为使用
5672
。