{"action":"created","issue":{"url":"https://api.github.com/repos/Azure/azure-iot-sdk-python/issues/220","repository_url":"https://api.github.com/repos/Azure/azure-iot-sdk-python","labels_url":"https://api.github.com/repos/Azure/azure-iot-sdk-python/issues/220/labels{/name}","comments_url":"https://api.github.com/repos/Azure/azure-iot-sdk-python/issues/220/comments","events_url":"https://api.github.com/repos/Azure/azure-iot-sdk-python/issues/220/events","html_url":"https://github.com/Azure/azure-iot-sdk-python/issues/220","id":370820286,"node_id":"MDU6SXNzdWUzNzA4MjAyODY=","number":220,"title":"IotHubMessage is truncated by byte array containing a zero","user":{"login":"DumDumin","id":20523828,"node_id":"MDQ6VXNlcjIwNTIzODI4","avatar_url":"https://avatars3.githubusercontent.com/u/20523828?v=4","gravatar_id":"","url":"https://api.github.com/users/DumDumin","html_url":"https://github.com/DumDumin","followers_url":"https://api.github.com/users/DumDumin/followers","following_url":"https://api.github.com/users/DumDumin/following{/other_user}","gists_url":"https://api.github.com/users/DumDumin/gists{/gist_id}","starred_url":"https://api.github.com/users/DumDumin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DumDumin/subscriptions","organizations_url":"https://api.github.com/users/DumDumin/orgs","repos_url":"https://api.github.com/users/DumDumin/repos","events_url":"https://api.github.com/users/DumDumin/events{/privacy}","received_events_url":"https://api.github.com/users/DumDumin/received_events","type":"User","site_admin":false},"labels":[{"id":1003983247,"node_id":"MDU6TGFiZWwxMDAzOTgzMjQ3","url":"https://api.github.com/repos/Azure/azure-iot-sdk-python/labels/area-boost-wrapper","name":"area-boost-wrapper","color":"d4c5f9","default":false},{"id":514797837,"node_id":"MDU6TGFiZWw1MTQ3OTc4Mzc=","url":"https://api.github.com/repos/Azure/azure-iot-sdk-python/labels/investigation-required","name":"investigation-required","color":"1d76db","default":false}],"state":"open","locked":false,"assignee":{"login":"pierreca","id":4979572,"node_id":"MDQ6VXNlcjQ5Nzk1NzI=","avatar_url":"https://avatars2.githubusercontent.com/u/4979572?v=4","gravatar_id":"","url":"https://api.github.com/users/pierreca","html_url":"https://github.com/pierreca","followers_url":"https://api.github.com/users/pierreca/followers","following_url":"https://api.github.com/users/pierreca/following{/other_user}","gists_url":"https://api.github.com/users/pierreca/gists{/gist_id}","starred_url":"https://api.github.com/users/pierreca/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pierreca/subscriptions","organizations_url":"https://api.github.com/users/pierreca/orgs","repos_url":"https://api.github.com/users/pierreca/repos","events_url":"https://api.github.com/users/pierreca/events{/privacy}","received_events_url":"https://api.github.com/users/pierreca/received_events","type":"User","site_admin":false},"assignees":[{"login":"pierreca","id":4979572,"node_id":"MDQ6VXNlcjQ5Nzk1NzI=","avatar_url":"https://avatars2.githubusercontent.com/u/4979572?v=4","gravatar_id":"","url":"https://api.github.com/users/pierreca","html_url":"https://github.com/pierreca","followers_url":"https://api.github.com/users/pierreca/followers","following_url":"https://api.github.com/users/pierreca/following{/other_user}","gists_url":"https://api.github.com/users/pierreca/gists{/gist_id}","starred_url":"https://api.github.com/users/pierreca/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pierreca/subscriptions","organizations_url":"https://api.github.com/users/pierreca/orgs","repos_url":"https://api.github.com/users/pierreca/repos","events_url":"https://api.github.com/users/pierreca/events{/privacy}","received_events_url":"https://api.github.com/users/pierreca/received_events","type":"User","site_admin":false}],"milestone":null,"comments":1,"created_at":"2018-10-16T22:09:25Z","updated_at":"2018-10-18T01:04:03Z","closed_at":null,"author_association":"NONE","body":"\r\n- **OS and version used:** Windows 10\r\n\r\n- **Python runtime used:** 3.6\r\n\r\n- **SDK version used:** <VERSION> <!-- Please include the SDK version -->\r\n\r\n\r\n# Description of the issue:\r\n\r\nI try to send a byte array to the iot hub, which contains zeros. All bytes after and including an zero are not received in the iot hub, which I receive in a java application listing to a consumer group.\r\n\r\n# Code sample exhibiting the issue:\r\n\r\n    from iothub_client import IoTHubClient, IoTHubTransportProvider, IoTHubMessage\r\n\r\n    CONNECTION_STRING = \"...\"\r\n    PROTOCOL = IoTHubTransportProvider.HTTP\r\n\r\n\r\n    def send_confirmation_callback(message, result, user_context):\r\n        print(\"Confirmation received for message with result = %s\" % (result))\r\n\r\n\r\n    if __name__ == '__main__':\r\n        client = IoTHubClient(CONNECTION_STRING, PROTOCOL)\r\n        client.set_option(\"MinimumPollingTime\", 2)\r\n\r\n    while True:\r\n\r\n        serialized_segment = b'\\x86\\x05\\x08\\x9a\\x89\\x00\\xf7\\xe7'\r\n        message = IoTHubMessage(serialized_segment)\r\n\r\n        client.send_event_async(message, send_confirmation_callback, None)\r\n        print(\"Message transmitted to IoT Hub\")\r\n\r\n        time.sleep(10)\r\n\r\n\r\nOutput of the received data converted to a hex string:\r\n8605089a89\r\n\r\nThis behavior does not depend on the bytes I send, from an zero on nothing is received by the iot hub.\r\n\r\nSending the same bytes with the C SDK is working fine.\r\nThank you\r\n"},"comment":{"url":"https://api.github.com/repos/Azure/azure-iot-sdk-python/issues/comments/430840038","html_url":"https://github.com/Azure/azure-iot-sdk-python/issues/220#issuecomment-430840038","issue_url":"https://api.github.com/repos/Azure/azure-iot-sdk-python/issues/220","id":430840038,"node_id":"MDEyOklzc3VlQ29tbWVudDQzMDg0MDAzOA==","user":{"login":"pierreca","id":4979572,"node_id":"MDQ6VXNlcjQ5Nzk1NzI=","avatar_url":"https://avatars2.githubusercontent.com/u/4979572?v=4","gravatar_id":"","url":"https://api.github.com/users/pierreca","html_url":"https://github.com/pierreca","followers_url":"https://api.github.com/users/pierreca/followers","following_url":"https://api.github.com/users/pierreca/following{/other_user}","gists_url":"https://api.github.com/users/pierreca/gists{/gist_id}","starred_url":"https://api.github.com/users/pierreca/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pierreca/subscriptions","organizations_url":"https://api.github.com/users/pierreca/orgs","repos_url":"https://api.github.com/users/pierreca/repos","events_url":"https://api.github.com/users/pierreca/events{/privacy}","received_events_url":"https://api.github.com/users/pierreca/received_events","type":"User","site_admin":false},"created_at":"2018-10-18T01:04:03Z","updated_at":"2018-10-18T01:04:03Z","author_association":"CONTRIBUTOR","body":"@DumDumin I was able to repro and confirm my hunch, it has to do with how our boost wrapper works over the C SDK - the Python3 byte sequence is interpreted as a string and `\\x00` character is interpreted as the end of it.\r\n\r\nThe simplest fix to this is to cast to a byte array:\r\n\r\n```python\r\nserialized_segment = bytearray(b'\\x86\\x05\\x08\\x9a\\x89\\x00\\xf7\\xe7')\r\nmessage = IoTHubMessage(serialized_segment)\r\n```\r\n\r\nThis will invoke the proper constructor of `IoTHubMessage` and send all the bytes."}}
{"actor":{"display_login":"pierreca"}}