shriyansh jain
2015-07-31 11:06:21 UTC
Hi,
I am sending data to a particular topic("Test") using user details(UserNAme:*
userA* Password: *UserApwd*) but at then time of receiving I am using
different user credentials (UserNAme:* userB* Password: *UserBpwd*) he is
also receiving the data from topic(* "Test"*).
How i can set the authentication Please let me know.
*Sender Code:*
MqttClient client = new MqttClient("Rabbit MQ VM IP");
client.Connect(*"ClientName1", "userA", "UserApwd"*);
string[] topic = {* "Test"* };
byte[] qoslevels = { MqttMsgBase.QOS_LEVEL_AT_MOST_ONCE };
client.Subscribe(topic, qoslevels);
client.MqttMsgPublished += new
MqttClient.MqttMsgPublishedEventHandler(client_MqttMsgPublished);
for (int i = 0; i < 10; i++)
{
ushort t = client.Publish("/queue/test",
Encoding.UTF8.GetBytes("testmessage" + i),
MqttMsgBase.QOS_LEVEL_AT_LEAST_ONCE, true);
Console.WriteLine("Sending: " + "testmessage" + i);
Console.WriteLine();
}
*Receiver Code*
static void Main(string[] args)
{
MqttClient client = new MqttClient("Rabbit MQ VM IP");
client.Connect(*"ClientName2", "userB", "UserBpwd"*);
string[] topic = {* "**Test**"* };
byte[] qoslevels = { MqttMsgBase.QOS_LEVEL_AT_MOST_ONCE };
client.Subscribe(topic, qoslevels);
client.MqttMsgPublishReceived += new
MqttClient.MqttMsgPublishEventHandler(client_PublishArrived);
Console.ReadLine();
}
private static void client_PublishArrived(object sender,
MqttMsgPublishEventArgs e)
{
Console.WriteLine("Message Received " +
Encoding.UTF8.GetString(e.Message));
Console.WriteLine();
}
Thanks
I am sending data to a particular topic("Test") using user details(UserNAme:*
userA* Password: *UserApwd*) but at then time of receiving I am using
different user credentials (UserNAme:* userB* Password: *UserBpwd*) he is
also receiving the data from topic(* "Test"*).
How i can set the authentication Please let me know.
*Sender Code:*
MqttClient client = new MqttClient("Rabbit MQ VM IP");
client.Connect(*"ClientName1", "userA", "UserApwd"*);
string[] topic = {* "Test"* };
byte[] qoslevels = { MqttMsgBase.QOS_LEVEL_AT_MOST_ONCE };
client.Subscribe(topic, qoslevels);
client.MqttMsgPublished += new
MqttClient.MqttMsgPublishedEventHandler(client_MqttMsgPublished);
for (int i = 0; i < 10; i++)
{
ushort t = client.Publish("/queue/test",
Encoding.UTF8.GetBytes("testmessage" + i),
MqttMsgBase.QOS_LEVEL_AT_LEAST_ONCE, true);
Console.WriteLine("Sending: " + "testmessage" + i);
Console.WriteLine();
}
*Receiver Code*
static void Main(string[] args)
{
MqttClient client = new MqttClient("Rabbit MQ VM IP");
client.Connect(*"ClientName2", "userB", "UserBpwd"*);
string[] topic = {* "**Test**"* };
byte[] qoslevels = { MqttMsgBase.QOS_LEVEL_AT_MOST_ONCE };
client.Subscribe(topic, qoslevels);
client.MqttMsgPublishReceived += new
MqttClient.MqttMsgPublishEventHandler(client_PublishArrived);
Console.ReadLine();
}
private static void client_PublishArrived(object sender,
MqttMsgPublishEventArgs e)
{
Console.WriteLine("Message Received " +
Encoding.UTF8.GetString(e.Message));
Console.WriteLine();
}
Thanks
--
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+***@googlegroups.com.
To post to this group, send an email to rabbitmq-***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
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+***@googlegroups.com.
To post to this group, send an email to rabbitmq-***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.