Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require 'bunny'
- @rabbitmq_host = 'localhost'
- # here the default for :tls value is false
- def get_connection_options()
- opts = {
- hosts: [ @rabbitmq_host ], port: 5671, vhost: '/',
- pass: 'guest', user: 'guest', ssl: true,
- verify_ssl: true, heartbeat: 2,
- tls: false,
- tls_cert: nil,
- tls_key: nil,
- verify_peer: false
- }
- return opts
- end
- def works()
- opts = {
- hosts: [ @rabbitmq_host ], port: 5671, vhost: '/',
- pass: 'guest', user: 'guest', ssl: true,
- verify_ssl: true, heartbeat: 2,
- tls: true,
- tls_verify_peer: true
- }
- return opts
- end
- def without_tls()
- opts = {
- hosts: [ @rabbitmq_host ], port: 5671, vhost: '/',
- pass: 'guest', user: 'guest', ssl: true,
- verify_ssl: true, heartbeat: 2,
- tls: nil
- }
- return opts
- end
- def test_connection(opts, descr)
- begin
- puts descr
- bb = Bunny.new opts
- bb.start
- bb.heartbeat
- puts 'connection success!'
- rescue => exception
- puts exception.backtrace
- end
- puts '==============================='
- puts
- end
- test_connection get_connection_options, 'plugin connection attempt: fails'
- test_connection works, 'working connection attempt'
- test_connection without_tls, 'ssl without tls (or set to nil) works'
Add Comment
Please, Sign In to add comment