Photon Unity Client SDK Client to Server Connection

A little back story so hopefully I don't look too dumb!

I am fairly new to Photon and I have been struggling to get a grasp on it for about a month or two now. Originally, I was able to access the API for the SDK's I've downloaded, but for some reason I can't do that at the moment which is only making things more difficult. I just recently figured out how to set up my Photon OnPremise Server and was able to host a chat server on it. Now, I am attempting to host an actual game server using the same idea.

What I've done so far is used the shell of the App From Scratch tutorial to get a server up and running. Now, I am trying to figure out how I can connect my Unity Client to the server that I have running. Next, I am going to try to figure out how to implement my custom game logic on the server side. I've been playing around with the demos Photon includes in the Unity Client SDK, but I have had no success in connecting either the tutorial or my own Unity project to my self hosted server. Can anyone point me in the right direction of a tutorial to connect my Unity client to my self hosted server? Or maybe give a brief Noob Friendly explanation of the process to connect to the server using the Unity Client SDK? Thanks in advance!

Comments

  • JohnTube
    JohnTube ✭✭✭✭✭
    edited December 2017
    Hi @Aaron2025,

    I think we talked via emails already.

    You need to check which Photon Server instance and applications you are running.

    For the "An App From Scratch", you created a new server application that doesn't offer any features other than connection and exchanging messages.

    To use our Unity Realtime SDK you should run "LoadBalancing" instance which has two applications: Master Server and Game Server. PhotonControl tool should help here. You need to make sure also to set Game Server IP which could be done using PhotonControl as well.

    You never shared with us what you need to do with Photon Server? Maybe you could start with Photon Cloud first and get familiar with the API and basic concepts.

    Can anyone point me in the right direction of a tutorial to connect my Unity client to my self hosted server?
    Start here.

    Also are you sure you need Photon Realtime Unity SDK and not PUN?
    Read difference here.
  • Hi @JohnTube!

    I believe we have talked through emails already! And well, my main intention for a Photon server is to transition my mobile iOS game from unity UNET to an authoritative server with minimal client side logic. I am currently in the process of redoing all of my game logic to become a server sided game. I do think it would be good to start with PUN and Photon Cloud first to help get familiar with the API, but ultimately I would like to operate my own server with custom logic.

    After researching PUN vs the Photon Unity Client I found here: https://photonengine.com/en-US/sdks#onpremiseunity I believe I will need to use the Photon Unity Client SDK. On a side note, in the link I just posted, the link to the C#API does not work, which makes studying the SDK a little more difficult.

    So far I have successfully started a chat server using the App from Scratch tutorial and I successfully connected clients to the chat server which was hosted on my Amazon EC2 machine. However, I don't quite understand how the connection works? I have created a new Application that contains absolutely no code at all currently. It is the bare bones of the app from scratch tutorial and that is it, at the moment it can't even handle receiving chats. What I would like to do from this point is now is as follows:

    1. I would like to connect my Unity Client project with the Photon Unity Client SDK Assets folder to the fresh server I have hosted on my machine.
    2. I would like to then like to insert my own custom server side logic into the new application that I have hosted. The first step of which would be to create one single room that all new clients who connect to the server lobby will join.
    3. Then finally, I would like to get to the point where I can insert my own custom server side logic for management of the game and client side logic to communicate with the server..

    I have completed something like the above mentioned scenario using UNET, but I always had to make one client the "server" to kind of simulate an authoritative server. Now I would like to step up the game a little and make a truly authoritative server. Also, I attempted to set up the particle demo which is included in the Photon Unity Client SDK, however I was only able to connect to Photon Cloud using the AppID in my Photon Dashboard. When I started the LoadBalancing application on my own server and entered my own server IP address, it was unable to connect, it would hang there for a while and then send a disconnect error to my console. Also, I changed the port to connect to the server and it said that the server refused the connection. I am not sure why this is as my app from scratch tutorial chat server accepted the client connection and I have all ports open on the server itself as well as through the Amazon security group.
  • JohnTube
    JohnTube ✭✭✭✭✭
    edited December 2017
    Hi @Aaron2025,

    Let's discuss each point separately and go step by step.

    You want to port a game from UNet to Photon, I recommend you start with Photon Cloud and when you see the need for the authoritative and custom server-side code you can:

    a- switch to self-hosted and extend the "LoadBalancing" application (the same one that we run on Photon Realtime Cloud) with your own operations or other custom logic.
    b- use the new recommended way of in-game custom logic: Plugins.

    I wanted to comment on your 3 points:

    1. OK, doable.
    2. if you want "Lobby" and "Room" then you need LoadBalancing application. Making an application from scratch means reinventing the wheel. As there are no such concepts in the "low-level framework" itself.
    3. OK, doable.

    For the connection issues, I can't tell for sure what's the issue.

    Again, start with Photon Cloud to get to know Photon first.