WSL: Incomplete socket send with fast writer and slow reader

This might be related to #493 ; I’m not sure. It certainly feels very similar. Reproduced under build 14376.

Open up two WSL terminals. In the first, run the following two commands:

dd if=/dev/zero of=big.dat bs=3000000 count=1
python -m SimpleHTTPServer

Then, in the second, run the following:

curl http://localhost:8000/big.dat

Expected:

  • curl will successfully transfer the file

Actual:

  • curl emits the following error:
curl: (18) transfer closed with 509705 bytes remaining to read

The exact number of bytes remaining varies, though it’s consistently in the vicinity of 500kb for me.

About this issue

  • Original URL
  • State: closed
  • Created 10 years ago
  • Comments: 30 (20 by maintainers)

Most upvoted comments

Just an update that this issue has been fixed in the dev branch and should soon hit the release branch. With the above repro steps, I was successfully able to transfer up to 3GB of data without any issues (thought it took a long time). Many thanks @aseering for being persistent and helping us stay on track. I will also ping this thread again once the fix makes it to the release branch.

Any ideas on new build release date (+/-)?

The fix has made it to the release branch. It depends on which build they snap for the Insider release (which is not in our (WSL team’s) control). If not in the upcoming Insider release build, it should definitely be in the next one after that. I don’t have any more insight into the timelines/dates etc. Thanks for your patience.

@therealkenc - For getting maximum reliability guarantees from the TCP stack, the TCP socket should not be closed until both the ends have been fully disconnected (or without the full termination handshake complete). To prevent server side sockets in a hanging state (from misbehaving clients that do not close their ends), there is timeout built it some systems. When the user mode socket is closed, a disconnect request (or FIN in TCP terms) is issued. When the FIN is ACK’ed, the TCP socket is in FIN_WAIT_2 state. After waiting for tcp_fin_timeout(http://man7.org/linux/man-pages/man7/tcp.7.html) seconds in the FIN_WAIT_2 state, the socket is forcibly closed. In WSL, we were not completely following the TCP guidelines, thereby leading to some data loss. The Windows networking team helped us figure it out.

This is also working great for me. Thanks!

Same here! I was able to run my Flask server just fine. Thank you!

As for now (an hour of playing with stuff around after upgrade this morning), works perfectly 😉 Thank You!