Skip to content

localhost relay (wslrelay) stalls permanently and leaks the connection when the Windows client pauses reading while still writing #42253

Open

Description

@Yamahari

Windows Version

10.0.26200.9711

WSL Version

2.7.1.0

Are you using WSL 1, WSL 2, or WSLC?

  • WSL 2
  • WSL 1
  • WSLC

Kernel Version

6.6.114.1-1

Distro Version

Ubuntu-20.04

Other Software

No response

Repro Steps

  1. In WSL, run a TCP server on 0.0.0.0:18999 that continuously sends data and drains everything it receives:
import socket, threading
def drain(c):
    while c.recv(1 << 20): pass
def serve(c):
    threading.Thread(target=drain, args=(c,), daemon=True).start()
    while True: c.send(b"x" * 65536)
s = socket.socket(); s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
s.bind(("0.0.0.0", 18999)); s.listen()
while True:
    c, _ = s.accept(); threading.Thread(target=serve, args=(c,), daemon=True).start()
  1. On Windows, connect to 127.0.0.1:18999. Read for 3 s while a second thread keeps writing 4 KB every 1 ms; stop reading for 20 s (keep writing); then try to read for 10 s; then close:
import socket, threading, time
s = socket.create_connection(("127.0.0.1", 18999)); stop = False
def w():
    while not stop:
        s.send(b"y" * 4096); time.sleep(0.001)
threading.Thread(target=w, daemon=True).start()
t = time.monotonic()
while time.monotonic() - t < 3: s.recv(1 << 20)
time.sleep(20)
s.settimeout(5); got = 0
try:
    while True: got += len(s.recv(1 << 20))
except socket.timeout: print("stalled after", got, "bytes")
stop = True; s.close()
  1. Check sockets on both sides (Windows: Get-NetTCPConnection -RemotePort 18999; WSL: ss -tn "( sport = :18999 or dport = :18999 )").

Expected Behavior

After the client resumes reading, data flows again in both directions. After the client closes, the relay closes its WSL-side connection.

Actual Behavior

  • After the pause, the client receives ~1.4 MB, then nothing (recv timeout); its writes also stall.
  • After close, the Windows socket stays in FIN_WAIT_1 and the relay's WSL-side socket stays ESTABLISHED with unread data, indefinitely (unchanged after 60 s+):
Windows: 56086 FinWait1
WSL:     ESTAB  Recv-Q 0        Send-Q 1048576  127.0.0.1:18999 -> 127.0.0.1:48562
         ESTAB  Recv-Q 1736704  Send-Q 0        127.0.0.1:48562 -> 127.0.0.1:18999
  • Without client writes during the pause (read-only client), the same test recovers fine.

In a real workload (MQTT client on Windows, broker in WSL Docker), this accumulated 192 leaked relay connections holding 573 MB of unread data and caused repeated keepalive timeouts until wsl --shutdown.

  • After this, port forwarding for that port is broken for new connections as well: wslrelay accepts the
    connection on Windows (127.0.0.1:18999, state Established, owned by wslrelay), but nothing is forwarded to
    the WSL listener (the server never sees an accept; no new socket in ss), and the client receives no data.
    Connecting to the same server from inside WSL works immediately.
  • The leaked connection was still present 13+ minutes later (Windows FIN_WAIT_1, WSL-side ESTAB with 1.7 MB Recv-Q).

Diagnostic Logs

No response

Activity

  1. github-actions commented on Nov 12, 2026

    @github-actions
    Contributor

    Logs are required for review from WSL team

    If this a feature request, please reply with '/feature'. If this is a question, reply with '/question'.
    Otherwise, please attach logs by following the instructions below, your issue will not be reviewed unless they are added. These logs will help us understand what is going on in your machine.

    How to collect WSL logs

    Download and execute collect-wsl-logs.ps1 in an administrative powershell prompt:

    Invoke-WebRequest -UseBasicParsing "https://raw.githubusercontent.com/microsoft/WSL/master/diagnostics/collect-wsl-logs.ps1" -OutFile collect-wsl-logs.ps1
    Set-ExecutionPolicy Bypass -Scope Process -Force
    .\collect-wsl-logs.ps1
    

    The script will output the path of the log file once done.

    If this is a networking issue, please use .\collect-wsl-logs.ps1 -LogProfile networking instead, following the instructions in Collect WSL logs for networking issues

    Once completed please upload the output files to this GitHub issue.

    See Collect WSL logs (recommended method).

    If you choose to email these logs instead of attaching them to the bug, please send them to wsl-gh-logs@microsoft.com with the GitHub issue number in the subject, and include a link to your GitHub issue comment in the message body, and reply with '/emailed-logs'.

  2. Yamahari commented on Nov 12, 2026

    @Yamahari
    Author

    no logs

  3. chemwolf6922 commented on Nov 13, 2026

    @chemwolf6922
    Contributor

    Hi Yamahari .
    This issue should be fixed with this PR #41458 and it's Linux part. The PR is currently in review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    wsl2Issue/feature applies to WSL 2

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions