azure-sdk-for-python icon indicating copy to clipboard operation
azure-sdk-for-python copied to clipboard

Azure Table Api ignore timeout, when wrong host name is used

Open leonbrag opened this issue 6 years ago • 8 comments

  • Package Name:

azure-common==1.1.25 azure-core==1.6.0 azure-cosmos==4.0.0 azure-cosmosdb-nspkg==2.0.2 azure-cosmosdb-table==1.0.6 azure-nspkg==3.0.2

Windows 10

Python 3.7.3

Following code connect to the purposely wrong account:

table_service = TableService("WrongAccountHere", "Key", socket_timeout=3)
    try:
        
        retVal = table_service.insert_entity("IoT", blah, timeout = 3)
        print (f"inserted to Azure: {retVal}")

    except AzureException as e:
        print (e)
        return ({"Status": "error", "Error": str (e) })

Even though socket_timeout and timeout specified as 3 seconds, APIs takes a very long time to timeout (much more then 3 seconds)

Here is the error, as expected:

Client-Request-ID=793a5574-c098-11ea-af1e-705a0f42318f Retry policy did not allow for a retry: , HTTP status code=Unknown, Exception=HTTPSConnectionPool(host='wrongBlah.table.core.windows.net', port=443): Max retries exceeded with url: /IoT?timeout=3 (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x000001A66BCA6518>: Failed to establish a new connection: [Errno 11001] getaddrinfo failed')).

Why are the timeout ignored?

leonbrag avatar Jul 07 '20 21:07 leonbrag

@leonbrag thanks for reporting this, @annatisch can you take a look at this

kaerm avatar Jul 08 '20 19:07 kaerm

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @klaaslanghout.

ghost avatar Jul 22 '20 06:07 ghost

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @anfeldma-ms, @zfoster, @southpolesteve.

ghost avatar Jul 22 '20 06:07 ghost

Thanks @leonbrag - we are working on a new SDK for Tables that is in development here: https://github.com/Azure/azure-sdk-for-python/tree/master/sdk/tables/azure-data-tables

@seankane-msft - we have a test to validate the socket timeout for the Blobs SDK, can you please add an equivalent test for the new Tables SDK? https://github.com/Azure/azure-sdk-for-python/blob/master/sdk/storage/azure-storage-blob/tests/test_blob_client.py#L195

Additionally an you confirm with the API reference documentation that timeout is a correct/support query parameter for this operation.

annatisch avatar Aug 12 '20 18:08 annatisch

@leonbrag The query parameter you are looking for is actually called connection_timeout.

seankane-msft avatar Sep 02 '20 18:09 seankane-msft

@leonbrag The new SDK for Tables was released in a preview state yesterday. It is available on pip with the command

pip install azure-data-tables

Your example would look like this with the new table

table_service = TableService("WrongAccountHere", "Key", socket_timeout=3)
    try:
        response = table_service.insert_entity(entity=entity, connection_timeout=3)
        print(f"inserted to Azure: {retVal}")
    except Exception as e:
        print(e)
        return ({"Status": "error", "Error": str(e)})

seankane-msft avatar Sep 09 '20 19:09 seankane-msft

@leonbrag were you able to solve the issue?

seankane-msft avatar Oct 07 '20 20:10 seankane-msft

While I have not tested it, go ahead and close as resolved. In case it’s not working, I will reopen. Thanks

leonbrag avatar Oct 07 '20 21:10 leonbrag