You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We deployed the mosquito mqtt con Azure cloud. Able to use Python script to connect to broker using Certificates.
Tried different approach on C# code. But unable to do it. Connection was happening but Received Ack is not valid so its throwing error as not received response packet.
` import paho.mqtt.client as mqtt
def on_connect(client, userdata, flags, rc):
print("Connected with result code "+str(rc))
Hi,
We deployed the mosquito mqtt con Azure cloud. Able to use Python script to connect to broker using Certificates.
Tried different approach on C# code. But unable to do it. Connection was happening but Received Ack is not valid so its throwing error as not received response packet.
` import paho.mqtt.client as mqtt
def on_connect(client, userdata, flags, rc):
print("Connected with result code "+str(rc))
def on_message(client, userdata, msg):
print(msg.topic+" "+str(msg.payload))
client = mqtt.Client(transport="websockets")
client.on_connect = on_connect
client.on_message = on_message
client.tls_set(ca_certs='ca.crt', certfile='client4.crt', keyfile='client4.key', cert_reqs=mqtt.ssl.CERT_NONE, tls_version=mqtt.ssl.PROTOCOL_TLS, ciphers=None)
client.connect("xxxx.azurecontainer.io", 443, 60)
client.publish("paho/temperature", 23.2)
client.publish("paho/temperature", 23.3)
client.publish("paho/temperature", 23.4) `
The C# code created a private key using CA certificate, Client.crt and Client4.key. Then used that Private key to connect.
` string testkey = @"C:\Certificates\ClientPrivate2.pfx";
string Broker = "xxxx.azurecontainer.io";
X509Certificate2 certificate2 = new X509Certificate2(testkey,"password");
var mqttClient = new MqttClient(Broker,
port,
true,
X509Certificate.CreateFromCertFile(CaFile),
//X509Certificate2.CreateFromCertFile(CertFile),
certificate2,
MqttSslProtocols.TLSv1_0, ValidateServerCertificate);
mqttClient.ProtocolVersion = MqttProtocolVersion.Version_3_1_1;
mqttClient.MqttMsgPublishReceived += MqttClient_MqttMsgPublishReceived;
mqttClient.ConnectionClosed += MqttClient_ConnectionClosed;
mqttClient.Connect("Testing");
`
Please help on this, thank you.
The text was updated successfully, but these errors were encountered: