robocode-dev / tank-royale

Git repository for Robocode Tank Royale
Apache License 2.0
145 stars 29 forks source link

Starting battle on LAN Websocket address #96

Closed electricSoda closed 1 month ago

electricSoda commented 5 months ago

The bug When you start a Robocode Tank Royale server from the GUI on any LAN Websocket address, boot up bots to connect to the server through the command line (e.g. java -cp ../lib/* AvoidWall.java), and then try and start up a match between these bots through the GUI, the match doesn't start.

To Reproduce

Desktop (please complete the following information):

Java info:

flemming-n-larsen commented 5 months ago

@electricSoda Thank you for reporting this as a bug and providing really good information for how to reproduce the issue you see. 😊👌

I will have a look into this issue.

flemming-n-larsen commented 5 months ago

I reproduced the problem :+1: So I will figure out how to fix that

@electricSoda When you start a local server, it will start up at localhost:, not the address(es) specified with the 'Select Server' dialog. This dialog is mainly meant for which server the GUI will connect to, which could be an external server or local server. It might even run from a Docker container or Linux shell within Windows.

That said, I believe the local IP address and localhost must be resolved equally, meaning that the GUI should be able to connect to the server. So it is still a bug, and a dialog should show up for sure.

electricSoda commented 5 months ago

Sounds good 👍

flemming-n-larsen commented 4 months ago

@electricSoda I just released 0.24.1 with fixes for this issue. I should like you to try out, if it works for you as well. ❓

Also notice, that I updated the check when entering/adding a new URL, so you don't need to do this manually via a text editor. 😉

electricSoda commented 4 months ago

Still doesn't work :(. If I select a LAN server like ws://192.168.1.28.:3000 (which is my machine's local LAN address), boot up some bots from the GUI, and some from the terminal, and then click start battle, the battle doesn't show up on the GUI...

flemming-n-larsen commented 4 months ago

@electricSoda I am sorry. I think I misunderstood you, and feel a bit embarrassed, as I did not fix at least the main issue with the GUI. My bad! And I think the GUI needs more work, so it is less confusing, and will be smarter to work with.

If I get you right, the main issue is that the GUI automatically starts up a server locally on the default (Robocode) port 7654. That is at ws://localhost:7654, where local IP addresses like e.g. 192.168.1.28 will work too, but only if you use the same port, i.e. ws://192.168.1.28:7654. The Select Server dialog only lets you select any server including your own (local server). And you can hit the Test button to check if the server is up and running. Note that this is useful, if you are trying to reach an external server outside your system, or if you have multiple servers running, e.g. started an independent server in the background on another port than 7654, e.g. 3000.

Then, when you add the server URL ws://192.168.1.28:3000 and try to start a battle nothing happens! Which is what this issue is about. This is caused by no server running on port 3000 unless you start one in the background, which is possible. Nevertheless, the GUI should alert you that no server is running on port 3000.

To fix this issue, I have some proposals I will start working on. If you have other suggestions, make sure to add those to this thread.

1) The GUI should alert the user when a selected server is not running, which is the main issue. The alert should provide the URL of the server, which is not running.

2) There should be a configuration for the server, where it is possible to set the default port so the default port can be changed from 7654 to e.g. 3000.

3) Perhaps I need to add something to the Select Server dialog to let people know that the dialog is not used for setting the possible local IP addresses and port(s) of the server, but only for choosing which server to use when starting battles.

4) I could improve the Select Server dialog so the list of servers indicates which servers are online and offline, e.g. by an icon beside the URL.

5) The Start Server (in the Server menu) should ask the user if the default port should be used, or if another port must be used. This could use the configuration from 2)

SirStone commented 2 months ago

Hi I would like to give my 2 cents here, but first I want state that this is a not-issue to me; in case someone wants to boot a server in a remote machine, the server configuration can stay as "localhost" and still be able to connect with remote bots up until the firewall and network rules are set correctly.

Said so...I think I can reproduce the same issue with a single machine and without using the official GUI. I'm not 100% sure if this is exactly the same problem, as far as I understand the reported bug states that starting the server using the lan ip, for example 192.168.xxx.yyy, instead of the "localhost" or "127.0.0.1" the match doesn't start.

I'm going to use my alternative GUI project, so maybe I can easily see more some details than @electricSoda.

  1. Start a server giving as lan adderss my local lan, that is on 192.168.178.xxx. I leave the port random.
  2. Connect a controller without issues
  3. Start 2 bots offical bots (sample bots) to be sure that the bots are not the issue
  4. start the match
  5. observe that the match doesn't start

Server output at point 5

image

Messages sent and received by the controller at point 5

controller_weboscket

Green arrow are the messages sent from Controller to Server, red arrows the messages received from the Server.


Now repeating the point 1 to 5 but reverting the server ip as 127.0.0.1

Server output at point 5

image

Messages sent and received by the controller at point 5

image


What I observe is that when using the lan address instead of localhost or 127.0.0.1 the server is able to make Controllers and bots join correctly but as soon as the game starts the server is unable to communicate correctly with them, in particular I see that the bots are not receiving the "game-started-event-for-bot" and so the bots can't respond with a "bot-ready".

It's the same issue I've reported in https://github.com/robocode-dev/tank-royale/issues/97 but in that case the problem was related to my machine, if I use "localhost", it is translated in ip V6 "::1" instead of "127.0.0.1", and the bots could join but could not receive the "game-started-event-for-bot", as in this open issue.

Are you maybe switching the messaging system from direct to broadcast? Could be here that there's a translation issue of addresses?

flemming-n-larsen commented 2 months ago

@electricSoda I have just release version 0.24.4 which now shows an error message if a remote server is being used for starting the battles. Currently, only local server battles are supported.

flemming-n-larsen commented 1 month ago

@electricSoda I have made a version 0.26.0, which supports remote servers as well as local servers. Has the issue you saw been fixed by now?

I am closing the issue now. Please re-open it, if the original issue is still present or create a new issue.