Page 1 of 2
XMLRPC Port changes after restart ?!
Posted: 16 Jun 2019, 13:05
by Nicklander
I set up cronjobs to restart the server and Maniacontrol once every day.
Most of the time it works fine but on some days something weird happens and the plugin won't load anymore.
I set a default XMLRPC port in the config but on some days, after a restart, it happens that this port changes and goes up +1 !?
Because of this weird port change, the plugin is no longer able to load (makes sense)...
I thought that it might have something to do with timeout or the port still being blocked after the server had been shut down ?!
Does the Maniaplanet server add +1 to the xmlrpc port if the default port in the config is blocked/not available/already used ?
Re: XMLRPC Port changes after restart ?!
Posted: 16 Jun 2019, 13:09
by sotn0r
Does the Maniaplanet server add +1 to the xmlrpc port if the default port in the config is blocked/not available/already used ?
yes, it does.
Re: XMLRPC Port changes after restart ?!
Posted: 16 Jun 2019, 13:45
by Nicklander
My cronjob in Debian looks like this:
# Stop TM2 Maniacontrol
1 6 * * * kill `pgrep -f ManiaControl_nickserver.php`
# Stop TM2 Server
2 6 * * * kill `pgrep -f nickserver`
# Start TM2 Server
5 6 * * * cd /path/to/nickserver; ./nickserver /game_settings=MatchSettings/tracklist.txt /dedicated_cfg=dedicated_cfg.txt
# Start TM2 Maniacontrol
7 6 * * * cd /path/to/nickserver/ManiaControl; php ManiaControl_nickserver.php >ManiaControl.log 2>&1 &
I wonder why it changes the port...
I mean all I do is shutting down the server and starting it up again...
Re: XMLRPC Port changes after restart ?!
Posted: 16 Jun 2019, 14:06
by sotn0r
Have you checked if your server is actually shut down once your cron starts it again? Your server logs should give you a hint at which times your server was shut down.
If you don't mind a non-graceful shutdown, you could add the -9 parameter to your kill command.
Re: XMLRPC Port changes after restart ?!
Posted: 16 Jun 2019, 17:13
by TMarc
TCP/IP has a session shut down time of up to 2 minutes.
If you try to reuse the same port right after closing the server application, it is still blocked, hence a new port is used.
This means that you need to add a delay in your restart script.
Or you check which port is free and dynamically create a new config file with that port from a template with your usual setings.
Re: XMLRPC Port changes after restart ?!
Posted: 16 Jun 2019, 17:20
by Nicklander
TMarc wrote: ↑16 Jun 2019, 17:13
TCP/IP has a session shut down time of up to 2 minutes.
If you try to reuse the same port right after closing the server application, it is still blocked, hence a new port is used.
This means that you need to add a delay in your restart script.
Or you check which port is free and dynamically create a new config file with that port from a template with your usual setings.
Well if that is so then I will just add more delay in my cronjobs and maybe even kill everything twice (maybe also use pkill)
Re: XMLRPC Port changes after restart ?!
Posted: 16 Jun 2019, 17:54
by TMarc
You can always check the port usage with
netstat -na
Re: XMLRPC Port changes after restart ?!
Posted: 16 Jun 2019, 19:41
by undef.de
Anyway, in my eyes the dedicated server should not use a different port as the configured one, just stop if the configured port is not available as other daemons do too.
To pick an other port just bring problems, the controller can't connect or the port forwarding doesn't work on that port... (because the behavior for the Connection and P2P-ports are the same).
Re: XMLRPC Port changes after restart ?!
Posted: 16 Jun 2019, 21:36
by TMarc
absolutely right!
Re: XMLRPC Port changes after restart ?!
Posted: 19 Jun 2019, 17:36
by Nicklander
undef.de wrote: ↑16 Jun 2019, 19:41
Anyway, in my eyes the dedicated server should not use a different port as the configured one, just stop if the configured port is not available as other daemons do too.
To pick an other port just bring problems, the controller can't connect or the port forwarding doesn't work on that port... (because the behavior for the Connection and P2P-ports are the same).
I agree... the automatic port change is useless and just causes problems in the end.
If you start the server and the configured port isn't open, it should simply show an error message and shut the server down.