簡體   English   中英

嘗試連接到unity3d中啟用TLS的代理時的MQTT超時

[英]MQTT Timeout when trying to connect to TLS enabled broker in unity3d

我正在Unity中構建AR應用程序,需要連接到啟用了TLS協議的MQTT代理。 我能夠成功地(統一地)連接到未啟用TLS的MQTT代理,並且我可以使用管理員通過此程序http://www.mqttfx.org/授予我的證書來成功連接到啟用TLS的代理。 但是,當我嘗試使用Unity中c#的m2mqtt庫連接到啟用了TLS的服務器時,出現超時異常,並且從未收到來自代理的響應。 這是我用來測試連接的代碼。 我只是嘗試建立成功的連接,然后斷開連接。

X509Certificate certificate = X509Certificate.CreateFromCertFile("filePath");

// Connect to this broker address at port 1883 with tls enabled 
client = new MqttClient(brokerAddress, port, true, certificate);

// Generate a client id
string clientId = Guid.NewGuid().ToString(); 

// Connect to the client with credentials
byte code = client.Connect(clientId, username, password;

// Disconnect       
client.Disconnect ();

連接期間發生此異常:

MqttCommunicationException: An application exception has occurred.
uPLibrary.Networking.M2Mqtt.MqttClient.SendReceive (System.Byte[] msgBytes, Int32 timeout) (at Assets/MQTT/scripts/MqttClient.cs:953)
uPLibrary.Networking.M2Mqtt.MqttClient.SendReceive (uPLibrary.Networking.M2Mqtt.Messages.MqttMsgBase msg, Int32 timeout) (at Assets/MQTT/scripts/MqttClient.cs:976)
uPLibrary.Networking.M2Mqtt.MqttClient.SendReceive (uPLibrary.Networking.M2Mqtt.Messages.MqttMsgBase msg) (at Assets/MQTT/scripts/MqttClient.cs:964)
uPLibrary.Networking.M2Mqtt.MqttClient.Connect (System.String clientId, System.String username, System.String password, Boolean willRetain, Byte willQosLevel, Boolean willFlag, System.String willTopic, System.String willMessage, Boolean cleanSession, UInt16 keepAlivePeriod) (at Assets/MQTT/scripts/MqttClient.cs:456)
uPLibrary.Networking.M2Mqtt.MqttClient.Connect (System.String clientId, System.String username, System.String password, Boolean cleanSession, UInt16 keepAlivePeriod) (at Assets/MQTT/scripts/MqttClient.cs:395)
ConnectionManager.connectToMQTTBroker () (at Assets/Scripts/ConnectionManager.cs:55)

任何幫助將不勝感激。 我已經堅持了好幾天。

M2Mqtt不支持TLS_V2,因為我們無法統一使用證書。 這是由於.Net FrameWork版本支持。 對於證書,我們使用TLSV_2 QOS級別進行連接。.Net4及更高版本支持該級別,但是Unity僅支持.Net 3.5版本。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM