Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

MasterServer.UnregisterHost() seemingly does not work?

Discussion in 'Multiplayer' started by gzz100, Dec 14, 2010.

  1. gzz100

    gzz100

    Joined:
    Dec 14, 2010
    Posts:
    3
    If the server game is started up, I call the the MasterServer.UnregisterHost() to let other clients who don't join game can't see the game in list ( PollHostList() ), but the server instance generally always appears on the list of games the client can see.

    And when call UnregisterHost() ,I see the master server log appears :
    "No table name defined, during query/removal."
    "Failed to remove row for XX.XX.XX.XX:XXX because table lookup failed"

    Why?

    Unity version 3.0.0f5, Master Server version 2.0.0b1
     
  2. gzz100

    gzz100

    Joined:
    Dec 14, 2010
    Posts:
    3
    anyone knows?
     
  3. Nordic

    Nordic

    Joined:
    Oct 7, 2010
    Posts:
    7
    I'm experiencing this also, although with the Unity Master Server.

    Anybody know if this is a problem with the current Master Server or should UnregisterHost be used differently?
     
  4. invulse

    invulse

    Joined:
    Nov 29, 2010
    Posts:
    128
    This is ridiculous, the master server only has 5 functions it can do, and one of its functions does not work. Can a unity network developer please check this bug?
     
  5. Kryptos

    Kryptos

    Joined:
    Mar 30, 2011
    Posts:
    29
    Same problem here. It is really a bad thing, because players can join a game which is already running. It causes a lot of issues and does not make any sense oin my case, as the game is a racing game : joining a race while almost all players are about to reach the finish line is stupid.
     
  6. Gabriele

    Gabriele

    Joined:
    Jul 25, 2009
    Posts:
    3
    Hi, i have the same problem any news on that ?

    Thanks
     
  7. Gabriele

    Gabriele

    Joined:
    Jul 25, 2009
    Posts:
    3
    Resolved:

    Server Creation :
    MasterServer.RegisterHost(gameName, m_szServerName, "Open");

    Match Start :
    // Don't allow any more players
    Network.maxConnections = -1;
    MasterServer.RegisterHost(gameName, m_szServerName, "Closed");


    During the PollList scan
    if(element.comment == "Closed") continue;
     
    Naeim likes this.
  8. fholm

    fholm

    Joined:
    Aug 20, 2011
    Posts:
    2,052
    You would still need to limit the connections on the hosting server (for the game) because clients can connect at will just by knowing the ip/port. Just hiding them in the master server is not good enough for a production grade game.
     
  9. shiba_nivengo

    shiba_nivengo

    Joined:
    Apr 20, 2011
    Posts:
    16
    I'm running a Master Server of my own and each time a client tries to UnregisterHost(), I'm getting the following error in the Master Server log:

    Code (csharp):
    1. ERROR No table name defined, during query/removal
    2. ERROR Malformed packet from 158.42.12.230:20000, packet size 218.
    3. INFO Failed to remove row for 258.42.12.230:20000, because table lookup failed
    Any idea of why I'm getting these errors?
    Thanks
     
  10. ErwinCave

    ErwinCave

    Joined:
    Jan 10, 2012
    Posts:
    4
    I have the same error, but it appears on MasterServer.RegisterHost()..
    Anyone please?
     
  11. Timmey

    Timmey

    Joined:
    Apr 13, 2010
    Posts:
    35
    MasterServer.UnregisterHost(); does not appear to work.

    If you call Network.Disconnect(); before MasterServer.UnregisterHost(); it will seem to work but only on the local machine "the server". Remote machines will still think the game is up.
     
  12. supmagc

    supmagc

    Joined:
    Feb 25, 2010
    Posts:
    5
    Hi,

    I might have found a solution (this will probably only work when using your own MasterServer):
    Open the following file: RakNet/Sources/LightweightDatabaseServer.cpp
    Add the following at line: 686
    Code (csharp):
    1. inBitstream.IgnoreBits(8);
    In total your code should look like this:
    Code (csharp):
    1. void LightweightDatabaseServer::OnRemoveRow(Packet *packet)
    2. {
    3.     RakNet::BitStream inBitstream(packet->data, packet->length, false);
    4.     inBitstream.IgnoreBits(8);
    5.     LightweightDatabaseServer::DatabaseTable *databaseTable = DeserializeClientHeader(&inBitstream, packet, 0, true);
    6.  
    7.     // Conditional stuff ... some calls and a bit of logging
    8. }
    I'm not yet 100% sure this fixes the MasterServer.UnregisterHost() problem,
    but this way, I got rid of the error's in the logfile
     
    paskal007r likes this.
  13. josegdfv

    josegdfv

    Joined:
    Jul 20, 2012
    Posts:
    1
    Anyone knows how to solve this issue?
    i've tried this solution, but it doesn't work.

     
  14. Xemenas

    Xemenas

    Joined:
    Sep 10, 2012
    Posts:
    28
    Hey,

    I'm not too sure if I was having the same problem as you guys, but here's what was happening and here's what I did:

    I would launch a game then do somethings with-in it and whenever the server closed, the client(just a watcher in this case) would disconnect, but when it went to find a game again it could still see the old game. I had tried doing Network.Disconnect() then MasterServer.UnregisterHost() but that still hadn't worked.

    I just tried MasterServer.ClearHostList(); before generating my list and this seems to have fixed the problem. I do still unregister when my server closes as well.

    Hope this helps.
     
  15. amirabiri

    amirabiri

    Joined:
    Mar 10, 2012
    Posts:
    11
    Same thing here. I posted a bug report to Unity about this.
     
  16. yuewahchan

    yuewahchan

    Joined:
    Jul 2, 2012
    Posts:
    309
    use Network.maxConnections = 0; to limit the client to connect
     
  17. koki

    koki

    Joined:
    Nov 27, 2009
    Posts:
    43
    Same problem here. Anyone know how to fix it?
     
  18. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    836
  19. Fuzzy

    Fuzzy

    Joined:
    Feb 11, 2011
    Posts:
    266
    This did it for me. Did some tests with it:
    • start my game 3 times [1 2 on same PC, 3rd on another one to be able to create 2 servers at the same time]
    • 1st starts server
    • 2nd checks host list and joins server
    • 3rd checks host list and joins server
    • 3rd leaves server
    • 3rd creates server
    • 2nd leaves server and checks host list (2 hosts show up)
    • 2nd rejoins 1st host
    • 1st starts 'match' with 2nd and calls "MasterServer.UnregisterHost();"
    • 1st and 2nd can play together
    • 3rd refreshes host list and it shows up empty.


    I just hope this little IgnoreBits(8); line doesn't come with some other unknown bad sideffects.
    But for now it seems to work just fine when you have compiled and set up your own MasterServer.

    Anyways there should still be an official fix in my opinion.

    (Using Unity 4.2.2f1 Master Server 2.0.1f1)


    even if his post is quite old and he may never read it:
    Thanks supmagc!
     
  20. ZeraKoN

    ZeraKoN

    Joined:
    Nov 1, 2013
    Posts:
    5
    This is how I "fixed" (file "LightweightDatabaseServer.cpp", line 854, from MasterServer source code):

    if ((tableName[0]) == 0)
    {
    tableName[0] = 'M';
    tableName[1] = 'y';
    tableName[2] = 'G';
    tableName[3] = 'a';
    tableName[4] = 'm';
    tableName[5] = 'e';
    tableName[6] = 0;
    //if (query)
    // Log::error_log("No table name defined, during query/removal.\n");
    //else
    // Log::error_log("No table name defined.\n");
    //Log::error_log("Malformed packet from %s, packet size %d bits.\n", packet->systemAddress.ToString(), packet->bitSize);
    //return 0;
    }

    and added this (file "RakPeer.cpp", line 1460, from MasterServer source code)

    if(packet->data[0] == 'M')
    messageHandlerList->OnClosedConnection(packet->systemAddress, packet->guid, LCR_DISCONNECTION_NOTIFICATION);

    PS1: The "MyGame" I pass to the char[] in the code is the same string you pass as parameter on MasterServer.RegisterHost(gameTypeName,...)

    PS2: I HOPE it get fixed (come, this is bugged for OVER 3 YEARS!)... I think it just need a implementation on "Multiplayer.UnregisterHost" to be able to receive a string parameter (gameTypeName).
     
    Last edited: Nov 2, 2013
  21. paskal007r

    paskal007r

    Joined:
    Sep 6, 2013
    Posts:
    68

    year 4, they still seem to think I'm a feature, not a bug...
    ç_ç
     
  22. paskal007r

    paskal007r

    Joined:
    Sep 6, 2013
    Posts:
    68
  23. bojan3d

    bojan3d

    Joined:
    May 1, 2014
    Posts:
    1
    I made it like below and it seems to work, when I refresh the master server list, the host is not longer findable.

    First I disconnect all players from the server, expect the player with the master server (is the first element in the network connection).

    for(int i = 1; i < Network.connections.Length; i++)
    Network.CloseConnection(Network.connections, true);


    After that, I call the UnregisterHost and Disconnect method from the master server.

    MasterServer.UnregisterHost();
    Network.Disconnect();


    Hope it works for all others too. And if you find an official way, let my know.
    Best Luck.