Because IoT Hub is not a broker, I want to use a Raspberry Pi as a broker which devices can communicate with, and the Raspberry Pi sends messages it receives to IoT Hub. After intallation of Mosquitto on Raspberry this is my file of configuration mosquitto:
connection iothub-bridge
log_type all
address your hub.azure-devices.net:8883
remote_username your hub.azure-devices.net/your device
remote_password sas token
remote_clientid your device
bridge_cafile /home/pi/baltimore.pem
try_private false
cleansession true
start_type automatic
bridge_insecure false
bridge_protocol_version mqttv311
bridge_tls_version tlsv1.2
notifications false
notification_topic events/
topic devices/Your device/messages/events/
The problem is a SAS token is used for few hours and will expire, I want a solution to replace SAS TOKEN and work for forever.