Guest User

Untitled

a guest
Jan 29th, 2019
204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.34 KB | None | 0 0
  1. require 'bunny'
  2.  
  3.  
  4. @rabbitmq_host = 'localhost'
  5.  
  6. # here the default for :tls value is false
  7. def get_connection_options()
  8. opts = {
  9. hosts: [ @rabbitmq_host ], port: 5671, vhost: '/',
  10. pass: 'guest', user: 'guest', ssl: true,
  11. verify_ssl: true, heartbeat: 2,
  12. tls: false,
  13. tls_cert: nil,
  14. tls_key: nil,
  15. verify_peer: false
  16. }
  17. return opts
  18. end
  19.  
  20.  
  21. def works()
  22. opts = {
  23. hosts: [ @rabbitmq_host ], port: 5671, vhost: '/',
  24. pass: 'guest', user: 'guest', ssl: true,
  25. verify_ssl: true, heartbeat: 2,
  26. tls: true,
  27. tls_verify_peer: true
  28. }
  29. return opts
  30. end
  31.  
  32. def without_tls()
  33. opts = {
  34. hosts: [ @rabbitmq_host ], port: 5671, vhost: '/',
  35. pass: 'guest', user: 'guest', ssl: true,
  36. verify_ssl: true, heartbeat: 2,
  37. tls: nil
  38. }
  39. return opts
  40. end
  41.  
  42.  
  43. def test_connection(opts, descr)
  44. begin
  45. puts descr
  46. bb = Bunny.new opts
  47. bb.start
  48. bb.heartbeat
  49. puts 'connection success!'
  50. rescue => exception
  51. puts exception.backtrace
  52. end
  53. puts '==============================='
  54. puts
  55. end
  56.  
  57. test_connection get_connection_options, 'plugin connection attempt: fails'
  58. test_connection works, 'working connection attempt'
  59. test_connection without_tls, 'ssl without tls (or set to nil) works'
Add Comment
Please, Sign In to add comment