First message of a WebSocket connection re-sends the GET request on localhost MacOS

Prior investigation work:

Ruling out my server: https://github.com/websockets/ws/issues/2109 Ruling out my client: https://bugs.chromium.org/p/chromium/issues/detail?id=1421590

Reproducing the issue on my machine (unfortunately, some other machines have not been able to duplicate this):

  1. Start any websocket server on my laptop (for this repro, I just use NodeJS and the ws library, as detailed in the Chromium ticket above)
  2. Use any client (specifically validated with Google Chrome and Safari) to connect to this server over localhost then send a single message
  3. This results in the server erroring, because the initial connecting WS HTTP GET request is re-sent immediately before the actual message

When I do the same thing not over localhost, this works just fine.

I have captured the packets that Chrome sends using a Chrome tool, and at the same time, captured the packets that the server receives using tcpdump. Chrome does not show the duplicated GET request, while the server does.

It seems like it must be an OS issue, or perhaps something hooking the socket connection and messing it up. How can I debug this further? Thanks so much.

I found that this issue only happens on port 8080. I believe something is interfering with that port's normal functionality somehow. It might be Docker for Mac.

Have you been able to solve this issue somehow? Unfortunately I'm experiencing exactly the same problem.

First message of a WebSocket connection re-sends the GET request on localhost MacOS
 
 
Q