Forum: PogamutUT2004

Set Port, Multiple Servers

If I want to run multiple servers at once in parallel, then each server needs to have different ports. The important ports can be set with a string

"?BotServerPort=" + botPort + "?ControlServerPort=" + controlPort + "?ObservingServerPort=" + observePort"

in the setOptions method of UCCWrapperConf. Technically speaking, this is all that is needed to run multiple servers simultaneously. However, I would also like to be able to spectate in each individual server, which requires each server to use another port. However, this port can't be set from the option straing (as far as I know).

In the previous version of Pogamut I actually modified UCCWrapper to take the extra port as input (and an INI file as well), which was used in the initUCCWrapper method to modify the UCC ProcessBuilder like this:

ProcessBuilder procBuilder = new ProcessBuilder(execStr, "server", parameter, "-server", "-ini=" + this.iniFile, "-port=" + this.port);

This corresponds to a ucc command that looks something like:
"ucc server MapName?Game=GameTypeClass?Parameter1=Value1?Parameter2=Value1,Value2?Parameter3=Value1 -server -ini=INIFile.ini -port=7555"

Now, my question is: does there currently exist a way to define which port game clients can connect to the server at (and remember that I need to run multiple servers), or do I need to introduce changes like this again? Making changes to the Pogamut libraries seems to be harder with the Maven integration, so I would really rather not mess with it. I'm hoping a solution already exists.
I have added .setPlayerPort() method to UCCWrapper conf and made change to initUCCWrapper method. Also I have deployed new version of PogamutUT2004 (version 3.3.1-SNAPSHOT) to our artifactory with this change. Which version are you using? If it is 3.3.1-SNAPSHOT then just try re-building your project and the changes should appear. If not, go to your user folder, find folder .m2 and there delete artifact for PogamutUT2004 (this forces maven to re-download the latest version of this artifact).

Best,
m
I tried what you suggested, but I'm still not getting a version of the file that contains the needed method. I have the 3.3.0 SNAPSHOT, but deleting the contents of the "repository" directory in the ".m2" directory did not fix the issue. So, I even tried downloading the latest 3.3.1 "nightly build" from the Pogamut website, but even a new project based off of that did not get me a version of the file that contained the method I needed.

Am I doing something wrong?
Just change the dependency in your pom.xml file - instead of 3.3.0, put 3.3.1-SNAPSHOT to the version of pogamut libraries you are using. E.g.:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
	<modelVersion>4.0.0</modelVersion>

	<parent>
		<groupId>cz.cuni.amis.pogamut.ut2004</groupId>
		<artifactId>pogamut-ut2004-bot-pom</artifactId>
		<version>3.3.1-SNAPSHOT</version>
	</parent>

	<groupId>com.mycompany</groupId>
	<artifactId>02-UT2004NavigationBot</artifactId>
	<version>1.0-SNAPSHOT</version>
	<packaging>jar</packaging>

	<name>02-navigation-bot</name>
	<url>http://pogamut.cuni.cz/pogamut_files/latest/doc/tutorials/02-navigationBot.html</url>

	<properties>
		<bot.main.class>com.mycompany.ut2004navigationbot.NavigationBot</bot.main.class>
	</properties>

	<repositories>
		<repository>
			<id>amis-artifactory</id>
			<name>AMIS Artifactory</name>
			<url>http://diana.ms.mff.cuni.cz:8081/artifactory/repo</url>
		</repository>
	</repositories>

	<build>
		<plugins>
			<plugin>
				<groupId>org.dstovall</groupId>
				<artifactId>onejar-maven-plugin</artifactId>
				<version>1.4.4</version>
				<configuration>
					<mainClass>${bot.main.class}</mainClass>
				</configuration>
			</plugin>
		</plugins>
	</build>

</project>



I have deployed the new version of pogamut-ut2004 artifact manually so it should be now online.
By downloading the latest nightly build you have meant getting the compiled jar files and use them as a dependency? (this might have not worked, because the change was not yet in the nightly build)
Ok, I was able to pull down the update, and the setPlayerPort() exists, but I think it was implemented wrong, because I get errors when I try to use it.
I think at least part of the issue is that the option to specify a port has to be preceded by a dash, so "-port=3003" instead of "port=3003". Also, this
option is separate from the "?" delimited parameter settings.

