This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vaizki
Recipients asvetlov, vaizki, yselivanov
Date 2019-06-11.09:36:54
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
When using loop.create_datagram_endpoint(), the default for reuse_address=True, which sets the SO_REUSEADDR sockopt for the UDP socket. 

This is a dangerous and unreasonable default for UDP, because in Linux it allows multiple processes to create listening sockets for the same UDP port and the kernel will randomly give incoming packets to these processes.

I discovered this by accidentally starting two Python asyncio programs with the same UDP port and instead of getting an exception that the address is already in use, everything looked to be working except half my packets went to the wrong process.

The documentation also refers to behavior with TCP sockets:

"reuse_address tells the kernel to reuse a local socket in TIME_WAIT state, without waiting for its natural timeout to expire. If not specified will automatically be set to True on Unix."

This is true for TCP but not UDP.

Either the documentation should reflect the current (dangerous) behavior or the behavior should be changed for UDP sockets. 

Workaround is of course to create your own socket without SO_REUSEADDR and pass it to create_datagram_endpoint().
Date User Action Args
2019-06-11 09:36:54vaizkisetrecipients: + vaizki, asvetlov, yselivanov
2019-06-11 09:36:54vaizkisetmessageid: <>
2019-06-11 09:36:54vaizkilinkissue37228 messages
2019-06-11 09:36:54vaizkicreate