AWS + Photon Server + Photon PUN + Photon Realtime + Unity = Can't connect to the server
Photon sdk v: PUN 2.40 LIB 4.1.6.11
WINDOWS SERVER BASE 2019 (Virtual Machine on AWS )
Photon Server 5v.
Repro Steps:
1.- Please, download the following project of Unity
2.- Configuration of PhotonServerSettings:
3.- I followed this guide
This
this
4.- About the EC2 Machine
Ports are open
The public ip is running on the machine and in the guide I set manually the public porst on GameServer.xml.config - Nameserver.json and PhotonServer.config
Firewall windows
Photon server
5.- The error on Unity
OperationResponse 230: ReturnCode: -2 (Missing value 210 (AuthenticateRequest.Region)
). Parameters: {} Server: MasterServer Address: 18.212.xx.xxx:xxxx
UnityEngine.Debug:LogError (object)
Photon.Realtime.LoadBalancingClient:DebugReturn (ExitGames.Client.Photon.DebugLevel,string) (at Assets/Photon/PhotonRealtime/Code/LoadBalancingClient.cs:2564)
Photon.Realtime.LoadBalancingClient:OnOperationResponse (ExitGames.Client.Photon.OperationResponse) (at Assets/Photon/PhotonRealtime/Code/LoadBalancingClient.cs:2644)
ExitGames.Client.Photon.PeerBase:DeserializeMessageAndCallback (ExitGames.Client.Photon.StreamBuffer) (at D:/Dev/Work/photon-dotnet-sdk/PhotonDotNet/PeerBase.cs:872)
ExitGames.Client.Photon.EnetPeer:DispatchIncomingCommands () (at D:/Dev/Work/photon-dotnet-sdk/PhotonDotNet/EnetPeer.cs:565)
ExitGames.Client.Photon.PhotonPeer:DispatchIncomingCommands () (at D:/Dev/Work/photon-dotnet-sdk/PhotonDotNet/PhotonPeer.cs:1771)
Photon.Pun.PhotonHandler:Dispatch () (at Assets/Photon/PhotonUnityNetworking/Code/PhotonHandler.cs:222)
Photon.Pun.PhotonHandler:FixedUpdate () (at Assets/Photon/PhotonUnityNetworking/Code/PhotonHandler.cs:145)
Logs
Please help. Thanks.
Comments
-
UPDATE:
Project on One Drive is delete for segurity reasons.
0 -
hi, @RogelioVR
From error you got it is clear that you managed to connect. Do you see that server answers you?
The think is that your auth request does not contain region.
@Tobias could you help here?
best,
ilya
2 -
Hi @chvetsov
thanks for the reply:
FYI
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Photon.Realtime;
using Photon.Pun;
using UnityEngine.UI;
public class Menu : MonoBehaviourPunCallbacks
{
[Tooltip("The UI Label to inform the user that the connection is in progress")]
[SerializeField]
private Text textStatus;
[SerializeField]
private GameObject buttonEnter;
private bool isConnecting = false;
private const string GameVersion = "0.1";
private const int MaxPlayersPerRoom = 20;
// Start is called before the first frame update
void Start()
{
textStatus.enabled = false;
Debug.Log("Start Photon Network");
}
private void Awake()
{
PhotonNetwork.AutomaticallySyncScene = true;
}
public void SearchForGame()
{
textStatus.enabled = true;
buttonEnter.SetActive(false);
textStatus.text = "Searching for Server";
Debug.Log("Searching for Server");
isConnecting = true;
if (PhotonNetwork.IsConnected)
{
PhotonNetwork.JoinRandomRoom();
}
else
{
PhotonNetwork.GameVersion = GameVersion;
PhotonNetwork.ConnectUsingSettings();
}
}
public override void OnConnectedToMaster()
{
if (isConnecting)
{
PhotonNetwork.JoinRandomRoom();
textStatus.text = "Connected to Server";
Debug.Log("Connecting to Server");
}
}
public override void OnDisconnected(DisconnectCause cause)
{
textStatus.text = "Connected to Server " + cause.ToString();
Debug.Log("Disconnected from Server" + cause.ToString());
}
public override void OnJoinRandomFailed(short returnCode, string message)
{
PhotonNetwork.CreateRoom(null, new RoomOptions { MaxPlayers = MaxPlayersPerRoom });
Debug.Log(returnCode + "," + message);
}
public override void OnJoinedRoom()
{
Debug.Log("Client succesfully joined room");
PhotonNetwork.LoadLevel("Game");
}
public override void OnCustomAuthenticationFailed(string debugMessage)
{
Debug.Log(debugMessage);
}
0 -
Hi @RogelioVR,
Did you try checking "Use Name Server" in PhotonServerSettings? as far as I can see you should fail to connect in the first place as you try to connect to the MasterServer ("Use Name Server" unchecked) using NameServer port (5058).
1 -
You get a disconnect due to "Invalid Region". In your config we can see "eu" being set. It seems this does not match the Photon Server v5 configuration you run.
See Missing Photon Cloud Features In V5.0.12.24499, which should be the solution you need.
Sorry for the delays. The Easter holidays are extended by vacations for several team members.
2 -
SOLUTION!
A workaround is to double the region entries in Nameserver.json by adding a duplicate per region but with '/*' suffix as name for each region you have. So, for example, if you have "eu" region only, you need to add and identical entry by with "eu/*" as name.
In th NameServer.js in /deploy/ (in the machine server)
Thanks! Sorry for the delay! :D BUT HEY! THIS IS A COMPLETE TASK! :D
1 -
To fix this without doubling every entry in the
Nameserver.json
file, you can go toNameServer.ClientPeer.HandleAuthenticateRequest
, then you may add this code to fix it:var authReq = authenticateRequest; if (authReq.Region != null && authReq.Region.Contains("/*")) { authReq.Region = authReq.Region.Replace("/*", ""); }
This happens because of their cluster sharding functionality.
2 -
Also don't set your hostname as "Server", it's for your actual hostname which will be sent to ipv6 clients which are using nat64 to bridge a connection
1 -
Thanks for the help! :D
Another question:
I'm trying to build a HTML UNITY for itch.io. When I use the serverless, it works, but, in this context, I have this error.
HTTP Response Header "Content-Type" configured incorrectly on the server for file Build/V04-ServerAWS.wasm , should be "application/wasm". Startup time performance will suffer.
So, in the page of Photon server:
Known Issues In V5.0.12.24499
- Setting GameServer IP via PhotonControl will result in an error. You need to set the GameServer IP manually in "deploy\LoadBalancing\bin\GameServer.xml.config" and the setting name is "PublicIPAddress".
- A configuration error in PhotonServer.config's HTTPListeners' URLs makes it impossible to connect to the server via WebSocket protocol out of the box. Replace "/+" with "/*" and it should work.
My settings are:
GameServer.xml.config
But I don't understand the "fix" that Photon gives me.
Thanks
0 -
But I don't understand the "fix" that Photon gives me.
How do you mean?
This thread highlights several tasks the server team should tackle for the next beta or release. Thanks for the updates and sorry for the hassle.
1 -
Hello @Tobias Thanks for the reply:
Sorry if I didn't explain my self correctly: What I mean is that in a HTML5 Build, hosted un itch.io, I have this error:
HTTP Response Header "Content-Type" configured incorrectly on the server for file Build/V04-ServerAWS.wasm , should be "application/wasm". Startup time performance will suffer.
And in the page of Photon Server, the following informativo is not clear for me.
Known Issues In V5.0.12.24499
Setting GameServer IP via PhotonControl will result in an error. You need to set the GameServer IP manually in "deploy\LoadBalancing\bin\GameServer.xml.config" and the setting name is "PublicIPAddress".
-What do you mean with "setting name is (...)"?
A configuration error in PhotonServer.config's HTTPListeners' URLs makes it impossible to connect to the server via WebSocket protocol out of the box. Replace "/+" with "/*" and it should work.
- Where is this file "PhotonServer.config's"? AIt's a line of code I need to replace?
In resume: this thread is about how connect a Windows Unity Build to a AWS Machine... and it works. Now, with the same configuration, but with a HTML5 Unity Build deploy, and hosting the build on itch.io, I have the errors that I posted above.
Maybe we can close this post, and create another thread message with this new topic?
Thanks again :)
0 -
The itch.io hosting error seems to be related to the content type they send for what you host on their servers. This is not our domain and we can't help.
You need to set the GameServer IP manually in "deploy\LoadBalancing\bin\GameServer.xml.config" and the setting name is "PublicIPAddress".
You need to configure the value of key PublicIPAddress in GameServer.xml.config. Set it to the public IP your machine will use to listen to connections.
The file is named PhotonServer.config. You should be able to find it. In it, do the replacement as described.
this thread is about how connect a Windows Unity Build [...] but with a HTML5 Unity Build deploy, and hosting the build on itch.io, I have the errors that I posted above.
The change of topic was a bit confusing. Maybe I didn't read everything well enough.
1 -
You're welcome. Let us know if anything else pops up.
1