Closed dries007 closed 2 weeks ago
Seem you have it all covered, so please feel free to submit a pull request.
I am not personally using tls, so if you submit changes that work for you, then they are very likely to be accepted.
I'll have a talk with our PO, I can't guarantee we'll get the required time.
Ok, one good argument is that you are using gratis software, which others spend a lot of unpaid time maintaining. The success of the library depends on many each making a small part.
Oh I know, and so does he, but I still have to ask.
Closing as being not able to reproduce. We managed to test against a real device (thanks to my old colleagues at Siemens), and it worked both with/without providing sslctx.
There might still be a problem, but without help we cannot pinpoint it.
OK, I'll forward this to the responcible team. In the meantime I've figured out that internally that device is using pymodbus, which makes this double strange, but I suspect they are doing something non-standard. But it's unlikely to be your problem. Thanks for looking into it.
OK.
Be aware if the device uses an old version of pymodbus, especially if it uses the 2.x versions, there are likely errors in the tis implementation. We changed quite tls a lot in the 3.5.x versions (any maybe also in 3.6.x, please see the release notes).
@dries007 Maybe is not the same problem but in my case it was related to #2014
from pymodbus.framer import FramerType
client = ModbusTlsClient(host=ip, port=port, server_hostname=ip, framer=FramerType.SOCKET, sslctx=_provide_ssl_context())
Thanks! I'll check it out
Versions
Pymodbus Specific
Description
Calling
read_holding_registers
results inConnection unexpectedly closed 0.000 seconds into read of 2002 bytes without response from slave before it closed connection
When testing with umodbus or modbus-tk, our device replied with the expected values.
After debugging we notice that pymodbus sends quite different bytes over the socket than the other two libraries.
Code samples for the other libraries included below, including byte arrays send & received.
Code and Logs
Note: Same thing happens without _provide_ssl_context in older versions. We added it to make sure SSL does not accept the wrong SSL versions (requirement on our end) and does not fail because selfsigned cert. This is the exact same context as used by manual testing with SSL sockets, umodbus and modbus-tk.
Raw socket code
umodbus
Works, We use a proprietary library layer I cannot share here, but the raw socket code above is the equivalent of what it ends up calling.
This is the relevant snippet I can share:
modbus-tk