2016-10-07 22 views
1

mqttに接続していて、役に立たない例外が表示されています。タイプ 'uPLibrary.Networking.M2Mqtt.Exceptions.MqttClientException'の例外がスローされました

コード

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 }); 

型 'uPLibrary.Networking.M2Mqtt.Exceptions.MqttClientException' の例外がで

スタックトレースを投げた

例外メッセージ例外

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() 

私はbug on the githubを設立したが、解決策

せず、例外メッセージはまったく役に立たない、それ内部に内部例外がありません。

答えて

0

私は同時に複数のトピックを指定するときmqttがバグを持って表示されます

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 }); 

に次のステートメント

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

を変更することにより、この有線例外を解決することができました。

2

はるかに良い:

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

が、これはまた、私のために働いています。 –

関連する問題