Open kennethhutw opened 7 years ago
The current sample implementation does not showcase how to setup a java mqtt client using TLS v1 psk connection to a broker.
What you can do, is to locally startup a bridge mqtt broker, where your java client code will be running, then setup the local bridge mqtt broker to bridge to the source SPoT/vSPoT mqtt broker using TLS v1 psk connection.
Then have your java code connect to your local bridge mqtt broker over clear via port 1883.
Please see https://github.com/rksg/gpb_mqtt_sample_client/blob/master/mqtt_bridge_conf/mosquitto_bridge.conf.sample for sample config for local bridge mqtt broker setup.
Thank yeongsheng-tan. My client provide me multi brokers. How do I configure it for multi-broker? I try to do it by following code but it seems not work
pid_file C:\temp\mqtt_bridge.pid
autosave_interval 0
autosave_on_changes false
persistence false
persistence_file mqtt_bridge.db
persistence_location C:\temp
log_dest file C:\temp\mqtt_bridge.log
log_type debug
# listener for MQTT messages without PSK
listener 1883 localhost
connection spot_push_api_mqtt_bridge
address <spot_venue_server_fqdn1>:8883 <spot_venue_server_fqdn2>:8883
topic 1.0.0/LOC/SPOT_GPB/<venue_id1>/GPB_LOCR in 1.0.0/LOC/SPOT_GPB/<venue_id2>/GPB_LOCR in
bridge_tls_version tlsv1
bridge_identity <psk_identity1> <psk_identity2>
bridge_psk <psk1> <psk2>
Please see official documentation at mosquitto-conf-5 under Section: "Configuring Bridges"
The other simpler option (I'm assuming each origin/source mqtt broker that you are bridging), has different psk-identity and psk, therefore, is to run multiple bridge brokers which you will need multiple java clients to connect to.
Thank you for reply but the performance of broker bridge are too high. This is why I want to directly connect to remote broker. Do you have any suggestion ?
Hi Folks,
is anyone still interested in this? Using the commented out code and Paho, I have a direct PSK connection working.
Steve
Hi @sjerman do you have a PR for your solution? I'd be interested to add it to the base example.
It isn't directly pullable ... I made a bunch of changes (including changing the client library). I didn't see how you could do the same thing with the fuse library (but was more familiar with the Paho library ...so may not have looked hard enough.
However, the source is here - and it will work with a standard Mosquitto server with PSK enabled:
https://bitbucket.org/stjerman/mqtt-example/src
Steve
@sjerman I'll take a look when I have time. Probably we can create a secondary sample using your code, instead of trying to muck around with the original sample which uses the fuse mqtt client lib
How connect to broker by TLSPSKClient
//TLSPSKClient lbsTLSPSKClient = new TLSPSKClient("rksg-dev.venue.ruckuslbs.com", "rksg-dev".getBytes(), "abcdefghijklmnopqrstuvw".getBytes());