Specifiy port for listen server


I’m feeling that I read this questions (and answeres for it) multiple times here in the forums and on AnswereHub but after an hour of googling I still haven’t found a working solution.
The question is actually pretty simple: Is it possible to specify a custom port for a listen server or is it damned to be listening on port 7777 or whatever is set in BaseEngine.ini?
I know that we can edit that file to change the default port, but what I have is a main menu where you can create multiple worlds and specify a port for that world, so that when you open the level it’s opened as a listen server with the specified port.
Using “?listen?port=xxxx” doesn’t work, it will still be opened on port 7777. Maybe I’m not seeing something here as it actually seems to be a pretty easy and common task to do to me.

Thanks in advance,

You can always override this port in your DefaultEngine.ini config file.

First, thanks for your answer, but it seems that this is not possible dynamically at runtime. As stated in the first sentence here, “Configuration files can be used to set values for properties that will be initialized when the project is loaded.”

I still tried to change the Port in DefaultEngine.ini manually after the project was open in the edior, but my changes only had an affect as I restarted the editor.

It should be parsing out the listen port at run-time based on the URL you give it. How are you spawning these worlds? Can you put a break point in UWorld::Listen(FURL& inURL) and watch to see where it’s pulling the port from?

I’m using the OpenLevel Blueprint with the ?listen and ?port options. Might this happen, because I’m testing it in editor as a listen server, so that when I press “Play” the listen server is started and then when I travel with the server to the next world with these options just get ignored as the instance in fact already is a listen server?

As far as I could trace the FURL back it is created in UnrealEngine.cpp line 8276 in UEngine::TickWorldTravel with “FURL(&Context.LastURL,*NextURL,(ETravelType)Context.World()->NextTravelType)”. LastURLs port is set to 1706, which in this case was the port I specified in DefaultEngine.ini, hence my suggestion above.

I think that’s likely. If you look in UnrealEngine.cpp and just search for TEXT(“Listen”) there are a number of cases where the listen option is stripped out when connecting to a local map to avoid crashing. You could place some break points there and see if that logic is getting hit and removing your listen info.

“path\UE4Editor.exe” “path\your project name.uproject” /Game/your map path/your map name -server - log -port=xxxx

like this:

“C:\UnrealEngine_4.20\Engine\Binaries\Win64\UE4Editor.exe” “C:\Project\Project.uproject” /Game/Maps/TestMap -server -log -port=9999