TrakHound / MTConnect.NET

Fully featured .NET library in C# to build MTConnect Agent, Adapter, and Client Applications. Pre-built Agents with Windows Installers. Support for Windows and Linux. Supports MTConnect Versions up to 2.3. Supports .NET Framework 4.6.1 up to .NET 8
http://www.TrakHound.com
MIT License
96 stars 36 forks source link

Added exception unwinding and logging on MqttRelay module when connec… #67

Closed virizar closed 2 months ago

virizar commented 2 months ago

As discussed on #66, I have added unwinding of the exceptions and logging the inner exceptions and the base exception when the connection attempt of MqttRelay throws. Below an example of the output, which corresponds to the problem described in the issue

2024-06-21 03:18:35.4669|WARN|modules.mqtt-relay|MQTT Relay Connection Error : Authentication failed, see inner exception.
2024-06-21 03:18:35.4669|WARN|modules.mqtt-relay|MQTT Relay Connection Error (InnerException) : Authentication failed, see inner exception.
2024-06-21 03:18:35.4669|WARN|modules.mqtt-relay|MQTT Relay Connection Error (InnerException) : SSL Handshake failed with OpenSSL error - SSL_ERROR_SSL.
2024-06-21 03:18:35.4669|WARN|modules.mqtt-relay|MQTT Relay Connection Error (InnerException) : error:14094412:SSL routines:ssl3_read_bytes:sslv3 alert bad certificate
2024-06-21 03:18:35.4669|WARN|modules.mqtt-relay|MQTT Relay Connection Error (BaseException) : Interop+Crypto+OpenSslCryptographicException: error:14094412:SSL routines:ssl3_read_bytes:sslv3 alert bad certificate

Maybe this can be converted to a utility function that can be used all around the code, if you find it useful.