What is the minimum required information to connect via MQTT

I am trying to connect (using a Ruby gem) to the TTN network and am unsure as to the minimum mandatory requirement for parameters to initialise the library. So far I have used the following, but get the message:
packet.rb:281:in `read’: execution expired (Timeout::Error)

client.connect(
:host => “eu.thethings.network”,
:port => 1883,
:username => ttn_app_id,
:password => ttn_app_access_key
)

I think that this is correct (I substitute the correct terms for the appID and access key) but can’t seem to make it work. It seems to be hanging during the login - but maybe I need another version of ruby…

Hi,
Using the ‘mqtt’ gem:

appId = 'APPID'
accessKey = 'ttn-account-XXXXXX'

MQTT::Client.connect("mqtt://#{appId}:#{accessKey}@eu.thethings.network:1883") do |c|
   # If you pass a block to the get method, then it will loop
  c.get("#{appId}/devices/+/up") do |topic,message|
    puts "#{topic}: #{message}"

    payload = JSON.parse(message)
    data = payload['payload_raw']
    #puts data.unpack data
    puts "[MQTTAdapter] DATA #{Base64.decode64(data)}"
  end
end

Hello Christoph,
Thanks for that - I actually got it to work…it was specifying the access key as “ttn-account-xxxxx” that I had wrong.
The mqtt gem works really well.
Thanks for getting back to me.
Jimgi