Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hang on network failure #847

Open
AdrienSchwartzentruber opened this issue Nov 12, 2024 · 0 comments
Open

Hang on network failure #847

AdrienSchwartzentruber opened this issue Nov 12, 2024 · 0 comments

Comments

@AdrienSchwartzentruber
Copy link

Hi,

First of all, thank for your work. We use rabbitmq-c for the last few month and, its works like a charm :)

We just have one issue, in your applicaion we have a AMQP connection, and every 10 seconds we use it to send messages (without reopening the connection). Everyting works fine with this, but when we have a network failure (ie the connection to the remote service failed ex: network cable unlink), the connection is close but it hang with this call stack :

#1 0x0000007f997bc708 in recv_with_timeout () from /usr/lib/librabbitmq.so.4
#2 0x0000007f997bd16c in wait_frame_inner () from /usr/lib/librabbitmq.so.4
#3 0x0000007f997bd8cc in simple_rpc_inner () from /usr/lib/librabbitmq.so.4
#4 0x0000007f997bdbbc in amqp_simple_rpc () from /usr/lib/librabbitmq.so.4
#5 0x0000007f997b51b4 in amqp_channel_close () from /usr/lib/librabbitmq.so.4
#6 0x0000007f99db99a0 in ace_amqp_client_close_connection () from /tmp/run_service/build/ace_common/libace_common.so

Ths code that we use :

void
ace_amqp_client_close_connection(AceAMQPClient* self){
g_rec_mutex_lock(&self->mConn);
if(self->conn){
amqp_channel_close(self->conn, 1, AMQP_REPLY_SUCCESS);
amqp_connection_close(self->conn, AMQP_REPLY_SUCCESS);
amqp_destroy_connection(self->conn);
self->conn = NULL;
}
g_rec_mutex_unlock(&self->mConn);
}

Opening of the connection :

gboolean
ace_amqp_client_open_connection(AceAMQPClient* self){
gboolean result = FALSE;
ace_amqp_client_close_connection(self);

g_rec_mutex_lock(&self->mConn);
if(self->conn == NULL){
amqp_socket_t *socket = NULL;
self->conn = amqp_new_connection();
if (self->ssl) {
socket = amqp_ssl_socket_new(self->conn);
amqp_ssl_socket_set_verify_peer(socket, 0);
amqp_ssl_socket_set_verify_hostname(socket, 0);

} else {
  socket = amqp_tcp_socket_new(self->conn);  
}

if (!socket) {
  g_warning("AceAMQPClient create_connection:: Failed to create socket");
  g_rec_mutex_unlock(&self->mConn);
  return FALSE;
}
gint status = amqp_socket_open(socket, self->host, self->port);
if (status) {
  g_warning("AceAMQPClient create_connection :: Failed to open socket");
  g_rec_mutex_unlock(&self->mConn);
  return FALSE;
}
amqp_login(self->conn, "/", 0, 131072, 0, AMQP_SASL_METHOD_PLAIN, self->user, self->pass); //,                  "Logging in");
amqp_channel_open(self->conn, 1);
amqp_get_rpc_reply(self->conn); //, "Opening channel");
result = TRUE;

}
g_rec_mutex_unlock(&self->mConn);
return result;
}

Do you have any feedback on this issue ?

Regards,
Adrien

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant