I'm having trouble getting a web-socket server (via Racket's net/rfc6455 package) to work properly in Windows. Concretely, if I run the server in DrRacket or via WSL or git bash, everything works fine. However, if I run the server in cmd or in PowerShell, connections are rejected. The code is identical, and the only differentiating factor seems to be how the server is run.
I know that Racket has a separate web server package, but I need to be able to make ws: connections, and this is the only package I see in the Racket docs when I search for "web sockets". It's important that this work in Windows, since the real example involves a student-facing tool.
I've made a minimal repository to reproduce the error, based heavily on the initial example in the docs.
It's been a long time since I did network programming, so please forgive if I'm missing something obvious, here. I've confirmed the server is listening and Wireshark shows the upgrade-to-ws request, but there is no reply.
Haven't dug into it at all, but this smells like it could be a Windows firewall issue, or some other aspect of Defender preventing connections to/from racket.exe by default.
I checked my Windows machine and I do happen to have a firewall exception for racket.exe:
I don't remember if I had to add that manually/semi-manually at some point, or if that's supposed to happen as a normal part of the installer.
If this is where the issue springs from, you'd expect to see it on some machines and not others, depending on people’s security settings and policies pushed by organizational device management.
Thanks for your reply! It's a reasonable thing to wonder about. I looked into this, and "Racket application" is allowed through the firewall (at least on the Windows machine I have access to and can reproduce this issue on). The settings appear to be the same as for DrRacket (in which the server works fine). I also don't see entries in my firewall log.
To be clear, the problem seems to happen (or not) depending on where the server application is run from:
if run from cmd or PowerShell (even PowerShell from the VSCode Terminal), the issue appears (unable to connect);
if run from DrRacket, git bash, or our VSCode extension (which uses node), the issue does not appear (connecting works fine).
so the websocket server has different behavior depending on where it is launched from, even on the same system.
I'm suspecting this may be one of those subtle Windows-vs-Linux sockets issues that I don't know about. I wonder if others can reproduce the behavior?
I've been able to repro on a fresh reinstall of Windows 11. The echo server in the rfc6455 code base has the same issue.
When the server is running under DrRacket, calling netstat -aon from cmd.exe shows a listener on port 8081; when the server is running under rackete.exe, there's no listener shown on port 8081.
I haven't tried git bash yet, I'll give that a try once git is installed (I did say fresh reinstall )
I did have to add a manual firewall exception for racket.exe, DrRacket already had an entry after installation.
I also tried adding an explicit port exception for 8081, this had no effect.
I tried shutting off Windows Defender temporarily, this also had no effect.
So, no resolution unfortunately, but definitely a reproducible issue.