#Unable to connect to Server (Matchmaker + Multiplay Hosting dedicated server)

1 messages · Page 1 of 1 (latest)

dreamy timber
#

Hey all. I've been working on getting matchmaking + dedicated server hosting working on my game using Unity's Matchmaker and Multiplay Hosting.

My matchmaking seems to be working perfectly, both of my clients request a match, I get a ticket response back from matchmaking with a port and ID in it, and I tell the clients to connect to the server with the given port and ID.

My server starts up properly, according the server logs, and then.....

Nothing happens. My clients fail to connect after 10 seconds and retry. I have them retrying 30 times, they are never able to connect.

A few questions I have:

Do I need to set a listener on my server on the port and ID that the matchmaking ticket is returning? I assumed this would happen automatically, but then I've also tried making my own listener on the server.

Do I need to have some kind of health check logic on my end for the server to keep it alive? Or will it just stay alive as long as the clients are connected?

What else could I missing here? I thought it would be as simple as setting the port and the IP and calling "StartClient()" but maybe I'm missing something here.

Thanks in advance for your feedback! I can provide code samples if necessary

mortal prawn
#

the server listen address should be set to 0.0.0.0

The server will keep itself alive as long as there are clients connected

#

You can try connecting outside of the matchmaker but starting a test server from the cloud dashboard and trying to connect to the IP manually from the client

dreamy timber
#

I will try this tonight, thanks!

dreamy timber
#

Curious, is there a way to manually start a server in the mulplay hosting UI? When I'm not using matchmaking actively I see 0 servers in there and no button to spin one up.

#

I have a build, a build config, and a fleet set up already.

mortal prawn
#

Technically you can use the Rest API, but its really only meant to be used with the Matchmaking service. In production you would want at least 1 available server running at all times

dreamy timber
#

Oh interesting, what service/shortcut do I use to just manually create a server in the UI? All I've used so far is matchmaking + multiplay.

#

I was able to run matchmaking once and it set up my 5 severs now.

#

I'll try to connect without matchmaking.

mortal prawn
#

The short way is to just use the MM service. You should also make use the player is properly leaving so you don't have extra servers costing money while it times out

dreamy timber
#

xx.xxx.xxx.xx:9200

is the IP:Port showing in the UI for my server that is available and unallocated. I'm going to try to the following on the server-side:

` #if UNITY_SERVER
int port = 7777; // Default port
var portEnv = System.Environment.GetEnvironmentVariable("PORT");
if (!string.IsNullOrEmpty(portEnv) && int.TryParse(portEnv, out int envPort))
{
port = envPort;
}

    var utp = NetworkManager.Singleton.GetComponent<Unity.Netcode.Transports.UTP.UnityTransport>();
    utp.ConnectionData.Port = (ushort)port;
    Debug.Log($"[ServerAutoStart] UnityTransport listening on port: {utp.ConnectionData.Port}");

    if (!NetworkManager.Singleton.IsServer)
    {
        NetworkManager.Singleton.StartServer();
        Debug.Log("[ServerAutoStart] Server started automatically.");
    }

#endif `

#

Does that look okay for server side?

#

And then on client side I'll do:

var transport = NetworkManager.Singleton.GetComponent<UnityTransport>(); transport.ConnectionData.Address = xx.xxx.xxx.xx; transport.ConnectionData.Port = 9200; NetworkManager.Singleton.StartClient();

#

Oh wait, should transport.ConnectionData.port be "7777" ?

mortal prawn
#

You shouldn't have to set the transport on the server. It should get configured from the Multiplay launch params

dreamy timber
#

Oh, so I don't need to do my own UnityTransport listening from the server?

mortal prawn
#

I would also look into using the Session SDK, it makes things loads easier

dreamy timber
#

oh cool, so I can use that on the server side, and then on the client side do I just set the IP + Port for my server and then startClient() ?

mortal prawn
dreamy timber
#

Innnnteresting. Maybe I should give some context.

My game is one on one card game but most of the logic handled by the server and then it sends the stuff via UI to the player.

Games are 1 player (1 client) vs. 1 player (1 client) and I won't need backfill or anything like that (maybe reconnect logic eventually, but i don't care about that for now).

Got busy with work, but I'm free now, I'll try to use sessions to connect to my server and get back to you.

dreamy timber
#

Having issues. I'm using the same imports as the tutorials scripts but my IMultiplaySessionManager is throwing a compilation error and my ServerAuthenticationService is as well.

#

Says it's in Unity.Services.Multiplayer, but I'm already "using" that.

#

😦

mortal prawn
#

but honestly for a 1v1 card game, a dedicated unity server is overkill

dreamy timber
#

Will check this out in a little bit, thanks!!

dreamy timber
mortal prawn
#

Yea. chess has no hidden info. For a card game you would need to store the player decks and hands in Cloud Save player data to prevent that kind of cheating

dreamy timber
mortal prawn
#

yea. Window or MacOS server would technically work as well

dreamy timber
#

Hm... Now I'm at the point where I'm getting a 404 error on my server and my client is getting a "SessionException: Failed to join Multiplay session"

#

So... I guess I'm closer? lol

#

This feels way harder than it should be. haha

mortal prawn
#

Huh, the server is getting a 404 error? What is the server trying to connect to?

dreamy timber
#

I don't think it's trying to connect to anything, this is the log from engine.log:

[Multiplayer]: EntityNotFound (21404). Message: (404) HTTP/1.1 404 Not Found HttpException: (404) HTTP/1.1 404 Not Found at Unity.Services.Matchmaker.Http.ResponseHandler.HandleAsyncResponse (Unity.Services.Matchmaker.Http.HttpClientResponse response, System.Collections.Generic.Dictionary2[TKey,TValue] statusCodeToTypeMap) [0x0006c] in <b5e64cd3004a4fbebae31700245ed9ac>:0
at Unity.Services.Matchmaker.Apis.Backfill.BackfillApiClient.DeleteBackfillTicketAsync `

#

Is it possible for you to give me a list of the pieces/steps I need to have set up to make session connections with match making work?

Currently I have:

(Server Side) ServerAutoStart - Sets up the networkmanager UTP UnityTransport, calls startserver()

(Server Side) MultiplayServerConnector - Connects to multiplay, sets up multiplaysessionmanagereventcallback, sets multiplaysessionmanageroptions, startsmultplaysessionmanagerasync, on serverallocatedcallback sets playerreadinessasync to true.

(Client Side) MatchmakingTicketHandler - I'm not using this anymore, but this was to handle all matchmaking logic and was successfully getting a match making Multiplay assignment (I couldn't figure out how to connect using this multiplay assignment, so I'm trying to use sessions now).

(Client Side) Session connection code - Gets an ISession from multiplay service, but I'm not sure how to connect once I have the session. (Doesn't look like ISession objects give an IP or Port number from what I can see in the documentation)

dreamy timber
#

Welp, no luck at all using sessions tonight. Could not connect. I think I may have connected to my server with matchmaking tickets, but my server immediately crashes afterwards with the 404 error... something about trying to delete backfill tickets (which I'm not using). 😦