How to Host (using a Relay-Service)


  • Admin

    Disclaimer: This post uses ngrok as its relay service, simply because I have used it in the past and it's free for personal use. If you know how to use the service of your choice you should be able to use it, as long as it supports raw tcp sockets.

    Note: This will only work on future versions of TripleA!

    Downloading and installing ngrok

    This step is simple. Go to https://ngrok.com/download and follow Steps 1 to 3. This assumes you know how to open a command prompt on your OS.

    You can now come up with a port number you'd like to use. The default port is 3300, which I will use from now on.

    In the command prompt run

    ./ngrok tcp 3300
    

    where 3300 is your port number.

    You'll get to a screen that looks like this:
    e9c19651-391d-4f53-8119-35340257a5f2-grafik.png

    We only care for the public hostname and port. In my case those are:
    Hostname: 0.tcp.ngrok.io and Port 19404 (they may change whenever restarting, so you'll have to check every time).

    Setting up your bot

    I assume you'll be using @prastle's script from here. You can find it here. We have to add modify the last part a bit:
    We replace

    -Ptriplea.server.password=%BOT_PASSWORD%
    

    with

    -Ptriplea.server.password=%BOT_PASSWORD%^
    -PcustomHost=0.tcp.ngrok.io^
    -PcustomPort=19404
    

    at the end of the file.

    Now you should be able to host.

    Note: You need to keep your ngrok window open as long as you want to host.



  • Instructions are not clear. The command prompt doesn't recognize it as batch file even though I have putted the exe to a folder which in system32.


  • Admin

    @Schulz Could you clarify a bit which step is not working for you?



  • I was looking for port forwarding without router access. I've unzipped ngrok, dragged it the file which I named ngrok then putted it in system32 folder. I tried to run but didn't work


  • Admin

    Ok, a couple of things to note here:
    AFAIK if you want to put ngrok.exe inside System32 to invoke it from everywhere you have to put it inside this folder directly, so it can be found at C:\Windows\System32\ngrok.exe, based on your screenshot it looks like you put it at C:\Windows\System32\ngrok\ngrok.exe.
    However your command prompt is in the "correct" folder, so that shouldn't really matter anyways for now.

    The screenshot you posted shows an error message that is important:
    It tells you you provided an invalid auth token, so your local ngrok client has no idea who you are, thus refuses to do anything.

    When you open the ngrok dashboard it should suggest you a authtoken command something like ./ngrok authtoken 1234abc, which you should be able to run on your machine before proceeding.

    Note that Windows uses backslashes (\) instead of forward slashes (/), so you'll have to replace that respectively.
    Also note that the auth token should be treated like a password, in your case it already expired, but you shouldn't post it in a public forum without censoring it.

    Tell me if that helps you.



  • After puttuing ngrok.exe directly into System32 folder and opening, I have commanded .\ngrok authtoken Navalland2 which worked after than I commanded .\ngrok tcp 3300 then I got this message;

    ngrocpic.png


  • Admin

    I think I wasn't clear enough:
    The auth token isn't something you choose, it is handed out to you by ngrok.
    You have to visit your dashboard at https://dashboard.ngrok.com/get-started/setup in order to see it. It should be a long random string of characters



  • It says now "Authtoken saved to configuration file C : ......

    Is it now permanently active?


  • Admin

    It should be I guess.



  • I can't still host either.


  • Admin

    What is the current problem?



  • Port checking in canyouseeme is invalid.


  • Admin

    You have to use the domain provided by ngrok, not your IP address.
    ngrok doesn't do the port forwarding for you, it relays the traffic they receive at their end to your machine



  • I have no idea what should I do.


  • Admin

    So after entering .\ngrok tcp 3300 it should show you a window similar to the one in my original post, right?



  • Correct.


  • Admin

    Did you download prastle's script and modify it like I said in the original post?



  • What to do with this text?

    @ECHO OFF
    REM
    REM This is a sample batch file for running a TripleA bot on a Windows system.
    REM
    REM THIS SCRIPT MAY NOT RUN CORRECTLY UNLESS YOU CUSTOMIZE SOME OF THE
    REM VARIABLES BELOW!  Please read each variable description carefully and
    REM modify them, if appropriate.
    REM
    REM To run this script, change to the directory in which you unpacked the
    REM headless game server archive, and type "run_bot.bat".
    REM
    
    REM ###########################################################################
    REM VARIABLES THAT YOU MAY CUSTOMIZE BEGIN HERE
    REM ###########################################################################
    
    REM
    REM The folder from which the bot will load game maps.
    REM
    REM The default value is the folder in which the TripleA game client stores
    REM maps that it downloads.  Under normal circumstances, you will not have to
    REM change this variable.  However, if you customized the settings in your
    REM TripleA client to use a different maps folder, you should change this
    REM variable to refer to the same location.
    REM
    SET MAPS_FOLDER=%USERPROFILE%\triplea\downloadedMaps
    
    REM
    REM The port on which the bot will listen for connections.  This port must be
    REM reachable from the Internet, so you may have to configure your firewall
    REM appropriately.
    REM
    REM Under normal circumstances, you will not have to change this variable.
    REM However, if you choose to run multiple bots on your system, you need to
    REM select a different available port for each bot.
    REM
    SET BOT_PORT=3300
    
    REM
    REM The name of the bot as displayed in the lobby.  Each bot must have a unique
    REM name.
    REM
    REM The default value uses a combination of your username and the local port
    REM you selected above on which the bot will run.  Under normal circumstances,
    REM you will not have to change this variable.
    REM
    SET BOT_NAME=Bot_%USERNAME%_%BOT_PORT%
    
    REM
    REM The password used to secure access to games running on your bot.  Users
    REM attempting to start a new game or connect to an existing game on your bot
    REM will be prompted for this password.  If the password is an empty string,
    REM the user will not be prompted, and any lobby user will be able to use your
    REM bot.
    REM
    REM The default value is an empty password. You should change this to a
    REM non-empty string if you do not want arbitrary users to use your bot.  For
    REM example, you may wish to run a private game for you and some friends.  In
    REM that case, set the password to a non-empty string and communicate it to
    REM your friends in some manner (e.g. via email).
    REM
    SET BOT_PASSWORD=
    
    REM
    REM The hostname of the lobby to which the bot will connect.
    REM
    REM The default value is the hostname for the TripleA community's public lobby.
    REM Under normal circumstances, you will not have to change this variable.
    REM
    SET LOBBY_HOST=lobby.triplea-game.org
    
    REM
    REM The port on which the lobby to which the bot will connect listens for
    REM connections.
    REM
    REM The default value is the port for the TripleA community's public lobby.
    REM Under normal circumstances, you will not have to change this variable.
    REM
    SET LOBBY_PORT=3304
    
    REM
    REM The email address at which you can be contacted.  Lobby moderators will
    REM communicate with you using this email address if they notice problems with
    REM your bot, or if they need to perform remote maintenance on your bot (e.g.
    REM to shut down your bot).
    REM
    REM The default value is meaningless.  IT IS STRONGLY RECOMMENDED THAT YOU
    REM CHANGE THIS VARIABLE TO A VALID EMAIL ADDRESS THAT YOU CONTROL.
    REM
    SET LOBBY_SUPPORT_EMAIL=%USERNAME%@localhost.localdomain
    
    REM
    REM The password used to secure remote maintenance of your bot.  A lobby
    REM moderator who wishes to perform remote maintenance on your bot will be
    REM required to enter this password in order to complete any maintenance
    REM action.  If the password is an empty string, a lobby moderator will be able
    REM to perform remote maintenance on your bot without your permission.
    REM
    REM The default value is an empty password. You should change this to a
    REM non-empty string if you do not want lobby moderators to interfere with the
    REM operation of your bot.  Note that a lobby moderator that cannot perform
    REM remote maintenance of your bot may choose to boot your bot from the lobby.
    REM
    SET LOBBY_SUPPORT_PASSWORD=
    
    REM ###########################################################################
    REM VARIABLES THAT YOU MAY CUSTOMIZE END HERE
    REM
    REM DO NOT MODIFY ANYTHING BELOW THIS LINE!
    REM ###########################################################################
    
    java^
     -server^
     -Xmx256M^
     -Djava.awt.headless=true^
     -jar bin\triplea-game-headless-1.9.0.0.13066-all.jar^
     -Ptriplea.game=^
     -Ptriplea.lobby.game.comments=automated_host^
     -Ptriplea.lobby.game.hostedBy=%BOT_NAME%^
     -Ptriplea.lobby.game.supportEmail=%LOBBY_SUPPORT_EMAIL%^
     -Ptriplea.lobby.game.supportPassword=%LOBBY_SUPPORT_PASSWORD%^
     -Ptriplea.lobby.host=%LOBBY_HOST%^
     -Ptriplea.lobby.port=%LOBBY_PORT%^
     -Ptriplea.map.folder="%MAPS_FOLDER%"^
     -Ptriplea.name=%BOT_NAME%^
     -Ptriplea.port=%BOT_PORT%^
     -Ptriplea.server=true^
     -Ptriplea.server.password=%BOT_PASSWORD%^
     -PcustomHost=0.tcp.ngrok.io^
     -PcustomPort=19404
    

  • Admin

    Oh, you put it in a File.
    So you open Notepad, paste the text and save it as "script.bat" or something.
    You'll have to download the headless version of TripleA which can be found here:
    https://github.com/triplea-game/triplea/releases/latest
    After that you unzip the downloaded file and place the script inside the unzipped folder, so that the bin\triplea-game-headless-1.9.0.0.13066-all.jar part inside the script (which has to be adjusted for the downloaded version in the script) points to an actual file.
    After that you have to run .\script.bat (or whatever you called the file) inside the command prompt where you have to 'cd' into the same directory you just extracted.

    This is not really related to networking but rather related how stuff on the command line works. I probably should've clarified this in the original post that this isn't a complete in-depth guide but rather a sort of extra if you know how to host a bot, but don't want to go through the hassle of setting up your router or know that your ISP doesn't allow for this



  • I've dragged all files from 2.2 headless zip (I can't open maps beyond 2.2) to deskop. I've pasted the text to notepad, saved and named as script.bat then put it in bin folder.

    Then I commanded .\script.bat in ngrok but it doesn't recognized as bat file.


Log in to reply