question

joehot200 avatar image
joehot200 asked

I think my custom game server isn't running. How can I resolve this?

Hi,

I have uploaded a custom server, and selected a region, and an instance appears to be running.

However, I'm not able to connect to the server, getting the "500 internal server error" message when attempting to connect.

What I don't understand is why I can't see the logs or any details about the server. Looking at other PlayFab threads, there should be additional buttons:

*BELOW SCREENSHOT TAKEN FROM ANOTHER THREAD*

From the look of this screenshot, it looks like I should have buttons for log files, an info section, etc. This leads me to believe that the server isn't successfully running.

The question is; Why? How can I find out why my server is not running successfully, and how can I solve this?

My PlayFab Title ID is 1DE9

Thank you

Joe

Edit: just realised the screenshot took elsewhere was from "archived games". But my archived games tab has nothing there, despite the fact that I spun up 2 servers!

Custom Game Servers
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

joehot200 avatar image
joehot200 answered

Never mind, I hadn't set the game server exe path.

Except now the client still can't connect as it isn't getting the onConnected message from the server.

*sigh*

1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

brendan avatar image brendan commented ·

What triggers the "onConnected" message in your code?

0 Likes 0 ·
joehot200 avatar image
joehot200 answered

@Brendan Here is the code, it's mostly from the example for the client and server. The output when run is the screenshot here, and the client is trying to connect but can't seem to connect to the server.

In the archived servers tab, I cannot view the logs. It just comes up with a 404. Also, I can't terminate server instances except for using the "terminate servers" button in the active games tab - Deleting the build or unselecting regions does not solve the problem.

public NetworkManager manager;
    private void ConnectNetworkClient(string host = "localhost", int port = 7777)
    {
        //If this fails, it will automatically disconnect from the server.
        if (IsLocalNetwork)
        {
            host = this.host;
            port = this.port;
        }
        Debug.LogFormat("Network Client Created0, waiting for connection on ServerHost:{0} Port:{1}", host, port);
        //Basic Unity Networking Client, note there are other ways to do this
        //Referr to the unity documentation on Unity Networking for more info.
        manager.networkAddress = host;
        manager.networkPort = port;
        manager.StartClient();
        _network = manager.client;
        
        _network.RegisterHandler(MsgType.Connect, OnConnected);
        _network.RegisterHandler(GameServerMsgTypes.OnAuthenticated, OnAuthenticated);
        _network.RegisterHandler(GameServerMsgTypes.MsgRecieverExampleResponse, OnMsgRecieverExampleResponse);
        _network.RegisterHandler(MsgType.Error, OnClientNetworkingError);
        _network.RegisterHandler(MsgType.Disconnect, OnClientDisconnect);


        _network.RegisterHandler(GameServerMsgTypes.OnPlayStreamEventReceived, OnReceivedPlayStreamEvent);
        _network.RegisterHandler(GameServerMsgTypes.OnSendFriendsList, OnReceivedFriendList);
        _network.RegisterHandler(GameServerMsgTypes.OnTitleNewsUpdate, OnTitleNewsUpdate);


        Debug.LogFormat("Network Client Created1, waiting for connection on ServerHost:{0} Port:{1}", host, port);


        /*  I wanted to expand on the statement above,  Unity Networking has a NetworkingManager that is a 
         *  monobehaviour that you can instantiate into the scene and it also has a HUD for debugging, 
         *  Some like to use that over the direct client.  So instead of creating a NetworkingClient
         *  You could just instantiate a NetworkManager Game Object Prefab, and get a refrence to it's Client
         *  property.  This would allow you to virtually do the same code above, but on that game object.
         *  For this example, I'm taking the most simple and direct path.
         */




    }


    private void OnTitleNewsUpdate(NetworkMessage netMsg)
    {
        /*
        var message = netMsg.ReadMessage<TitleNewsItemMessage>();
        Debug.LogFormat("{0} New Title News '{1}' Message Received: {2}", message.NewsId, message.Title, message.Body);


        Header.text = message.Title;
        Message.text = message.Body;
        SmallWindow.SetActive(true);
        */
    }


    private void OnConnected()
    {
        StartText.text = "Connected, waiting for Authorization";
        Debug.Log("Network Client connected, You have 30 seconds to Authenticate or you get booted by the server.");
        _network.Send(GameServerMsgTypes.Authenticate, new AuthTicketMessage()
        {
            PlayFabId = PlayFabId,
            AuthTicket = !string.IsNullOrEmpty(GameServerAuthTicket) ? GameServerAuthTicket : SessionTicket,
            IsLocal = IsLocalNetwork
        });
        Debug.Log("Authorisation sent.");
        //ClientScene.Ready(_network.connection);
    }


    private void OnConnected(NetworkMessage netMsg)
    {
        Debug.Log("OnConnected!");
        OnConnected();
    }


9 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

brendan avatar image brendan commented ·

There are only a few ways you would not get the log file once the server instance shuts down:

1. The log file was simply not written.

2. The log file was written to the wrong location (the log file path passed in is the absolute path that should be used).

3. The log file was too large to be copied off before the server shut down (think 100s of MB or larger).

4. The server host either crashed or had to be terminated (should be rare).

If you're unable to terminate the servers normally, that sounds like the server code is getting caught in a loop where it's not terminating, so that's the first thing I'd check.

In terms of making the connection to the server, have you tried getting a Wireshark capture, to have a look at the traffic?

0 Likes 0 ·
joehot200 avatar image joehot200 brendan commented ·

But how do I "check"? I don't get any output log from the server, and it works 100% when I test the server locally. I haven't considered a wireshark capture, but is there even a point? It's pretty obvious by now that the server isn't running, we just need to find out how and why. I'm pretty lost here, sorry.

0 Likes 0 ·
brendan avatar image brendan joehot200 commented ·

Looking at the logs, what I'm seeing is that we try to start the executable twice, and then fail the instance start, as the executable isn't running. What dependencies does your exe have? Can you try running it on a vanilla Windows Server 2K12 R2 instance?

0 Likes 0 ·
Show more comments

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.