Setup photon on Amazon EC2 Servers

The whole answer can be found below.

Please note: The Photon forum is closed permanently. After many dedicated years of service we have made the decision to retire our forum and switch to read-only: we've saved the best to last! And we offer you support through these channels:

Try Our
Documentation

Please check if you can find an answer in our extensive documentation on Photon Server.

Join Us
on Discord

Meet and talk to our staff and the entire Photon-Community via Discord.

Read More on
Stack Overflow

Find more information on Stack Overflow (for Circle members only).

Write Us
an E-Mail

Feel free to send your question directly to our developers.

Setup photon on Amazon EC2 Servers

AmirRahmani
2021-11-26 13:31:14

Hi, I hope you all are doing good.

Today I launched a windows EC2 instance on amazon aws servers.

I followed the documents to get the server running but I don't know how to get the server and port address for my client game.

I really don't know how to get the server running.

Please if anyone has successfully done it on amazon EC2 servers tell me step by step how to do it.

by the way my game works fine on photons servers.

Thank you.

Comments

chvetsov
2021-11-26 16:44:55

hi, @AmirRahmani

first set local IP address, copy client on your machine and try to get it working.

'LoadBalancing (My Cloud)' menu you will find sub menu items to start/stop photon or to install it as service.

Once it is working locally set Public IP of your server and try to access your server using your laptop/desktop

best,

ilya

AmirRahmani
2021-11-26 19:04:56

Hey. thanks for your reply.

when I start as application it will start but it won't get me a public ip.

and when I click on set public ip it says: Object reference not set to an instance of an object

I don't know what to do and I am REALY CONFUSED. Please Help me.

JohnTube
2021-11-27 01:55:32

Hi @AmirRahmani,

Thank you for choosing Photon!

There is a known issue in PhotonControl in v5 RC1 that will be fixed in upcoming v5 Final (ETA: soon).

You need to configure the GameServer IP manually:

In "deploy\LoadBalancing\GameServer\bin\GameServer.xml.config"

change "PublicIPAddress" setting value to your public IP address.

restart or start server and try again.

Otherwise here are our Photon Server hosting on AWS EC2 steps.

Sorry for the inconvenience and for the confusion.

AmirRahmani
2021-11-27 10:34:48

Thanks for your reply @JohnTube

I changed the "PublicIPAddress" setting value and followed the Photon Server hosting on AWS EC2 steps.

I don't know what to and I really wish the  v5 Final comes out soon.

AmirRahmani
2021-11-29 09:51:25

Hello there again.

I think I made some progress. I was able to connect to the nameserver but there is this error about regions:

please help me. Thank you

JohnTube
2021-11-29 12:17:18

Hi @AmirRahmani,

Please follow steps here to connect to Photon Server SDK v5.

Change port to 5058 to connect to the NameServer.

AmirRahmani
2021-11-29 13:40:03

Thanks @JohnTube

I was able to make a stable connection to the server but there is this problem:

I can't create a room. These are the logs:

AmirRahmani
2021-11-30 08:40:38

Hello there again.

I couldn't get it work yet.

I guess I am going to make my own networking system or use something else.

Thanks anyway

JohnTube
2021-11-30 21:45:00

Hi @AmirRahmani,

The logs are a bit confusing and too verbose.

The important entry is "Failed to get server instance".

it means the master server cannot find a game server.

so somehow in your setup/config the game server cannot register itself with the master server.

The other PUN related logs are misleading because they are probably about local client.

Not sure how to reproduce the errors though and they are unrelated to the main problem of not being able to create a room and connect to a game server.

Also the warning is about trying to 'connect' (initiate first connection) while already connected to master server.

So, I would first solve the problem of game server - master server connection.

I would check server logs, open logs using PhotonControl shortcut and see what's wrong.

Are you hosting all server apps on the same machine?

How did you configure GameServer's PublicIPAddress? private or public address?

AmirRahmani
2021-12-01 05:14:08

Hey @JohnTube

I used photon server SDK v5 and it didn't detect my public IP so I changed the "PublicIPAddress" setting value In "deploy\LoadBalancing\GameServer\bin\GameServer.xml.config" and in the unity editor I changed the port to 5058 and I had a "connected to nameserver" message. So my game connected to the server but failed to create room.

I tried the photon server SDK v4 but still the same result. but in the v4 it detected my public IP automatically.

I guessed about "it means the master server cannot find a game server." but I don't know how to fix that.

chvetsov
2021-12-01 08:31:44

hi, @AmirRahmani

please share with us server side logs. they are in deploy/log folder.

By default GameServer looks for Master on the same machine. it uses address 127.0.0.1 to connect to master. it looks like it can not connect. But I will be able to say for sure only by checking logs.

Please attach also your PhotonServer.config file

best,

ilya

AmirRahmani
2021-12-01 10:09:07

Hello @chvetsov

Here are the logs and the PhotonServer.config file.

I tried v5 and v4 both.

log-v5.zip

Uploaded 2021-12-01T10:08:56+00:00 144020 bytes log-v4.zip

Uploaded 2021-12-01T10:08:53+00:00 13256 bytes

chvetsov
2021-12-01 13:09:06

@AmirRahmani you have sent me wrong logs. I asked from deploy/log folder. you should see there something like Game.log, Master.log and so on

best,

ilya

AmirRahmani
2021-12-01 14:37:32

@chvetsov Sorry.

Here are the logs. I hope this is the right one :)

log-v4.zip

Uploaded 2021-12-01T14:37:04+00:00 7352 bytes log-v5.zip

Uploaded 2021-12-01T14:37:05+00:00 109818 bytes

chvetsov
2021-12-02 08:54:51

hi, @AmirRahmani

It looks like you misconfigured game server. Lets' learn some things.

Look at the GSGame.log. you will see

2021-11-30 07:44:15,100 [10] WARN Photon.LoadBalancing.GameServer.MasterServerConnectionBase - s2s MS connection: connection failed:3.....45:5058., errorCode=121, msg=The semaphore timeout period has expired.. Skipped:1

this means that GS failed to establish connection to master. look at the address. it tries to connect to port 5058. First this is udp port and second this port for NameServer (according to PhotonServer.config).

Port for S2S communication is 4520. Find it in PhotonServer.config and read comment.

Please send me GameServer.xml.config. I'll check it

Last note is that your log has debug messages. It is ok for development. but may dramatically slowdown server on production.

best,

ilya

AmirRahmani
2021-12-02 12:27:49

Hey @chvetsov

Thank you so much for your help.

Problem fixed successfully.

I was able to connect to the server and create rooms.

The problem was GameServer.xml.config.

I will contact you if there was any problem again.

Thanks again.

AmirRahmani
2021-12-11 18:30:59

Hello there again.

I could manage to connect to the server but some of my players couldn't connect to the server.

The strange part is when they use VPN it will connect(if they don't use VPN the it will be connect and disconnect fast). the player who experienced this is from US and I don't think it's because of his country.

is it the photon or the Amazon. How am I able to fix this?

Thank You.

chvetsov
2021-12-13 09:48:18

hi, @AmirRahmani

I can not help you here. I at least should take a look on logs.

I would say if client does everything correctly photon should not disconnect it.

may be there is some issue with VPN service it self, if it works correctly without

best,

ilya

atik_swt
2023-02-01 06:23:36

Hi, I am using photon server host on AWS but it not working. I tried on local machine it work but when i put it on server (AWS-Windows machine) it not working. Also i put my server public IP address on GameServer.xml.config and restart but it not working. Please help me.

Back to top