In theory, there should be no difference between the two calls below:
MqttClient.Connect(ApiClientId)
MqttClient.Connect(ApiClientId, null, null)
however the first call can successfully establish a connection, the second call cannot and produces the following logs:
[Information] MQTT Client lost connection. Attempting to re-establish connection...
[Error] Exception connecting to the MQTT endpoint
uPLibrary.Networking.M2Mqtt.Exceptions.MqttConnectionException: Exception connecting to the broker ---> System.Net.Internals.SocketExceptionFactory+ExtendedSocketException: An operation was attempted on something that is not a socket [sensitive text here]
at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress)
at System.Net.Sockets.Socket.Connect(EndPoint remoteEP)
at uPLibrary.Networking.M2Mqtt.MqttNetworkChannel.Connect()
at uPLibrary.Networking.M2Mqtt.MqttClient.Connect(String clientId, String username, String password, Boolean willRetain, Byte willQosLevel, Boolean willFlag, String willTopic, String willMessage, Boolean cleanSession, UInt16 keepAlivePeriod)
--- End of inner exception stack trace ---
at uPLibrary.Networking.M2Mqtt.MqttClient.Connect(String clientId, String username, String password, Boolean willRetain, Byte willQosLevel, Boolean willFlag, String willTopic, String willMessage, Boolean cleanSession, UInt16 keepAlivePeriod)
I was wondering why this happens.
Thank you.