Nothing obvious stands out. What kind of crash are you getting? Run it under a debugger and see where it crashes?
-Alan On Mon, Nov 18, 2013 at 1:50 PM, Kiran Kumar <[email protected]>wrote: > I have a rabbitmq server running on my debian linux machine. I have a BGP > process running and it prepared a Route Message using google protocol > buffers. The protocol buffer returns a binary data buffer. > > Then I have below code to send this data to rabbitmq server. When I > execute this, the process crashes on amqp_basic_publish call. > > Any thoughts on this ? Am I missing some thing here ? > > > int bgp_mq_send(char const* rt_msg, int size) > { > static int init_done = 0; > int status; > amqp_socket_t *socket = NULL; > amqp_connection_state_t conn = NULL; > amqp_rpc_reply_t reply; > > if (init_done == 0) { > conn = amqp_new_connection(); > > socket = amqp_tcp_socket_new(conn); > if (!socket) { > printf("\n socket creation failed\n"); > return 1; > } > > status = amqp_socket_open(socket, "localhost", 5672); > if (status) { > printf("\n socket open failed\n"); > return 1; > } > > reply = amqp_login(conn, "/", 0, 131072, 0, AMQP_SASL_METHOD_PLAIN, > "guest", "guest"); > if (reply.reply_type) { > printf("\n Login is failed\n"); > } > > amqp_channel_open(conn, 1); > reply = amqp_get_rpc_reply(conn); > if (reply.reply_type) { > printf("\n get_reply failed\n"); > } > init_done = 1; > } > > > { > amqp_basic_properties_t props; > props._flags = AMQP_BASIC_CONTENT_TYPE_FLAG | > AMQP_BASIC_DELIVERY_MODE_FLAG; > props.content_type = amqp_cstring_bytes("gpb"); > props.content_encoding = amqp_cstring_bytes("binary"); > props.delivery_mode = 2; /* persistent delivery mode */ > > amqp_bytes_t str2; > str2.len = size; > str2.bytes = rt_msg; > > status = amqp_basic_publish(conn, 1, > amqp_cstring_bytes("amq.fanout"), > amqp_cstring_bytes("#"), 0, 0, > &props, str2); *<<<----------- It crashes right > here.* > > if (status < 0) { > printf("\n publish failed\n"); > } > printf("\n Publish success\n"); > } > reply = amqp_channel_close(conn, 1, AMQP_REPLY_SUCCESS); > if (reply.reply_type) { > printf("\n chan close failed\n"); > } > reply = amqp_connection_close(conn, AMQP_REPLY_SUCCESS); > if (reply.reply_type) { > printf("\n conn close failed\n"); > } > status = amqp_destroy_connection(conn); > if (status < 0) { > printf("\n Destroy failed\n"); > } > printf("\n All Done\n"); > return 0; > } > > any help in moving forward would be great. > > Thanks, > Kiran. > > _______________________________________________ > rabbitmq-discuss mailing list > [email protected] > https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss > > -- You received this message because you are subscribed to the Google Groups "rabbitmq-discuss" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/rabbitmq-discuss. For more options, visit https://groups.google.com/groups/opt_out.
