{"action":"created","issue":{"url":"https://api.github.com/repos/Azure/azure-iot-sdks/issues/874","repository_url":"https://api.github.com/repos/Azure/azure-iot-sdks","labels_url":"https://api.github.com/repos/Azure/azure-iot-sdks/issues/874/labels{/name}","comments_url":"https://api.github.com/repos/Azure/azure-iot-sdks/issues/874/comments","events_url":"https://api.github.com/repos/Azure/azure-iot-sdks/issues/874/events","html_url":"https://github.com/Azure/azure-iot-sdks/issues/874","id":183468796,"number":874,"title":"[Linux][C] IoT Hub Client AMQP Memory Leak","user":{"login":"spr-lfeliu","id":6306040,"avatar_url":"https://avatars.githubusercontent.com/u/6306040?v=3","gravatar_id":"","url":"https://api.github.com/users/spr-lfeliu","html_url":"https://github.com/spr-lfeliu","followers_url":"https://api.github.com/users/spr-lfeliu/followers","following_url":"https://api.github.com/users/spr-lfeliu/following{/other_user}","gists_url":"https://api.github.com/users/spr-lfeliu/gists{/gist_id}","starred_url":"https://api.github.com/users/spr-lfeliu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/spr-lfeliu/subscriptions","organizations_url":"https://api.github.com/users/spr-lfeliu/orgs","repos_url":"https://api.github.com/users/spr-lfeliu/repos","events_url":"https://api.github.com/users/spr-lfeliu/events{/privacy}","received_events_url":"https://api.github.com/users/spr-lfeliu/received_events","type":"User","site_admin":false},"labels":[{"id":356336017,"url":"https://api.github.com/repos/Azure/azure-iot-sdks/labels/CSS","name":"CSS","color":"e99695","default":false},{"id":369924804,"url":"https://api.github.com/repos/Azure/azure-iot-sdks/labels/investigation-required","name":"investigation-required","color":"d93f0b","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2016-10-17T16:48:30Z","updated_at":"2016-11-18T23:50:03Z","closed_at":null,"body":"We are using the IoT Hub Client (Linux C SDK) with AMQP.\n\nOn one environment, we inadvertently added an http port number to the hostname in the connection string.\n\nFor the code specified below, we observed the following:\n\n`while ((IoTHubClient_LL_GetSendStatus(iotHubClientHandle, &status) == IOTHUB_CLIENT_OK)\n            && (status == IOTHUB_CLIENT_SEND_STATUS_BUSY)) {\n          IoTHubClient_LL_DoWork(iotHubClientHandle);\n          ThreadAPI_Sleep(100);\n        }`\n\nThis caused the app to hang in this loop. The iot hub client library continued to increase its memory footprint during the course of several hours until the OOM killer was invoked.\n\nWhen removing the above loop and just invoking the following,\n\n`IoTHubClient_LL_DoWork(iotHubClientHandle);`\n\nthe app would continue to add messages to the queue and the iot hub client library continued  to increase the memory footprint during the course of several hours until OOM killer was invoked.\n\nHow to reproduce:\n- Use the iothub client library with AMQP\n- Add a non AMQP port to the hostname in the connection string (e.g. HostName=myiothub.azure-devices.net**:443**;DeviceId=mydeviceid;SharedAccessKey=mysharedaccesskey)\n\nWhile we expect the send message event to fail when the connection string is invalid, we do expect  the library to properly handle this scenario and not increase its memory usage.\n"},"comment":{"url":"https://api.github.com/repos/Azure/azure-iot-sdks/issues/comments/261672078","html_url":"https://github.com/Azure/azure-iot-sdks/issues/874#issuecomment-261672078","issue_url":"https://api.github.com/repos/Azure/azure-iot-sdks/issues/874","id":261672078,"user":{"login":"jtanner-msft","id":14320427,"avatar_url":"https://avatars.githubusercontent.com/u/14320427?v=3","gravatar_id":"","url":"https://api.github.com/users/jtanner-msft","html_url":"https://github.com/jtanner-msft","followers_url":"https://api.github.com/users/jtanner-msft/followers","following_url":"https://api.github.com/users/jtanner-msft/following{/other_user}","gists_url":"https://api.github.com/users/jtanner-msft/gists{/gist_id}","starred_url":"https://api.github.com/users/jtanner-msft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jtanner-msft/subscriptions","organizations_url":"https://api.github.com/users/jtanner-msft/orgs","repos_url":"https://api.github.com/users/jtanner-msft/repos","events_url":"https://api.github.com/users/jtanner-msft/events{/privacy}","received_events_url":"https://api.github.com/users/jtanner-msft/received_events","type":"User","site_admin":false},"created_at":"2016-11-18T23:50:03Z","updated_at":"2016-11-18T23:50:03Z","body":"Hi @spr-lfeliu ,\r\n\r\nSo after a little more investigation I agree that the current implementation had a problem in not having an easy way to expose lower level networking errors to the higher layers.\r\n\r\nThe good news is that we are now adding some retry logic to the SDK which should improve that functionality.\r\n\r\nC SDK currently uses the following to two API’s to help understand the behavior of connection underneath.\r\n\r\na.\tIoTHubClient_SetConnectionStatusCallback – Using this API you can set callback, which informs you about various states of connection failure particulary look at enum values IOTHUB_CLIENT_CONNECTION_STATUS_REASON\r\nb.\tIoTHubClient_SetRetryPolicy – This call can be used to register retry policies and timeout limit up to which SDK will attempt to retry. After the timeout limit is reached, SDK will stop retrying.\r\n\r\nThe similar two API’s are present for the LL layer as well.\r\n\r\nCurrently this is only available in the C SDK for MQTT, but look for it to be available in AMQP & HTTP eventually as well.\r\n\r\n\r\n"}}
{"actor":{"display_login":"jtanner-msft"}}