2016-10-07 15 views
1

Ich bin mit der mqtt verbinden und ich erhalte eine nicht hilfreiche Ausnahme.Ausnahme des Typs 'UPLibrary.Networking.M2Mqtt.Exceptions.MqttClientException' wurde ausgelöst

-Code

string smsTopic = ConfigurationManager.AppSettings["MQTT_SMS_Topic"]; 
string emailTopic = ConfigurationManager.AppSettings["MQTT_Email_Topic"]; 
string pushTopic = ConfigurationManager.AppSettings["MQTT_PUSH_Topic"]; 
string socialTopic = ConfigurationManager.AppSettings["MQTT_SOCIAL_Topic"]; 

client = new MqttClient("somehostname"); 
string clientId = Guid.NewGuid().ToString(); 
client.Connect(clientId); 
client.MqttMsgPublishReceived += client_MqttMsgPublishReceived; 
client.Subscribe(new string[] { smsTopic, emailTopic, pushTopic, socialTopic }, new byte[] { MqttMsgBase.QOS_LEVEL_EXACTLY_ONCE }); 

Ausnahmemeldung

Ausnahme vom Typ 'uPLibrary.Networking.M2Mqtt.Exceptions.MqttClientException'

Stacktrace der geworfen wurde Ausnahme

at uPLibrary.Networking.M2Mqtt.Messages.MqttMsgSubscribe.GetBytes(Byte protocolVersion) in c:\Users\ppatierno\Source\Repos\m2mqtt\M2Mqtt\Messages\MqttMsgSubscribe.cs:line 187 
at uPLibrary.Networking.M2Mqtt.MqttClient.Send(MqttMsgBase msg) in c:\Users\ppatierno\Source\Repos\m2mqtt\M2Mqtt\MqttClient.cs:line 1028 
at uPLibrary.Networking.M2Mqtt.MqttClient.ProcessInflightThread() in c:\Users\ppatierno\Source\Repos\m2mqtt\M2Mqtt\MqttClient.cs:line 1954 
at System.Threading.ThreadHelper.ThreadStart_Context(Object state) 
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) 
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) 
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) 
at System.Threading.ThreadHelper.ThreadStart() 

Ich gründete eine bug on the github, aber ohne Lösung

Die Ausnahmemeldung ist überhaupt nicht hilfreich, und es gibt keine innere Ausnahme in seinem Inneren.

Antwort

0

konnte ich diese verdrahtete Ausnahme lösen, indem

client.Subscribe(new string[] { smsTopic, emailTopic, pushTopic, socialTopic }, new byte[] { MqttMsgBase.QOS_LEVEL_EXACTLY_ONCE }); 

zu

client.Subscribe(new string[] { smsTopic }, new byte[] { MqttMsgBase.QOS_LEVEL_EXACTLY_ONCE }); 
client.Subscribe(new string[] { emailTopic }, new byte[] { MqttMsgBase.QOS_LEVEL_EXACTLY_ONCE }); 
client.Subscribe(new string[] { pushTopic }, new byte[] { MqttMsgBase.QOS_LEVEL_EXACTLY_ONCE }); 
client.Subscribe(new string[] { socialTopic }, new byte[] { MqttMsgBase.QOS_LEVEL_EXACTLY_ONCE }); 

die folgenden Anweisung ändert es die mqtt Bug hat angezeigt, wenn in der gleichen Zeit mehr als ein Thema angeben.

2

Viel besser:

client.Subscribe(new string[] 
    { smsTopic, emailTopic, pushTopic, socialTopic }, 
    new byte[] { 
     MqttMsgBase.QOS_LEVEL_EXACTLY_ONCE, 
     MqttMsgBase.QOS_LEVEL_EXACTLY_ONCE, 
     MqttMsgBase.QOS_LEVEL_EXACTLY_ONCE, 
     MqttMsgBase.QOS_LEVEL_EXACTLY_ONCE 
    } 
); 
+0

dies war auch für mich. –

Verwandte Themen