question

Michał Karcz avatar image
Michał Karcz asked

PlayFab with Photon Fusion - Failed to bind socket to [ip:port]

Hi, I'm trying to setup dedicated servers for multiplayer game created with Unity + Fusion.

On Client side 1. I'm logging in: PlayFabClientAPI.LoginWithCustomID(request, OnPlayFabLoginSuccess, OnLoginError);

  1. OnPlayFabLoginSuccess - I'm requesting multiplayer server: PlayFabMultiplayerAPI.RequestMultiplayerServer(requestData, OnRequestMultiplayerServer, OnRequestMultiplayerServerError);

  2. OnRequestMultiplayerServer - I'm trying to StartGame on Fusion NetworkRunner string ip = response.IPV4Address; ushort port = (?); var adress = NetAddress.CreateFromIpPort(ip, port); await _basicSpawner.StartGame(GameMode.Client, adress);

On Server side (I assume this is after Client 2. and before Client 3.) 1. I'm calling API.Start() PlayFabMultiplayerAgentAPI.Start(); PlayFabMultiplayerAgentAPI.OnServerActiveCallback += PlayfabOnServerActiveCallbackHandler;

  1. PlayfabOnServerActiveCallbackHandler - I'm trying to StartGame on Fusion NetworkRunner string ip = PlayFabMultiplayerAgentAPI.GetGameServerConnectionInfo().PublicIPv4Address; ushort port = (?); var adress = NetAddress.CreateFromIpPort(ip, port); await _basicSpawner.StartGame(Fusion.GameMode.Server, adress);

BasicSpawner.StartGame method looks like this: public async Task StartGame(GameMode mode, NetAddress? address = null) { var networkRunnerGameObject = new GameObject(); networkRunnerGameObject.name = "Network Runner";

     _runner = networkRunnerGameObject.AddComponent<NetworkRunner>();
     _runner.ProvideInput = mode != GameMode.Server;

     await _runner.StartGame(new StartGameArgs()
     {
         GameMode = mode,
         SessionName = "playfab-photon-test",
         Address = address,
         Scene = SceneManager.GetActiveScene().buildIndex,
         SceneManager = networkRunnerGameObject.AddComponent<NetworkSceneManagerDefault>()
     });
 }

Both on Server and Client I'm getting error from Fusion that it is unable to start a game: Failed to bind socket to [ip, port]

No matter what port I'm specyfing

On server side I was trying 0, 5055, 7777, 8080, all specified in PlayFabMultiplayerAgentAPI.GetGameServerConnectionInfo().GamePortsConfiguration GamePort.ServerListeningPort

Also on client side I was trying 0, 30000, 50000 and (ushort)response.Ports[0].Num

When adding build to playfab Server type - Container (Proccess is always unhealthy) Operating system - Windows Mount path - C:\Assets Start command - C:\Assets\game.exe

Unity 2022.2.21f1 For server I'm building Dedicated Server

What port should I pass for Fusion to sucessfully bind port?

Thanks

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.

1 Answer

·
Dimitris-Ilias Gkanatsios avatar image
Dimitris-Ilias Gkanatsios answered
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.

Michał Karcz avatar image Michał Karcz commented ·

I've tried this as it is in this sample with different game_port, ex: 7777, 5055, 8080 and all attempts have resulted in the same error from Fusion: Failed to bind socket to [Address Ip, Port]

     private async void PlayfabOnServerActiveCallbackHandler()
     {
         var connectionInfo = PlayFabMultiplayerAgentAPI.GetGameServerConnectionInfo();
         var portInfo = connectionInfo.GamePortsConfiguration.Where(x =&gt; x.Name == "game_port").FirstOrDefault();
    
         string ip = connectionInfo.PublicIPv4Address;
         ushort port = (ushort)portInfo.ServerListeningPort;
    
         var adress = NetAddress.CreateFromIpPort(ip, port);
    
         await _basicSpawner.StartGame(Fusion.GameMode.Server, adress);
     }
0 Likes 0 ·
Neils Shi avatar image Neils Shi Michał Karcz commented ·

I'm not an expert at Fusion. As this error is return by Fusion, you may ask the photon team for further assistance.

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.