title: MQTT on Azure IOT Hub : Error initializing MQTT connection:Not authorized to connect
body: <p>I am trying to use Microsoft Azure IOT Hub to demonstrate connecting my device to IOT Hub and send messages using mqtt protocol.
  I have an account and created device and SAS with TTL as required. I am using java client SDK given by microsoft azure to connect but my connection is not authorized.
  I have followed all the steps as given in the below URL:
  <a href="https://azure.microsoft.com/en-us/documentation/articles/iot-hub-mqtt-support/" rel="nofollow">https://azure.microsoft.com/en-us/documentation/articles/iot-hub-mqtt-support/</a>
  Please help me in this regards. My logs are below:</p>
  
  <p>Logs:</p>
  
  <pre><code>MqttIotHubConnection.open() connectionOptions=
  ============== Connection options ==============
  CleanSession : false
  SocketFactory : null
  MqttVersion : 4
  KeepAliveInterval : 20
  ConTimeout : 30
  UserName : PCSIOTHub.azure-devices.net/MQ...
  SSLProperties : null
  WillDestination : null
  
  
  Exception in thread "main" java.io.IOException: Error initializing MQTT connection:Not authorized to connect
  at com.microsoft.azure.iothub.transport.mqtt.MqttIotHubConnection.open(MqttIotHubConnection.java:142)
  at com.microsoft.azure.iothub.transport.mqtt.MqttTransport.open(MqttTransport.java:83)
  at com.microsoft.azure.iothub.DeviceClient.open(DeviceClient.java:163)
  at samples.com.microsoft.azure.iothub.SendReceive.main(SendReceive.java:210)
  </code></pre>