--------------------------------------------------
(UCC) INFO 12:25:40.301 ID0 Executing Class Engine.ServerCommandlet
(UCC) INFO 12:25:40.966 ID0 Invalid URL: DM-TrainingDay?game=GameBots2004.BotDeathMatch?timelimit=5?fraglimit=0?GoalScore=0?DoUplink=False?UplinkToGamespy=False?SendStats=False?bAllowPrivateChat=False?bAllowTaunts=False?bEnableVoiceChat=False?bAllowLocalBroadcast=False?BotServerPort=3000?ControlServerPort=3001?ObservingServerPort=3002 port=3003
(UCC) INFO 12:25:40.967 ID0 Executing UObject::StaticShutdownAfterError
(UCC) INFO 12:25:40.969 ID0 UGameEngine::Init
(UCC) INFO 12:25:40.969 ID0 UServerCommandlet::Main
(UCC) INFO 12:25:40.970 ID0 Invalid URL: DM-TrainingDay?game=GameBots2004.BotDeathMatch?timelimit=5?fraglimit=0?GoalScore=0?DoUplink=False?UplinkToGamespy=False?SendStats=False?bAllowPrivateChat=False?bAllowTaunts=False?bEnableVoiceChat=False?bAllowLocalBroadcast=False?BotServerPort=3000?ControlServerPort=3001?ObservingServerPort=3002 port=3003
(UCC) INFO 12:25:40.970 ID0
(UCC) INFO 12:25:40.972 ID0
(UCC) INFO 12:25:40.972 ID0
(UCC) INFO 12:25:40.972 ID0 History: UGameEngine::Init
I forgot to put there - character. Fixed it now:

String playerPortSetting = conf.playerPort != -1 ? " -port=" + conf.playerPort : "";


There is a space and -. Should be ok now. Deployed in svn and 3.3.1-SNAPSHOT.
Hmmm, I pulled this version down and it's still not working. I can see in the error message that there is a dash (-) before the port option, but I'm still getting the same errors:

{CODE()}
(UCC) INFO 09:11:57.531 ID0 Executing Class Engine.ServerCommandlet
(UCC) INFO 09:11:58.859 ID0 Invalid URL: DM-TrainingDay?game=GameBots2004.BotDeathMatch?timelimit=5?fraglimit=0?GoalScore=0?DoUplink=False?UplinkToGamespy=False?SendStats=False?bAllowPrivateChat=False?bAllowTaunts=False?bEnableVoiceChat=False?bAllowLocalBroadcast=False?BotServerPort=3000?ControlServerPort=3001?ObservingServerPort=3002 -port=3003
(UCC) INFO 09:11:58.860 ID0 Executing UObject::StaticShutdownAfterError
(UCC) INFO 09:11:58.873 ID0 UGameEngine::Init
(UCC) INFO 09:11:58.874 ID0 UServerCommandlet::Main
(UCC) INFO 09:11:58.875 ID0 Invalid URL: DM-TrainingDay?game=GameBots2004.BotDeathMatch?timelimit=5?fraglimit=0?GoalScore=0?DoUplink=False?UplinkToGamespy=False?SendStats=False?bAllowPrivateChat=False?bAllowTaunts=False?bEnableVoiceChat=False?bAllowLocalBroadcast=False?BotServerPort=3000?ControlServerPort=3001?ObservingServerPort=3002 -port=3003
(UCC) INFO 09:11:58.875 ID0
(UCC) INFO 09:11:58.875 ID0
(UCC) INFO 09:11:58.875 ID0
(UCC) INFO 09:11:58.875 ID0 History: UGameEngine::Init
For some reason, the CODE option never works for me. There was more to my post. Here it is:

I don't think the "-port=3003" should be part of the same string as the "?" delimited options. As a sanity check, I made sure that the following command did work:
ucc server DM-TrainingDay?game=GameBots2004.BotDeathMatch?timelimit=5?fraglimit=0?GoalScore=0?DoUplink=False?UplinkToGamespy=False?SendStats=False?bAllowPrivateChat=False?bAllowTaunts=False?bEnableVoiceChat=False?bAllowLocalBroadcast=False?BotServerPort=3000?ControlServerPort=3001?ObservingServerPort=3002 -port=3003

As to how to fix this in UCCWrapper, I think the trick is in the ProcessBuilder: Instead of having:
ProcessBuilder procBuilder = new ProcessBuilder(execStr, "server", parameter);
where the "-port=3003" option is part of the parameter String, you could do
ProcessBuilder procBuilder = new ProcessBuilder(execStr, "server", parameter, "-port=3003");

It's the only thing I can think of.
Ok, I went ahead and implemented this change myself in my code (but I had to do it in a weird way since I'm doing it on top of the Maven libraries, but that's besides the point) and IT WORKS!
I don't know why separating the "-port" option out is necessary, I just know it works. Maybe a Windows thing? Still, it would be nice if the fix made it into the official Pogamut version, so that I
could just use your library instead of hacking my changes on top of your code.

Thanks for all the help!
I know it should not be a part of ? query - there is a SPACE in front of the -port, but apparently something is removing the space from the query. :-/
Oh I've got it... Fixed it, will be online in 15 minutes (separate parameters have to be treated separately in java ProcessBuilder).
Hmm, we should refactor UCCWrapper to use ProcessExecution (wrapper around Java Process I've created long time ago,
that has much nicer API, less cave-ats).

Best, Jakub