Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

If I try to join first and then host, I get an error with Failed to listen on port #148

Closed
Ughuuu opened this issue Nov 27, 2023 · 3 comments · Fixed by #161
Closed

If I try to join first and then host, I get an error with Failed to listen on port #148

Ughuuu opened this issue Nov 27, 2023 · 3 comments · Fixed by #161

Comments

@Ughuuu
Copy link

Ughuuu commented Nov 27, 2023

The use case is that I connect to Noray with both game instances.
Then, with one of them I do client connect(join) to the other instance(the other instance isn't yet started as host).
Then, with other instance I start it as a host.
I get the following error:
Failed to connect to 172.105.69.73:51200 with status 1

After the client fails to connect, I can host normally. I wonder why though. Is that port in use while the client is connecting? I am trying with the ForestBrawl demo.

@elementbound
Copy link
Contributor

If I try to join first and then host

If I understand your question correctly, that's the intended behaviour. Before you click the host button, the game host is not listening for connections, thus noone can connect.

Maybe the point of confusion is the buttons on the Noray UI? The Connect button only connects to the noray server, and registers its address, so noray can forward traffic there.

Think of it like announcing your address to the post office before moving in to your new place. They can send you letters, but you won't be there to read them. Only once you moved can you read the letters. Moving in in this example is starting the host, i.e. listening for connections.

Let me know if that clears it up, and/or if there's a specific point in the documentation that you feel didn't provide enough info on this!

@Ughuuu
Copy link
Author

Ughuuu commented Nov 27, 2023

I think the problem is that if you try to join and then start a server, the port is blocked, that's all. Might be ok or not, since it's same computer. Even though it's a bit weird that that port is blocked.

Eg. what happens:

  1. client calls join
  2. server calls host
  3. server receives port blocked

What I see should happen

  1. client calls join
  2. server calls host
  3. no port is blocked, as client would not need to listen to server port.

@elementbound
Copy link
Contributor

I see now! The issue was that when the host receives the handshake command from noray, it has no role yet. Roles are set when you press the host or the join button.

Without a role, it assumes that you're joining a game, so it tries to connect. So it creates a UDP connection, binds the registered local port, and the connection fails, since both clients are trying to connect to eachother, with neither of them listening.

Created PR with fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants