Sending App ID for rabbit mq connection from C#.

608 views
Skip to first unread message

Prajwal Amatya

unread,
Oct 2, 2018, 1:36:22 PM10/2/18
to rabbitmq-users
Hi,
Is there a method, or properties which can be used to send appID while connecting to the rabbitmq server ?
We need to send application Id at each request, so that application id can be verified from the backend of the system in each request.
Any help will be greatly appreciated.

--
Best Regards
Prajwal

Luke Bakken

unread,
Oct 2, 2018, 2:33:12 PM10/2/18
to rabbitmq-users
Hi Prajwal -

I recommend making "appID" part of the message body, or part of a custom header for the message.

Thanks,
Luke

Michael Klishin

unread,
Oct 2, 2018, 4:18:42 PM10/2/18
to rabbitm...@googlegroups.com
There's an "application ID" message property, too. It's a short string (up to 255 bytes).

--
You received this message because you are subscribed to the Google Groups "rabbitmq-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rabbitmq-user...@googlegroups.com.
To post to this group, send email to rabbitm...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--
MK

Staff Software Engineer, Pivotal/RabbitMQ

Prajwal Amatya

unread,
Oct 2, 2018, 5:10:55 PM10/2/18
to rabbitmq-users
Thank you Luke and Micheal, for a quick response.
I was able to send appID as following:

 IBasicProperties basicProperties =  channel.CreateBasicProperties();
                        basicProperties.AppId = "appID";
                        basicProperties.ContentType = "x-m7/request; version=6";
                        basicProperties.CorrelationId = gl.ToString();
                        basicProperties.UserId = "userName";
                        basicProperties.ReplyTo = queueName;
How ever, I am not able to DeclareExchange or DeclareQueue with the provided username and appid.  I even emailed the Rabbitmq server (epex spot) in my case about the problem and in response i received that username/appid are all configured properly and there isn't any issue from there end. Can you please suggest me how i can check the permission of a username from client side? to make sure that provided username has all the required permissions.
Thanks
Best Regards
Prajwal

Luke Bakken

unread,
Oct 2, 2018, 5:18:48 PM10/2/18
to rabbitmq-users
Hi Prajwal,

Neither of those properties are used for authentication. Please check to see how you're opening the connection and what username and password are being used there.

https://www.rabbitmq.com/access-control.html

Thanks,
Luke
To unsubscribe from this group and stop receiving emails from it, send an email to rabbitmq-users+unsubscribe@googlegroups.com.
To post to this group, send email to rabbitmq-users@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.


--
MK

Staff Software Engineer, Pivotal/RabbitMQ

--
You received this message because you are subscribed to the Google Groups "rabbitmq-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rabbitmq-users+unsubscribe@googlegroups.com.
To post to this group, send email to rabbitmq-users@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.


--
Best Regards
Prajwal

Michael Klishin

unread,
Oct 2, 2018, 6:04:32 PM10/2/18
to rabbitm...@googlegroups.com
User ID set on messages will be validated against the actual user, though [1]. Maybe that'd be a decent alternative?


To unsubscribe from this group and stop receiving emails from it, send an email to rabbitmq-user...@googlegroups.com.
To post to this group, send email to rabbitm...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.


--
MK

Staff Software Engineer, Pivotal/RabbitMQ

--
You received this message because you are subscribed to the Google Groups "rabbitmq-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rabbitmq-user...@googlegroups.com.
To post to this group, send email to rabbitm...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.


--
Best Regards
Prajwal

--
You received this message because you are subscribed to the Google Groups "rabbitmq-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rabbitmq-user...@googlegroups.com.
To post to this group, send email to rabbitm...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Prajwal Amatya

unread,
Oct 2, 2018, 6:22:47 PM10/2/18
to rabbitmq-users
Luke/Michael,
I am using user/pass provided to me by epex spot. And i am able to connect to the server with the provided credentials. Also, i have set user id on the basic properties while sending message. Still i am not able to DeclareExchange or DeclareQueue. Is there something i am missing with the request i am making? As initial connection created is successful but anything further than that closes the channel.

