Microsoft Azure PlayFab logo
    • Multiplayer
    • LiveOps
    • Data & Analytics
    • Add-ons
    • For Any Role

      • Engineer
      • Designer
      • Executive
      • Marketer
    • For Any Stage

      • Build
      • Improve
      • Grow
    • For Any Size

      • Solo
      • Indie
      • AAA
  • Runs on PlayFab
  • Pricing
    • Blog
    • Forums
    • Contact us
  • Sign up
  • Sign in
  • Ask a question
  • Spaces
    • PlayStream
    • Feature Requests
    • Add-on Marketplace
    • Bugs
    • API and SDK Questions
    • General Discussion
    • LiveOps
    • Topics
    • Questions
    • Articles
    • Ideas
    • Users
    • Badges
  • Home /
  • API and SDK Questions /
avatar image
Question by Abdulhai Moubarak · Sep 22, 2021 at 01:36 AM · Custom Game Serversmultiplayer

Unity Mirror Playfab Multiplayer Connecting to the Server

if the server is active and have a session ID in Playfab - the game (mirror) doesn't connect to it

if the server is in Standby and have no session ID - the game connects successfully every time to the ip and port

what can I do ?

Comment

People who like this

0 Show 4
10 |1200 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image SethDu ♦ · Sep 22, 2021 at 02:25 AM 0
Share

May I ask how do you get the IP and port when a server is in standby and no session ID? Usually there are only 2 methods to get IP and port -- via RequestMultiplayerServer API or GetMatch API.

avatar image Abdulhai Moubarak SethDu ♦ · Sep 22, 2021 at 03:00 AM 0
Share

I am using RequestMultiplayerServer

avatar image SethDu ♦ Abdulhai Moubarak · Sep 22, 2021 at 09:47 AM 0
Share

Do you mean after RequestMultiplayerServer is called, you can not connect the server instance using the IP and port from callback result?

Still, to help you solve this issue, may I know how do you get the IP and port when a server is in standby and no session ID? Is it from a previous call?

Show more comments

2 Replies

· Add your reply
  • Sort: 
avatar image
Best Answer

Answer by Abdulhai Moubarak · Sep 24, 2021 at 01:52 AM

Found the Issue

In the Mirror version I am using v32.1.4 (maybe all future versions not sure)

you should not set the network manager to listen in AgentListener.cs in the official MpsSamples

here :

https://github.com/PlayFab/MpsSamples/blob/master/UnityMirror/UnityServer/Assets/Server/Scripts/AgentListener.cs

after this small change everything works great now

private void OnServerActive()
    {
        UnityNetworkServer.Instance.StartListen();  //<----------------Remove This line
        Debug.Log("Server Started From Agent Activation");
    }

I guess that's why for me it was working when connecting to a standby server

Comment
SethDu
steve18624@gmail.com

People who like this

2 Show 2 · Share
10 |1200 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image steve18624@gmail.com · Jun 12 at 11:19 AM 0
Share

This solved my problem as well. Thanks Abdulhai! I spent many hours on this bug.

avatar image steve18624@gmail.com steve18624@gmail.com · Jun 12 at 11:35 AM 0
Share

I forgot to mention that I haven't figured out why this works yet. This should cause an error in the Mirror NetworkManager. TelepathyTransport should be listening on the wrong port. Without overriding it, it is listening on whatever port was set in the inspector before build.

The Mirror Server port is set by Agent listener as follow:

NetworkManagerCustom.Instance.Port = portInfo.Single().ServerListeningPort.


When we comment out StartListen.

    [Server]
    private void OnServerActive()
    {
        //NetworkManagerCustom.Instance.StartListen();
        Debug.Log("Server Started From Agent Activation");
    }

The Server never sets the Mirror Telepathy Port to the one provided by AgentListener/PlayFab because the following code is the only place that the port is set by NetworkManager:

#if ENABLE_PLAYFABSERVER_API
    public void StartListen()
    {
        this.GetComponent<TelepathyTransport>().port = (ushort)Port;
        NetworkServer.Listen(maxConnections);
avatar image

Answer by SethDu · Sep 23, 2021 at 05:29 AM

To be clear, an instance won’t switch back to standby state. The Lifecycle of a server instance ends when it is shutdown, while the resource will be released to the pool. The standby server you have seen is a newly created one by Docker.

You should not cache any IP and port because that information will be invalid when this instance is shutdown. You can still connect to the server build possibly because the server still in shutdown process or other states like onMaintenance and you don’t define any codes to destroy connections when entering shutdown process.

Each server instance is independent (so are the IP and port) and you cannot use an old IP and port to connect a new instance.

Comment

People who like this

0 Show 1 · Share
10 |1200 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Abdulhai Moubarak · Sep 23, 2021 at 08:59 AM 0
Share

connectingplayfab.png

@SethDu please check the Image

connectingplayfab.png (177.9 kB)

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Navigation

Spaces
  • General Discussion
  • API and SDK Questions
  • Feature Requests
  • PlayStream
  • Bugs
  • Add-on Marketplace
  • LiveOps
  • Follow this Question

    Answers Answers and Comments

    3 People are following this question.

    avatar image avatar image avatar image

    Related Questions

    From my Rest API to PlayFab API 1 Answer

    Matchmaking Flow with Multi-Session Custom Servers 1 Answer

    How do I get The team ID of a player in Unreal Blueprints after calling GetMatch? 1 Answer

    Does having PlayFab Editor Extension in Unity and enabling server API expose the developer secret key? 1 Answer

    Is it possible to do multiplayer sessions that never turn off? like Ark or Last Oasis servers? 1 Answer

    PlayFab

    • Multiplayer
    • LiveOps
    • Data & Analytics
    • Runs on PlayFab
    • Pricing

    Solutions

    • For Any Role

      • Engineer
      • Designer
      • Executive
      • Marketer
    • For Any Stage

      • Build
      • Improve
      • Grow
    • For Any Size

      • Solo
      • Indie
      • AAA

    Engineers

    • Documentation
    • Quickstarts
    • API Reference
    • SDKs
    • Usage Limits

    Resources

    • Forums
    • Contact us
    • Blog
    • Service Health
    • Terms of Service
    • Attribution

    Follow us

    • Facebook
    • Twitter
    • LinkedIn
    • YouTube
    • Sitemap
    • Contact Microsoft
    • Privacy & cookies
    • Terms of use
    • Trademarks
    • Safety & eco
    • About our ads
    • © Microsoft 2020
    • Anonymous
    • Sign in
    • Create
    • Ask a question
    • Create an article
    • Post an idea
    • Spaces
    • PlayStream
    • Feature Requests
    • Add-on Marketplace
    • Bugs
    • API and SDK Questions
    • General Discussion
    • LiveOps
    • Explore
    • Topics
    • Questions
    • Articles
    • Ideas
    • Users
    • Badges