Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add possibility to connect via ssl to broker #245

Merged
merged 1 commit into from
Jul 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion env.example
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ REDIS_STORE=redis://redis:6379/3
MQTT_HOST=mqtt
#MQTT_CLEAN_SESSION=true
#MQTT_CLIENT_ID=some_id

#MQTT_PORT=port
#MQTT_SSL=false
aws_secret_key=123

# kairos Dockerized
Expand Down
8 changes: 7 additions & 1 deletion lib/tasks/mqtt_subscriber.rake
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,23 @@ namespace :mqtt do
mqtt_clean_session = ENV.has_key?('MQTT_CLEAN_SESSION') ? ENV['MQTT_CLEAN_SESSION'] == "true" : true
mqtt_client_id = ENV.has_key?('MQTT_CLIENT_ID') ? ENV['MQTT_CLIENT_ID'] : nil
mqtt_host = ENV.has_key?('MQTT_HOST') ? ENV['MQTT_HOST'] : 'mqtt'
mqtt_port = ENV.has_key?('MQTT_PORT') ? ENV['MQTT_PORT'] : 1883
mqtt_ssl = ENV.has_key?('MQTT_SSL') ? ENV['MQTT_SSL'] : false

mqtt_log.info('MQTT TASK STARTING')
mqtt_log.info("clean_session: #{mqtt_clean_session}")
mqtt_log.info("client_id: #{mqtt_client_id}")
mqtt_log.info("host: #{mqtt_host}")
mqtt_log.info("port: #{mqtt_port}")
mqtt_log.info("ssl: #{mqtt_ssl}")

begin
MQTT::Client.connect(
:host => mqtt_host,
:port => mqtt_port,
:clean_session => mqtt_clean_session,
:client_id => mqtt_client_id
:client_id => mqtt_client_id,
:ssl => mqtt_ssl
) do |client|

mqtt_log.info "Connected to #{client.host}"
Expand Down