Following is the line of codes :            
ConnectionFactory factory = new RabbitMQ.Client.ConnectionFactory();
            string queueName,exchangeName;
            string tradeXML;
               var body = Encoding.UTF8.GetBytes("Hello World");
            Guid gl;
            gl = Guid.NewGuid();
            exchangeName = "M7.echangeName.username"; //+ DateTime.Now.ToString("yyyyMMddHHmmss");
            queueName = "M7.private.responseName.username." + gl;
         
            factory.UserName = "username";
            factory.Password = "password";
            factory.VirtualHost = "app";
            factory.HostName = "hostURL";
            factory.Port = 1800;
            factory.AutomaticRecoveryEnabled = true;
          
            factory.Protocol = Protocols.AMQP_0_9_1;
          
            factory.RequestedHeartbeat = 60;

            factory.Ssl.Enabled = true;
            factory.Ssl.ServerName =
            factory.Ssl.CertPath = @"certpath";
            factory.Ssl.CertPassphrase = "CertPassword";
            factory.Ssl.Version = System.Security.Authentication.SslProtocols.Tls12;
            factory.Ssl.ServerName = "servernameURL";
          
            var properties = new Dictionary<String, Object>
                         {
                           {"AppId","provided_appID"},
                           {"CorrelationId",gl.ToString()},
                           {"ContentType","x-m7/request; version=6"},
                           {"UserId","username"},
                           {"ReplyTo",queueName},
                           {"ClientProvidedName","Prajwal"}
                         };
            factory.ClientProperties = properties;
          
            using (IConnection conn = factory.CreateConnection())
            {
                using (IModel channel = conn.CreateModel())
                {
                    conn.AutoClose = true;
                  
                        channel.BasicQos(0, 1, false);
                        channel.BasicAck(0, true);
                 
                        IBasicProperties basicProperties =  channel.CreateBasicProperties();
                        basicProperties.AppId = "provided_appID";

                        basicProperties.ContentType = "x-m7/request; version=6";
                        basicProperties.CorrelationId = gl.ToString();
                        basicProperties.UserId = "username";
                        basicProperties.ReplyTo = queueName;

                        var heartbeatConsumer = new EventingBasicConsumer(channel);
                        heartbeatConsumer.Received += (model, ea) =>
                        {
                            var result = ea.Body;
                            var message = Encoding.UTF8.GetString(result);
                      
                        };

                    
                        var consumer = new EventingBasicConsumer(channel);
                        channel.BasicGet(queueName, true); 
                }
            }




To unsubscribe from this group and stop receiving emails from it, send an email to rabbitmq-user...@googlegroups.com.
To post to this group, send email to rabbitm...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.


--
MK

Staff Software Engineer, Pivotal/RabbitMQ

--
You received this message because you are subscribed to the Google Groups "rabbitmq-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rabbitmq-user...@googlegroups.com.
To post to this group, send email to rabbitm...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.


--
Best Regards
Prajwal

--
You received this message because you are subscribed to the Google Groups "rabbitmq-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rabbitmq-user...@googlegroups.com.
To post to this group, send email to rabbitm...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.


--
Best Regards
Prajwal

Michael Klishin

unread,
Oct 2, 2018, 6:46:23 PM10/2/18
to rabbitm...@googlegroups.com
Please see (and post) server logs. A user must have appropriate permissions
for the virtual host(s) they connect to [1].

Prajwal Amatya

unread,
Oct 3, 2018, 11:22:16 AM10/3/18
to rabbitmq-users
Michael,
Unfortunately i do not have access to server logs as its a third party server that we have to connect.  Is there a way in which we can check permissions for client end ?
thank you

Luke Bakken

unread,
Oct 3, 2018, 11:32:17 AM10/3/18
to rabbitmq-users
Hi Prajwal,

If you have access to the RabbitMQ management interface, you can go to Admin -> Users -> click on username to see that user's permissions.

You can also use the HTTP API to retrieve a user's permissions. Here is an example request:

curl -u guest:guest localhost:15672/api/users/guest/permissions

This returns the following in my environment:

[{"user":"guest","vhost":"/","configure":".*","write":".*","read":".*"}]

You will have to modify the arguments to curl to match your environment, of course.

Thanks,
Luke

Prajwal Amatya

unread,
Oct 3, 2018, 11:53:32 AM10/3/18
to rabbitmq-users
Thanks Luke,
when i try to use curl as you suggested i received '(52) Empty reply from server'. Looks like there is some firewall which has blocked my access through curl. Anyways, thank you  and Micheal for the support you have given me.
I really appreciate it.
Prajwal

--
You received this message because you are subscribed to the Google Groups "rabbitmq-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rabbitmq-user...@googlegroups.com.
To post to this group, send email to rabbitm...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--
Best Regards
Prajwal

Prajwal Amatya

unread,
Oct 6, 2018, 5:31:40 PM10/6/18
to rabbitmq-users
along with AppID, we need to send exchangeID, Correlation ID and other information as client properties while connecting to the Rabbitmq server. After sending these information issue were solved.
Thank you for your support and comment.
Thanks & Regards
Prajwal
--
Best Regards
Prajwal
Reply all
Reply to author
Forward
0 new messages