zivillian / ism7mqtt

GNU General Public License v3.0
56 stars 10 forks source link

Special characters in parameter name for Heatpump CHA and in username for the broker (in --mqttuser) #39

Closed MKModder closed 1 year ago

MKModder commented 1 year ago

Hello

thanks for this great tool and for the work you are spending on it. When I tried the currenty last version (0.0.9) I ran into an isssue with a "+" character inside of a parameter name: In example this one: "Leistungsaufnahme(WP+_EHZ)" (I am running the tool with parameter -s)

Stack Trace:

publishing mqtt with topic 'Wolf/192.168.178.106/CHA0x8/Leistungsaufnahme(WP_+_EHZ)' '0.0' MQTTnet.Exceptions.MqttProtocolViolationException: The character '+' is not allowed in topics. at MQTTnet.Protocol.MqttTopicValidator.ThrowIfInvalid(String topic) at MQTTnet.Protocol.MqttTopicValidator.ThrowIfInvalid(MqttApplicationMessage applicationMessage) at MQTTnet.Client.MqttClient.PublishAsync(MqttApplicationMessage applicationMessage, CancellationToken cancellationToken) at ism7mqtt.Program.OnMessage(IMqttClient client, MqttMessage message, Boolean debug, CancellationToken cancellationToken) in /home/runner/work/ism7mqtt/ism7mqtt/src/ism7mqtt/Program.cs:line 226 at ism7mqtt.Ism7Client.OnInitialValuesAsync(IResponse response, CancellationToken cancellationToken) in /home/runner/work/ism7mqtt/ism7mqtt/src/ism7mqtt/ISM7/Ism7Client.cs:line 285 at ism7mqtt.ResponseDispatcher.DispatchAsync(IResponse response, CancellationToken cancellationToken) in /home/runner/work/ism7mqtt/ism7mqtt/src/ism7mqtt/ISM7/ResponseDispatcher.cs:line 32 at ism7mqtt.Ism7Client.ReadPipeAsync(PipeReader source, CancellationToken cancellationToken) in /home/runner/work/ism7mqtt/ism7mqtt/src/ism7mqtt/ISM7/Ism7Client.cs:line 178 System.IO.IOException: Unable to read data from the transport connection: Der E/A-Vorgang wurde wegen eines Threadendes oder einer Anwendungsanforderung abgebrochen.. ---> System.Net.Sockets.SocketException (995): Der E/A-Vorgang wurde wegen eines Threadendes oder einer Anwendungsanforderung abgebrochen. --- End of inner exception stack trace --- at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.System.Threading.Tasks.Sources.IValueTaskSource.GetResult(Int16 ) at System.Net.Security.SslStream.EnsureFullTlsFrameAsyncTIOAdapter at System.Net.Security.SslStream.ReadAsyncInternal[TIOAdapter](TIOAdapter , Memory`1 ) at ism7mqtt.Ism7Client.FillPipeAsync(PipeWriter target, CancellationToken cancellationToken) in /home/runner/work/ism7mqtt/ism7mqtt/src/ism7mqtt/ISM7/Ism7Client.cs:line 132 ///////////////////////////////////////////////////////

Further I noticed that I am unable to have the executable working with a broker that is secured by using a user name (and password) which contains the special german chacater "ä" inside. What I tried is a commandline like this: ism7mqtt -m XXX.XXX.XXX.XX --mqttuser "ä user" --mqttpass ?CrypticSamplePassword! -i XXX.XXX.XXX.XX -p ISM7Pass -d -s

Stack Trace: MQTTnet.Adapter.MqttConnectingFailedException: Connecting with MQTT server failed (NotAuthorized). at MQTTnet.Client.MqttClient.AuthenticateAsync(IMqttChannelAdapter channelAdapter, MqttApplicationMessage willApplicationMessage, CancellationToken cancellationToken) at MQTTnet.Client.MqttClient.ConnectAsync(IMqttClientOptions options, CancellationToken cancellationToken) at MQTTnet.Client.MqttClient.ConnectAsync(IMqttClientOptions options, CancellationToken cancellationToken) at ism7mqtt.Program.Main(String[] args) in /home/runner/work/ism7mqtt/ism7mqtt/src/ism7mqtt/Program.cs:line 107 mqtt disconnected - reconnecting in 5 seconds Unhandled exception. MQTTnet.Adapter.MqttConnectingFailedException: Connecting with MQTT server failed (NotAuthorized). at MQTTnet.Client.MqttClient.AuthenticateAsync(IMqttChannelAdapter channelAdapter, MqttApplicationMessage willApplicationMessage, CancellationToken cancellationToken) at MQTTnet.Client.MqttClient.ConnectAsync(IMqttClientOptions options, CancellationToken cancellationToken) at MQTTnet.Client.MqttClient.ConnectAsync(IMqttClientOptions options, CancellationToken cancellationToken) at ism7mqtt.Program.Main(String[] args) in /home/runner/work/ism7mqtt/ism7mqtt/src/ism7mqtt/Program.cs:line 107 at ism7mqtt.Program.

(String[] args)

Thanks for help and advice.

zivillian commented 1 year ago

I've tested the mqtt username with special chars and spaces, but I can't reproduce your issue.

The missing escape of plus signs in mqtt topics is already fixed, but I've not yet released a new version. Can you try either the docker image zivillian/ism7mqtt:master or a current build from master?

krkuhlmann commented 1 year ago

I also do own a CHA and get the sam issue with the Parameter 27049 at Bus 0x08 named "Leistungsaufnahme (WP + EHZ)" with the exact same exception. I created a new container on the zivillian/ism7mqtt:master but the error remains.

zivillian commented 1 year ago

@krkuhlamnn ~can you post your exception?~ Nevermind, I've found the problem.

zivillian commented 1 year ago

@krkuhlamnn should be fixed, can you try again with the latest master?

krkuhlmann commented 1 year ago

@zivillian I rebased the container and now I am getting the value as expected. Thank you very much! Great work!

publishing mqtt with topic 'Wolf/192.168.0.82/CHA_0x8/Leistungsaufnahme_(WP___EHZ)' '0.3'