Advertisement
Guest User

Untitled

a guest
Feb 28th, 2017
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. # The Device ID
  2. device = '<Device-Id>'
  3.  
  4. # The name of your IoT Hub
  5. hubname = '<Hub Name>'
  6.  
  7. # The SAS for the device; generate it using e.g. Device Explorer or the iothub-explorer command line tool
  8. sas = '<SAS-Token>'
  9.  
  10. path = '/devices/' + device + '/messages/events'
  11.  
  12. ssl_options = ({"ca_certs": "/home/mindstix/LIOTA/trusted-certs.txt",
  13. "server_side": False})
  14.  
  15. username = device + '@sas.' + hubname
  16.  
  17. credentials = pika.PlainCredentials(username, password=sas)
  18. host = hubname + '.azure-devices.net'
  19.  
  20. print(host)
  21. print(username)
  22. print(sas)
  23.  
  24. connection = pika.BlockingConnection(pika.ConnectionParameters(
  25. host=host, port=5671, credentials=credentials,
  26. ssl=True, ssl_options=ssl_options))
  27.  
  28. print(connection)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement