Setting up a Noray Instance
Hi there.
I've been developing my multiplayer game for several months now using the tomfol.io instance provided and it's been working great. The game is ready to alpha launch feature-wise, and I wanted to move over from your instance to a custom one that I handle myself.
Although I have followed the setup instructions on the noray repository, I can't have it working properly. I managed to connect to the Noray instance and "register_host". I'm getting both an OID and PID successfully. When it comes to the register_remote call, on the other hand, it times out (error 24). Seems like no packets come from the UDP relay. I wonder if I'm doing something wrong/forgetting something, or something else entirely.
Could you provide some insight on the issue? Perhaps share your setup of the tomfol.io instance so we can replicate it?
As extra info, I've tried hosting the Noray instance using docker and also locally with pnpm. I've also changed the host to IPv4 (0.0.0.0).
Any help would be appreciated!
Hi @Learus,
Great to hear about your progress! How and where are you running noray? Is it running from Docker? Is it already running on your own server somewhere on the internet, or just locally for now?
If Docker, it might be missing the expose port flag for the remote registrar port. Try running it like this:
docker run -p 8090:8090 -p 8091:8091 -p 8809:8809 --env-file=.env -t ghcr.io/foxssake/noray:main
The extra bit is exposing port 8809. Note that this doesn't include exposing any ports for the relays, so you might need to add something like -p 49152-51200:49152-51200.
Alternatively, you could try this:
docker run --network host --env-file=.env -t ghcr.io/foxssake/noray:main
This would eliminate an extra translation layer, and thus the need for exposing ports.
If you're running from docker compose, here's an example config:
services:
noray:
image: ghcr.io/foxssake/noray:main
network_mode: host
environment:
NORAY_SOCKET_HOST: "0.0.0.0"
NORAY_HTTP_HOST: "0.0.0.0"
NORAY_UDP_RELAY_PORTS: "3072-3200"
NORAY_LOGLEVEL: trace
The important part is network_mode - exposing a large range of ports is slow with docker, so the network mode is configured to not introduce an extra translation layer - i.e. port 8809 on the host machine will correspond to port 8809 on the container, same for every single port.
Slightly off topic, but would you be interested in showcasing your game? Feel free to drop some details about it and I'd be happy to feature it! :slightly_smiling_face:
Hey, thanks for the quick reply!
I've tried both hosting it with docker (both locally and in a server), and locally with pnpm start. I had already assumed I had to expose port 8809 so I had already tried that. I hadn't tried exposing the relay ports as well though.
Sadly, none of the solutions that you propose are working 😞. "network_mode: host" does not seem to be working at all weirdly enough, as in the service doesn't even respond to the "register-host" command anymore. As an extra note, exposing 130 ports is indeed slow when docker starts. I wonder if it hinders general performance as well.
Any ideas?
Regarding the showcasing of the game, sure! Just need to make sure that it's stable and working before I publish the alpha. When that's done, I'll be glad to send a message and move it forward.
Gotcha, in that case let's debug with running through pnpm on localhost - I'm wondering where does the connectivity break. Try running noray with NORAY_LOGLEVEL=trace and then connect to it. If you get a Received UDP relay request, then the UDP packets arrive to noray, but it fails to relay for whatever reason.
If it doesn't arrive, then it's either a config issue ( noray is listening on a different address/port where the game is sending the packets ), or some mysterious network issue.
Also, do you get the same issue with Forest Brawl? Alternatively, how's your game using the noray addon?
Looking forward to showcasing your game! :slightly_smiling_face:
Ok, good news! Turns out that my local docker had issues with "network_mode: host", since I'm using Docker Desktop with WSL. If I try it on the external server, on the other hand, it works properly. So, I guess it was a config issue. I'll keep troubleshooting on my local computer just to figure it out for everybody else having the same issue as me.
Another possible bug I noticed now that I got it working:
- Run the game via the Godot Editor
- Connect to noray (I do it automatically for now)
- Shut the game down using the Stop button in the editor
- Noray server crashes with ECONNRESET.
If I shut down the game normally (by get_tree().quit(), or by pressing the X button on the main window) everything is fine. For now, it's not a big issue for dev, because I could just "restart: always" the dev noray server. Nevertheless, it could cause problems in the future. LMK if I should post this as a different issue.
Thanks for your insight!
Thanks! Could you please file an issue under noray for the crash?
In the meanwhile, I'll keep this issue open for a while, so you can share any further findings.
Hi, I'm using a similar setup (WSL + Docker) and running into the same issue when trying to connect via localhost. Were you able to figure out any solution besides moving to an external server? Thanks!
Hi @MattStory,
So to confirm, you're running noray locally from Docker, you're able connect to it from your game, get an OID/PID pair, but the game fails at registering the remote address?
Some ideas for troubleshooting:
- Is traffic getting through to the remote registrar? This is by default on port 8809
- If that's working, you should see "Received UDP relay request" debug log messages
-
Note that you might need to run noray with
NORAY_LOG_LEVEL=debugto see these logs - If traffic doesn't get through, check if the remote registrar port is exposed from the container
- Are the remote address registrations failing?
- Check the value of the
noray_remote_registrar_failmetric at http://localhost:8891/metrics - If something somehow fails even more catastrophically, you should see some error messages in the logs
- Check the value of the
- Is the relay failing?
- If relays get lost for whatever reason, noray will drop their traffic
- Check the value of the
noray_relay_drop_countmetric at http://localhost:8891/metrics
Hope I'm not adding to this unnecessarily, but since I've also struggled to set up a docker instance I noticed some issues in the documentation of the docker instance:
The udp port is never mentioned in the docs and not exposed as an udp port with 8809/udp. Additionally, the docker command shown and the ports set up in the .env.example are vastly different. The udp port range is never exposed at all and shouldn't work as far as I'm aware unless also specifically exposed (which can make creating the instance take a lot longer, like ~142 seconds all of a sudden). I would also suggest setting the TCP connection port and UDP registar port to the same port to save up and avoid any confusion as there is no reason not to use the same port with different protocols.
Closing issue as there hasn't been much discussion in a while. The linked PR has been merged to update the noray README.