johanhelsing / matchbox

Painless peer-to-peer WebRTC networking for rust wasm (and native!)
Apache License 2.0
864 stars 70 forks source link

Peers are not paired in next mode after one day of system uptime. #365

Open ConnorBP opened 10 months ago

ConnorBP commented 10 months ago

Very odd bug. Was tripping me out the other day and would definitely get in the way of running a server. I don't know the exact cause but when you leave the server on for a day the matchbox server stops pairing.

2023-10-31T14:50:12.487593Z  INFO Matchbox Signaling Server: 0.0.0.0:3536
2023-10-31T14:52:16.398687Z  INFO Client connected 127.0.0.1:57080: PeerId(a54f50ee-b9a4-4c1e-ab18-554804117039)
2023-10-31T14:52:22.059235Z  INFO Client connected 127.0.0.1:57081: PeerId(eaac19c4-4c3d-41eb-85d7-25ec5c755eed)
2023-10-31T14:52:22.062397Z  INFO a54f50ee-b9a4-4c1e-ab18-554804117039 -> "{\"NewPeer\":\"eaac19c4-4c3d-41eb-85d7-25ec5c755eed\"}"

as shown in the logs above the peers get connected but then on your clients it still says no one is paired with you in your lobby. The weirdest part is that when you restart the server program, it does not resolve itself. Only a full system reboot solves the issue. I imagine this must mean it has something to do with some kind of system time variable overflowing or something?

Ran into this issue mid extreme violence tutorial and it caused me to go backtrack so much to find the issue only to then reboot for a windows update and suddenly it works again. Same issue popped up today after I left my laptop to sleep overnight. I will try and look in the server code to see what might be the cause let me know if anyone else finds out. On a similar note, none of the games embedded in the tutorial work anymore maybe that's related to this.

EDIT: I should mention this issue is on both the latest release and current main branch commit fe95d914be691e3e3fe6e982c558622b9d134ff6

Also it looks like internally the server makes a pair, but then for whatever reason the clients are never notified of this pairing.

ConnorBP commented 10 months ago

Update: upon further testing it seems it might be a client side issue. I tried installing the matchbox server on a vps without rebooting and the same issue happened. I will now try and reboot and see if it starts working again. My current theories are maybe websocket port handles are not being released and the browser runs out of ports to give for web sockets, or some variable relating to time from the browser or client code is overflowing and breaking the handshake.

simbleau commented 9 months ago

@ConnorBP update? Logic issue or matchbox issue?

ConnorBP commented 9 months ago

@ConnorBP update? Logic issue or matchbox issue?

I have not been able to find the source of this yet. It pops up unexpectedly when trying to connect peers on only certain subnets or external networks. I suspect something along the network is breaking the connection and matchbox or ggrs is not handling it correctly and just gets stuck waiting for the NewPeer event.