Open robmry opened 4 months ago
Just trying a wild shot - isn't there somewhere some stateful firewall? I knowiptables
has config with NEW
and ESTABLISHED
and those configs have some timeouts for UDP. iptables
labels UDP packets as ESTABLISHED
while they flow within some timeframe. If next UDP packet arrives after some time threshold, it is considered NEW
again. And theoretically can be blocked by some rule. I am noob at networking, so take it with some grain of salt, just an idea :)
Sorry, I should have explained above - there's a hard-coded 90s timeout in Docker Desktop's UDP-proxying code... similar to (copied from) the one I mentioned on the moby ticket.
Description
Originally reported by @daveismith in https://github.com/moby/moby/issues/47879 ... re-raising here as there doesn't seem to be an engine-only way to address the issue.
Original Description...
I'm trying to run a LWM2M server inside of docker for UDP based clients to connect to. These clients will register with the server using a CoAP message and specify a lifetime for the registration. Periodically they update this registration to maintain communication with the server.
When the server desires information from the client, it will send a CoAP request to the same UDP port as the client registered from. I'm using Eclipse Leshan for this.
When I put the server into a container, I see that there are windows after the registration/update messages where I can't query the client from the server. This doesn't happen if I run the application natively.
In digging down further, I also discovered that this doesn't happen in host networking mode, only when using port mapping via bridge (I've only tested with the default network so far). I've seen this behaviour in bridge networking mode on both docker for mac (apple silicon) and a raspberry pi. This makes me think that this is likely some sort of NAT timeout happening in the bridge network stack. Unfortunately, host mode networking isn't an option on OS X and windows from my understanding so just switching to host mode networking isn't an option.
I wrote a simple pair of python programs to demonstrate the issue, which are included below. They work by receiving a UDP datagram and then waiting for a period of time before echoing it back to the sender. This works in a docker container for delays up to 89 seconds. Once the value increases past this, no response is received or seen in wireshark. Running the app natively I've tested with delays up to 900 seconds and not seen any issues.
Reproduce
Server
Client
Dockerfile
docker build -t udp_test .
docker run -p 5005:5005/udp udp_test
UDP_IP
in the clientpython3 client.py
Expected behavior
The UDP message sent by the server should be received by the client. Ideally this would not require special configuration of the docker container, but if there is a need to adjust a default timeout, this is documented clearly and available for use in docker compose.
docker version
docker info
Diagnostics ID
n/a
Additional Info
No response