TCP Connections dropped after approx 5 mins of inactivity

Mike Taylor 116 Reputation points
2020-11-05T10:30:16.17+00:00

I have the idle timeout set to 20 minutes. However, tests with a Python TCP client talking to a a Python TCP server using "epoll", give me an issue when the idle time is roughly 5 minutes of inactivity. I loose the last packet sent, and get an error thrown from the client when after 10 minutes it tries to close the connection, as follows:-

Traceback (most recent call last):
File "atlas_client.py", line 121, in <module>
make_connection()
File "atlas_client.py", line 111, in make_connection
skt.shutdown(socket.SHUT_RDWR)
OSError: [Errno 107] Transport endpoint is not connected

Running this test locally on my Ubuntu VM, gives no such issue.

I am a bit of a loss as to what to try. I can (I believe) force keep-alive packets, however on a 4g connection when we are paying for each and every byte sent/received I don't really want to do this.

How can I tell whether this is an Azure firewall issue, Ubuntu VM or a problem with my code?

Azure Virtual Machines
Azure Virtual Machines
An Azure service that is used to provision Windows and Linux virtual machines.
7,991 questions
Azure Firewall
Azure Firewall
An Azure network security service that is used to protect Azure Virtual Network resources.
680 questions
Azure Virtual Network
Azure Virtual Network
An Azure networking service that is used to provision private networks and optionally to connect to on-premises datacenters.
2,505 questions
0 comments No comments
{count} votes

Accepted answer
  1. Mike Taylor 116 Reputation points
    2020-11-16T19:17:57.58+00:00

    That's ok thank you, I have asked the question via Azure portal.


9 additional answers

Sort by: Most helpful
  1. Cristian SPIRIDON 4,481 Reputation points
    2020-11-05T22:55:35.793+00:00

    I think this is because Azure firewall:
    https://learn.microsoft.com/en-us/azure/firewall/firewall-faq

    Check the paragraph for "TCP Idle Timeout".

    Hope that help

    1 person found this answer helpful.
    0 comments No comments

  2. Khurram Rahim 1,841 Reputation points
    2020-11-06T20:14:12.443+00:00
    1 person found this answer helpful.
    0 comments No comments

  3. SaiKishor-MSFT 17,236 Reputation points
    2020-11-06T07:12:25.507+00:00

    @Mike Taylor

    A standard behavior of a network firewall is to ensure TCP connections are kept alive and to promptly close them if there's no activity. Azure Firewall TCP Idle Timeout is four minutes. This setting isn't configurable. If a period of inactivity is longer than the timeout value, there's no guarantee that the TCP or HTTP session is maintained.
    A common practice is to use a TCP keep-alive. This practice keeps the connection active for a longer period. For more information, see the .NET examples. As given in the doc- https://learn.microsoft.com/en-us/azure/firewall/firewall-faq

    Hope this helps. Please let us know if you need any further assistance. Thank you!

    0 comments No comments

  4. Mike Taylor 116 Reputation points
    2020-11-06T09:27:01.707+00:00

    Just so I understand...

    So although the TCP idle timeout is set at 30 minutes (according to the IP configuration on Azure), the network firewall will close in-active sessions after 4 minutes of inactivity (where keep-alives haven't been set).

    We have GPRS devices (which we have been using for years) that have no ability to set "keep-alives", can we set this server side (on the Azure VM) to keep the session active?


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.