Browse files

Fixed issues with server behind router

Tested-by: jurkan.
  • Loading branch information...
1 parent 37adb26 commit 442d214d22223dcfe7ddb9e9111753603fa0304c @Ablu committed Apr 7, 2012
Showing with 11 additions and 3 deletions.
  1. +6 −0 docs/manaserv.xml.example
  2. +2 −2 src/account-server/accounthandler.cpp
  3. +3 −1 src/game-server/accountconnection.cpp
@@ -148,6 +148,9 @@
<option name="net_chatHost" value="localhost"/>
<option name="net_chatListenToClientPort" value="9603"/>
+ <!-- needed to set when hosting behind router or in situations
+ where you cannot bind the server to the public url -->
+ <!-- <option name="net_publicChatHost" value=""/> -->
The clients use this address to connect to a game server on this machine.
@@ -156,6 +159,9 @@
<option name="net_gameHost" value="localhost"/>
<option name="net_gameListenToClientPort" value="9604"/>
+ <!-- needed to set when hosting behind router or in situations
+ where you cannot bind the server to the public url -->
+ <!-- <option name="net_publicGameHost" value=""/> -->
Update host url: E.g.: ""
@@ -881,8 +881,8 @@ void AccountHandler::handleCharacterSelectMessage(AccountClient &client,
// Give address and port for the chat server
- reply.writeString(Configuration::getValue("net_chatHost",
- "localhost"));
+ reply.writeString(Configuration::getValue("net_publicChatHost",
+ Configuration::getValue("net_chatHost", "localhost")));
// When the chatListenToClientPort is set, we use it.
// Otherwise, we use the accountListenToClientPort + 2 if the option is set.
@@ -78,7 +78,9 @@ bool AccountConnection::start(int gameServerPort)
LOG_INFO("Connection established to the account server.");
const std::string gameServerAddress =
- Configuration::getValue("net_gameHost", "localhost");
+ Configuration::getValue("net_publicGameHost",
+ Configuration::getValue("net_gameHost",
+ "localhost"));
const std::string password =
Configuration::getValue("net_password", "changeMe");

3 comments on commit 442d214


Technically sounds fine. Yet, I'm almost sure I could figure out the same situation without the need of this configuration option.
(Not that I'm against an easy setup or a clearer config ;])

What problem triggered that patch?


Ablu replied Apr 12, 2012

The problem is: the game and chat server need to assign themselves to an ip. you cannot use the public ip when you are behind a router since the machine does not know this ip (only router has it). So i can only assign localhost( but this ip will send to the client. And it will try to connect to localhost (which will fail proberbly). Your documentation you did on the forum had the same issue. @jurkan figured this out when trying to make his server accessible from outside.

Ahh, alright. That's the sending of the local ip to the client where it's causing problems.

In my tests, I wasn't sending localhost, but a 192.168.x.y one, but the problem will remain the same.

Ok, got it, and reviewed.

Please sign in to comment.