That's really bad that they don't even share the same interfaces.
Yep. Both Mqtt3AsyncClient and Mqtt5AsyncClient implement MqttClient interface but not some kind of MqttAsyncClient or so.
Seems like devs have cloned all classes and interfaces. The whole package structure is there for Mqtt3 and Mqtt5.
It seems like the Mqtt5 Client implementation doesn't fall back to Mqtt3 when connecting to a server that doesn't understand version 5.
I've tested my change and it seems to connect. I've build the tracker-server.jar (./gradlew assemble) and started a docker container from the original latest image but mounted my local jar into the container.
docker run --rm --name traccartest --publish 8082:8082 --volume ./traccar.xml:/opt/traccar/conf/traccar.xml:ro --volume ./tracker-server.jar:/opt/traccar/tracker-server.jar traccar/traccar:latest
With <entry key='event.forward.mqttVersion'>3</entry>
it connects to my MQTT server. Without the entry or with <entry key='event.forward.mqttVersion'>5</entry>
it doesn't connect.
I've added some unit-tests and created a pull request: https://github.com/traccar/traccar/pull/5158
Not 100% sure but from the error message I thought that this is a backwards compatibility problem with the hivemq mqtt client.
In the code Mqtt5AsyncClient is used and it seems to be incompatible to MQTT 3.x servers. But of course I can be wrong :)
I've prepared something that I need to try:
https://github.com/traccar/traccar/compare/master...jokakilla:traccar:mqtt3
In hivemq there are Mqtt3AsyncClient and Mqtt5AsyncClient.