Websocket connection timeout problems over wifi (off-topic)

I have a HTTP+Websocket server running on laptop1 (on ports 8070 and 8080, rocket to serve the web app and ws-rs for the websocket server that the web app connects to) and I'm connecting to it from laptop2 (loading the webapp in Firefox and Chrome).
The browser can fetch the web app and assets just fine, but the WS connection ONLY works over my Lancom router (has ethernet only, no wifi), NOT over Linksys WRT 54G (tested both ethernet AND wifi) or TP-LINK MR3020 (wifi-only travel router), for those I always get timeout for the WS connection attempt.

Any idea why it doesn't work over those?

I really need my websockets between my android tablet to my laptop1 via wifi (using the web app in the tablet browser).

A few months ago I was using my neighbor's wifi and it was working over that (between my tablet and laptop, also between both laptops), but he had a different (large) router and I need it to work with the TP-LINK MR3020 travel router because I need a portable setup.

(After my neighbor moved away (so I wasn't using his router between my tablet and my laptop anymore, and tried the TP-LINK MR3020) I first noticed that it wasn't working there, so I tried between both laptops and there I saw that I was getting timeouts in the browser dev console..)

This is driving me mad, any idea why I'm always getting timeouts with websockets, EXCEPT over ethernet with the Lancom router (even over ethernet with the Linksys router)?

(I know it's not a Rust issue per-se but maybe it's caused by the ws-rs crate?)

And btw, I did try different ports for the websocket server (e.g. 8077) thinking that maybe the router was using that port for itself, but I'm getting the same results (WS connection timeouts) :frowning:

What else can I try?

It's not a Windows Firewall issue (laptop1 is running Windows 8.1 and I explicitly allowed this app to listen on ports on public and private networks), not a wifi issue (it was working with my neighbor's Fritzbox router), and it works over ethernet with one router but not with the other, what could be the cause?

And how are websockets so special that a router can let normal HTTP traffic through but not Websockets? Aren't they done over HTTP, too?

Is there a way to manually try to connect as a Websocket, like doing curl myhost:8070 or telnet myhost 8070 and then typing GET /? What would be the steps to do the same for Websockets to get a more detailed error?

The WebSocket protocol is simply HTTP with a connection upgrade handshake (the handshake is described in RFC 6455). In short, the client provides two additional request headers: Connection: upgrade and Upgrade: websocket, and the server responds with HTTP 101 and the same two headers to complete the handshake. These can be sent directly with telnet.

You can also use Wireshark to capture all TCP packets between your client and the host, which can help you determine whether there are issues at or below layer 4. Finally, there are also tools like traceroute which is also good for network troubleshooting.

1 Like