rksg / gpb_mqtt_sample_client

Sample SPoT Location Push API client code and GPB binding code generator for SPoT Push API
BSD 3-Clause "New" or "Revised" License
2 stars 3 forks source link

not able to connect to vSPoT api's #1

Closed rlsaurabh closed 8 years ago

rlsaurabh commented 8 years ago

I'm not able to connect to vSPoT api's

vSPoT instance IP - 192.168.99.135 mqtt broker IP - 192.168.99.122, venue_id - vspot password - 12345678

below is my mosquitto-bridge config file:

pid_file /tmp/mqtt_bridge.pidautosave_interval 0
autosave_on_changes false
persistence true
persistence_file mqtt_bridge.db
persistence_location /tmp/
log_dest file /tmp/mqtt_bridge.log
log_type debug
# listener for MQTT messages without PSK
listener 1883 192.168.99.122
connection spot_push_api_mqtt_bridge
address 192.168.99.135:8883
topic "1.0.0/LOC/SPOT_GPB/vspot/GPB_LOCR" in
bridge_tls_version tlsv1
bridge_identity vspot
bridge_psk 12345678

I've used the following command to start the local mosquitto broker: mosquitto -c mosquitto_bridge.conf

After this I locally subscribe to the mqtt-bridged TLS PSK connection to venue server using the mosquitto_sub utility: mosquitto_sub -h 192.168.99.122 -p 1883 -t "1.0.0/LOC/SPOT_GPB/vspot/GPB_LOCR"

I was expecting some encoded message streaming on my stdout. Unfortunately this is not happening.

Kindly help.

yeongsheng-tan commented 8 years ago

@rlsaurabh in your mosquitto_bridge.conf, the key-value pair setting of _bridgepsk should be hex encrypted. You should be able to read the connectivity error from /tmp/mqtt_bridge.log. It is evident you have used the non-encrypted _bridgepsk value.

You may try this online tool to help you derive the correct _bridgepsk .

  1. Enter into the 'Text (ASCII/ANSI)' text box your unencrpyted _bridgepsk of '12345678'
  2. Click 'Convert' button
  3. Copy the concatenated value in the 'Hexadecimal' text box
  4. Paste the above hexadecimal value of '3132333435363738' (ascii to hex value) into your mosquitto_bridge.conf file configuration item _bridgepsk value (previously '12345678') as you have pasted above, with this hexadecimal value.
yeongsheng-tan commented 8 years ago

@rlsaurabh would appreciate if you could close this issue if the above fix works for you. Thank you.

rlsaurabh commented 8 years ago

Thanks for the reply

Even with the changes you mentioned, it's not working. This is now my config file:

pid_file /tmp/mqtt_bridge.pid
autosave_interval 0
autosave_on_changes false
persistence true
persistence_file mqtt_bridge.db
persistence_location /tmp/
log_dest file /tmp/mqtt_bridge.log
log_type debug

# listener for MQTT messages without PSK
listener 1883 192.168.99.122
connection spot_push_api_mqtt_bridge
address 192.168.99.135:8883
topic "1.0.0/LOC/SPOT_GPB/vspot/GPB_LOCR" in
bridge_tls_version tlsv1
bridge_identity vspot
bridge_psk '3132333435363738'

Log only shows sending CONNECT messages : 1459341885: Bridge Vostro-3446.spot_push_api_mqtt_bridge sending CONNECT

But, this command is working for me, and I'm seeing encrypted messages on the stdout: mosquitto_sub -h 192.168.99.135 -p 8883 -t "1.0.0/LOC/SPOT_GPB/vspot/GPB_LOCR" --psk 3132333435363738 --psk-identity vspot --tls-version tlsv1

I'm still not able to figure out what the issue is over here. Do let me know.

yeongsheng-tan commented 8 years ago

@rlsaurabh 2 issues I see above and you seem to have conflated 2 concepts.

The mosquitto bridge setting is so that you can ease development w/o coding to TLS PSK connection for your client code. Therefore, if you have a piece of client code, it should register to listen to mqtt on host 192.168.99.122 on port 1883.

If you are only intending to test out connectivty to receive SPoT Location GPB messages over mqtt, you could easily have just used (as shown in above snippets) the below, without running a mqtt bridge broker on 192.168.99.122:1883 at all:

mosquitto_sub -h 192.168.99.135 -p 8883 -t "1.0.0/LOC/SPOT_GPB/vspot/GPB_LOCR" --psk 3132333435363738 --psk-identity vspot --tls-version tlsv1

To further debug, can you not run any mosquitto bridged broker on 192.168.122:1883 (though this is highly unlikely the cause), then just issue the below instead and see if you even receive any mqtt packets at all:

mosquitto_sub -h 192.168.99.135 -p 8883 -t "#" --psk 3132333435363738 --psk-identity vspot --tls-version tlsv1

If you do not even seem to be receiving any packets (I would expect to see MQG/MGR, PAQ/PAR, etc types of messages on top of the Location GPB packets.

Please try the above and let me know the results.

yeongsheng-tan commented 8 years ago

BTW @rlsaurabh in your mosquitto_bridge.conf, the entry for _bridgepsk is still wrong. DO NOT quote the psk value.

It should therefore be: bridge_psk 3132333435363738

Similarly topic does not need to be quoted and should therefor be: topic 1.0.0/LOC/SPOT_GPB/vspot/GPB_LOCR in

rlsaurabh commented 8 years ago

Brilliant!

That was the issue! Removed the quotes as you advised and now it works. Thanks a lot!