question

laurentiumarianivan avatar image
laurentiumarianivan asked

Client disconnects after connect (Multiplayer Server)

Hello

I am using this unofficial guide in order to test Unity with Mirror and PlayFab Multiplayer server hosting, before adding Mirror and hosting to my current game(which already uses a lot of PlayFab features):

https://docs.google.com/document/d/1ZgtDsgTcccyj25jSZgQPJ3_gnUCaOqQoJ9cvay2IfV4/edit

The only difference is that I left the PlayFab port to the default (8080) from the Multiplayer PlayFab page, changing it to 7777 as per document would make my build either hanging in Deplyoying status or to Unhealthy.
So the server is uploaded to PlayFab, the status is deployed, server is getting active when a player connects. The problem is, right after connecting the player gets disconnect, and I am not sure why, any kind of help would be greatly appreciated.
My PlayFab title id is: 449BD

Thanks alot!

Here is a screenshot with the Unity Console logs, in case it helps:

unity3dmultiplayer
unitylog.png (47.5 KiB)
10 |1200

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

Sarah Zhang avatar image
Sarah Zhang answered

We can’t reproduce this behavior in our test, the server example can work fine in the testing title. Sometimes, this issue would happen when the port number of the client connection is wrong. Could you please check that have you entered the right port number in the client’s Configuration? The port number should be the one in the response of RequestMultiplayerServer.

Besides, PlayFab also provides a Unity Mirror server example in the official repository, you can check it for the reference.

2 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.

laurentiumarianivan avatar image laurentiumarianivan commented ·

I use the ip from the RequestMultiplayerServer response, but the port returned is 30000. Using the ip and port returned from that request, I get a connection time out.
If I go to PlayFab web page > Multiplayer > Servers > Servers and I select my build and then go to Connect, the port is 50000 (the ip is the same).
Using the ip from the before mentioned response and the port from the PlayFab web page, I get the behaviour in my original post.
Any idea why this is happening or what I can do next?
Thanks a lot for your help!

0 Likes 0 ·
Sarah Zhang avatar image Sarah Zhang laurentiumarianivan commented ·

Thanks for the clarification. The "30000" is the correct port number. Could you please provide the server log files?

In addition, you can try to follow this documentation to test the server locally. In local debugging, you can check the server's states and output intuitively. It would be helpful for troubleshooting.

0 Likes 0 ·
emreertugrul avatar image
emreertugrul answered

Could you be falling into the same trap as i was? Mirror using kcp transport uses UDP instead of TCP, so you have to configure your build's network with UDP port. Check what your server is listening on (i'm guessing 7777), and enter that number with UDP into the builds network area. You can test this by using the local container flow (MockVmAgent). This fixed my issue and i can connect with the ip and the port returned from playfab.
https://docs.microsoft.com/en-us/gaming/playfab/features/multiplayer/servers/locally-debugging-game-servers-and-integration-with-playfab

6 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.

laurentiumarianivan avatar image laurentiumarianivan commented ·

Oh, this might be one of the causes - when I uploaded the build I left the values by default: port 8080 and TCP.
I will try to make a build with 7777 and UDP.
Thanks!

Edit: I made another build with port 7777, name game_port and UDP protocol, but it still doesn't work :(

0 Likes 0 ·
emreertugrul avatar image emreertugrul laurentiumarianivan commented ·

@laurentiumarianivan Are you initializing your server with NetworkServer.Listen? Is the port set up correcty on the kcp transport? I cant think of anything else... Are you testing on local container?

0 Likes 0 ·
laurentiumarianivan avatar image laurentiumarianivan emreertugrul commented ·

Yep, I am using NetworkServer.Listen to initialize the server.
I tried setting the port on the transports either to 7777 (as that's what I set up on the build page) or to response's port I get from the RequestMultiplayerServer - no luck, the connection times out.
Setting the port to the value on the PlayFab web page > Multiplayer > Servers > Servers > <my_build> > Connect briefly connects the client, but then it instantly disconnects.
I didn't test on the local environment, only remotely.

0 Likes 0 ·
Show more comments
Dominic Moret avatar image Dominic Moret commented ·

I was working on this for days and couldn't figure out what the problem was and by changing to UDP (with Mirror's KCP) it all worked. Can't thank you enough! :)

0 Likes 0 ·

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.