question

bhester avatar image
bhester asked

Photon Realtime cloud on PlayFab,UE4, Photon and PlayFab

My current issue is that on Photo, when in a room, we no longer get callbacks or the ability to find other rooms (Without having extra CCUs).

So I thought I would try and use the RegisterGame funcitonality of PlayFab with to register an almost 'dummy' game server, which I can then find through the PlayFab calls. I'm not sure whether this is the best method or if there is a better way to approach this, but I'm currently having some issues with getting the 'RegisterGame' to not throw an unexpected error.

PlayFab::ServerModels::FRegisterGameRequest RegisterGameRequest;
    RegisterGameRequest.ServerHost = "SomeIP";
    RegisterGameRequest.ServerPort = "SomePort";
    RegisterGameRequest.Build = "1";
    RegisterGameRequest.pfRegion = PlayFab::ServerModels::Region::RegionEUWest;
    RegisterGameRequest.GameMode = "Standard";

    Server->RegisterGame(RegisterGameRequest,
        PlayFab::UPlayFabServerAPI::FRegisterGameDelegate::CreateUObject(this, &APlayFabServer::OnRegisterPhotonGameToPlayFab),
        PlayFab::FPlayFabErrorDelegate::CreateUObject(this, &APlayFabServer::GenericPlayFabError));

Are we required to have a build up on the PlayFab, as the build isn't actually a server build and isn't hosted anywhere (Hence my "SomeIP"/"SomePort").

My log looks like:

[2017.10.30-12.29.20:870][346]LogHttp: Warning: 00000203ED018100: request has been successfully processed. URL: https://35B9.playfabapi.com/Server/RegisterGame, HTTP code: 500, content length: 278, actual payload size: 278
[2017.10.30-12.29.20:871][346]LogHttp: Warning: 00000203ED018100 Response Header Access-Control-Allow-Credentials: true
[2017.10.30-12.29.20:871][346]LogHttp: Warning: 00000203ED018100 Response Header Access-Control-Allow-Headers: Content-Type, Content-Encoding, X-Authentication, X-Authorization, X-PlayFabSDK, X-ReportErrorAsSuccess, X-SecretKey
[2017.10.30-12.29.20:871][346]LogHttp: Warning: 00000203ED018100 Response Header Access-Control-Allow-Methods: GET, POST
[2017.10.30-12.29.20:871][346]LogHttp: Warning: 00000203ED018100 Response Header Access-Control-Allow-Origin: *
[2017.10.30-12.29.20:871][346]LogHttp: Warning: 00000203ED018100 Response Header Cache-Control: private
[2017.10.30-12.29.20:871][346]LogHttp: Warning: 00000203ED018100 Response Header Content-Type: application/json; charset=utf-8
[2017.10.30-12.29.20:871][346]LogHttp: Warning: 00000203ED018100 Response Header Date: Mon, 30 Oct 2017 12:30:12 GMT
[2017.10.30-12.29.20:871][346]LogHttp: Warning: 00000203ED018100 Response Header X-RequestId: 83fe6cfcf7514d28ad1b2bc641758d75
[2017.10.30-12.29.20:871][346]LogHttp: Warning: 00000203ED018100 Response Header Content-Length: 278
[2017.10.30-12.29.20:871][346]LogHttp: Warning: 00000203ED018100 Response Header Connection: keep-alive
[2017.10.30-12.29.20:872][346]LogPlayFabServer: Generic PlayFab Error From Server 
An unexpected error occured while processing the request.
,

We have recently setup both PlayFab and Photon as seperate parts of our game (Perform 2 different logins, which is fine). However, we wanted the ability to find rooms while already in a room using the realtime cloud methods, which isn't possible on Photon (or isn't easily done).

I found a 'RegisterGame' function in the PlayFab server API which looked like something we could call when using an External Hosted Game. My idea was, whenever we create a lobby, we RegisterGame with PlayFab, and make sure we keep pinging it to keep it open.

However, I'm having some issues with the setup as I'm not actually using a server build of the project with a hosted IP, but rather the Photon real time cloud.

I fixed up the error message of not having the GameMode setup but now get an unexepected error from:

PlayFab::ServerModels::FRegisterGameRequest RegisterGameRequest;
RegisterGameRequest.ServerHost = "SomeIP";
RegisterGameRequest.ServerPort = "SomePort";
RegisterGameRequest.Build = "1";
RegisterGameRequest.pfRegion = PlayFab::ServerModels::Region::RegionEUWest;
RegisterGameRequest.GameMode = "Standard";

Server->RegisterGame(RegisterGameRequest,
	PlayFab::UPlayFabServerAPI::FRegisterGameDelegate::CreateUObject(this, &APlayFabServer::OnRegisterPhotonGameToPlayFab),
        PlayFab::FPlayFabErrorDelegate::CreateUObject(this, &APlayFabServer::GenericPlayFabError));
1 comment
10 |1200

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

bhester avatar image bhester commented ·

So I recently changed the Host and Port values and now get a successful return with a Lobby ID:

RegisterGameRequest.ServerHost = "1.1.1.1";
RegisterGameRequest.ServerPort = "7777";

However, I'd still like to know whether this is the best approach to my problem or if I might be doing something which could end up charging me more money in the future.

0 Likes 0 ·

1 Answer

·
brendan avatar image
brendan answered

No, sorry - the external game server hosting logic (RegisterGame, etc.) is only going to work if you actually have a server you're connecting to us. To connect players for realtime exchange of packets, you need to use either a custom game server of your own, or a service like Photon.

Can you clarify what the issue is you're seeing with Photon, exactly? Do you mean that you're on their free plan, and have reached the point where you have more than 20 CCU? If so, you'll really need to upgrade to a paid plan with them, so that you can support the traffic your game is seeing.

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

bhester avatar image bhester commented ·

So we are currently using the Photon Realtime Cloud service, which from what I gather is just a way to group people into a 'room', so that we can send messages between them.

However, Photon splits these rooms into different regions, which you have to hop through to find different games in different regions. They also don't allow the ability to find/see updated matches when you are already in one of thier rooms.

This is why I wanted to store the games on the PlayFab back end (In the Active Games area) and use 'GetCurrentGames' to display all open games in all regions, regardless of whether I am in a Photon room or not.

I have not got a game to register to the PlayFab Active Games and am also able to Deregister it. I also store the Photon Room ID in the tags area, so that when the user gets the list of rooms, they can check the Region, connect to it and use the Photon Room ID to call the JoinRoom on their side.

This 'seems' to work, although I feel I am possibly using the system in a way I am not supposed to be. This is due to my rooms not actually closing, even if I don't ping them.

0 Likes 0 ·
capture.png (21.0 KiB)
brendan avatar image brendan bhester commented ·

I'm sorry, but that functionality is specifically designed for cases where you're using a custom game server to host sessions. We really can't support that use case, and I'd have to recommend against it.

0 Likes 0 ·
bhester avatar image bhester brendan commented ·

Ah ok thanks. It just seemed like it was possible after reaching this point. Do you know why my Active games will stay around forever then and not close?

The docs mention of pinging the active game -

"The response will be a simple OK message with no data. Failure to call this after two minutes will result in the server being removed from the Matchmaker registry, which could mean that its LobbyId will be reassigned to a new server."

Does that not include the game being removed from the active games, as if I call Deregister it seems to work fine.

0 Likes 0 ·
Show more comments
Show more comments

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.