Photon c++ sdk not connecting to server with unreal engine

As per the documentation provided here https://doc-api.exitgames.com/en/cpp/current/a05882.html I have instantiated a photon peer and called the connect function with my appid. The documentation says that onStatusChanged function should be called, but it is never getting called. There are no compile/runtime errors. I am struck here and have no idea how to proceed. Does anyone know how to resolve this issue. I will try to provide further information on this if required.

Best Answer

  • Kaiserludi
    Kaiserludi admin
    edited March 17 Answer ✓

    Hi @Rox.


    but getting status code as EXCEPTION_ON_CONNECT

    That usually indicates a firewall or router issue.

    Please make sure that your firewall and router are allowing outgoing traffic on the ports that Photon is using:

    https://doc.photonengine.com/en-us/realtime/current/connection-and-authentication/tcp-and-udp-port-numbers

    You only need to allow the ports for the connection protocols that you are actually using.

    On default LoadBalancing-cpp uses UDP on ports 5055, 5056 and 5058. If you pass 'true' for 'tryUseDatagramEncryption', in the ConnectOptions, then TCP on port 19093 is also used.

    If you pass 'true' for 'useAlternativePorts' to the constructor of class Client, then ports 27000-27002 are used for UDP instead of ports 5055, 5056 and 5058.

    If you set the connection protocol to TCP, WS or WSS, then the according 3 ports from the aforementioned link for these protocols are used.


    Are you saying that in order to connect to photon cloud we cannot use photonpeer even for testing purposes?

    Let me elaborate on this with some background info.

    Photon Server consists of multiple layers:

    • The Photon Core, which provides basic low level networking functionality. It's essentially a socket-server.
    • The application layer, which sits on top of the the Core a provides more high-level functionality via so-called server-side applications

    When self-hosting, you can aside from using one of the existing applications, write your own server-side application either from scratch or based on an existing application.

    The default application for a self-hosted server is the LoadBalancing application.

    Photon Cloud runs multiple applications and selects the correct one for a client, depending on the product type of the appID that the client provides.

    When the client provides a Realtime appID or a Voice appID, then it will be connected to the LoadBalancing app.

    When the client provides a Chat appID, then it will be connected to the Chat app.

    On the client side you need to use the matching client API for the chosen product type as well, either LoadBalancing-cpp or Chat-cpp or PhotonVoice-cpp. Otherwise the client won't behave the server expects it to.


    Photon-cpp is the client-side equivalent to the Photon Core level on the server side:

    It provides the low-level networking functionality that is used by the aforementioned APIs to implement their higher level functionality.


    That means that in theory you could connect to Photon Cloud with a raw PhotonPeer, but for this to work you would need to implement the high-level connection flow of LoadBalancing-cpp from scratch yourself, basically writing your own LoadBalancing-cpp implementation, which in practice does not make sense.


    Hence the only case in which you might wanna use Photon-cpp directly from your code without any of the higher-level APIs in between, is when you want to connect to a self-hosted Photon server on which you are running a custom application, that is not compatible with the provided higher level client APIs, and even in that scenario you might be better of with adding custom modifications to LoadBalancing-cpp and operating on that customized LoadBalancing-cpp derivative rather than with operating directly on Photon-cpp.


    If no can we use litepeer instead of photonpeer?

    LitePeer is the client API for the server side Lite application, which is not available on Photon Cloud nor on Photon Server v4 and higher, but only on Photon Server v3 and lower. LitePeer is not compatible to Photon Cloud at all.


    And also can u list some unreal engine games which use photon sdk?

    We don't track which Photon user uses which game engine. So we only know, which game engine is used for a certain project, when the developer provides us with this information in a support ticket, in which case it is confidential and not publicly shared by us.

    That said, most customers that use Unity, use one of our Unity-specific products PUN, Photon Bolt, Photon Fusion and Photon Quantum.

    So, naturally, a big share of the games that are listed for Photon Realtime at https://www.photonengine.com/en-US/Realtime/Showcase uses our C++ Client SDK, either with Unreal or with a bespoken in-house engine.

Answers

  • Hi @Rox.


    You need to regularly (multiple times per second) call service(). Otherwise nothing will happen.

    This is outlined right at https://doc-api.exitgames.com/en/cpp/current/a05875.html.



    Do you write your own server side application for a self-hosted Photon server from scratch?

    If that is not the case, but you rather want to connect to Photon Cloud or to a self-hosted server that runs the default application, then you should not work directly with a PhotonPeer, but rather rather use the LoadBalancing-cpp (for photon Realtime / self hosted), Chat-cpp (for text chat) or PhotonVoice-cpp (for voice chat) APIs.

  • Rox
    Rox
    edited March 17

    Thanks for the answer It is working but getting status code as EXCEPTION_ON_CONNECT, currently I want to connect to photon cloud. Are you saying that in order to connect to photon cloud we cannot use photonpeer even for testing purposes?, If no can we use litepeer instead of photonpeer? And also can u list some unreal engine games which use photon sdk?

  • Kaiserludi
    Kaiserludi admin
    edited March 17 Answer ✓

    Hi @Rox.


    but getting status code as EXCEPTION_ON_CONNECT

    That usually indicates a firewall or router issue.

    Please make sure that your firewall and router are allowing outgoing traffic on the ports that Photon is using:

    https://doc.photonengine.com/en-us/realtime/current/connection-and-authentication/tcp-and-udp-port-numbers

    You only need to allow the ports for the connection protocols that you are actually using.

    On default LoadBalancing-cpp uses UDP on ports 5055, 5056 and 5058. If you pass 'true' for 'tryUseDatagramEncryption', in the ConnectOptions, then TCP on port 19093 is also used.

    If you pass 'true' for 'useAlternativePorts' to the constructor of class Client, then ports 27000-27002 are used for UDP instead of ports 5055, 5056 and 5058.

    If you set the connection protocol to TCP, WS or WSS, then the according 3 ports from the aforementioned link for these protocols are used.


    Are you saying that in order to connect to photon cloud we cannot use photonpeer even for testing purposes?

    Let me elaborate on this with some background info.

    Photon Server consists of multiple layers:

    • The Photon Core, which provides basic low level networking functionality. It's essentially a socket-server.
    • The application layer, which sits on top of the the Core a provides more high-level functionality via so-called server-side applications

    When self-hosting, you can aside from using one of the existing applications, write your own server-side application either from scratch or based on an existing application.

    The default application for a self-hosted server is the LoadBalancing application.

    Photon Cloud runs multiple applications and selects the correct one for a client, depending on the product type of the appID that the client provides.

    When the client provides a Realtime appID or a Voice appID, then it will be connected to the LoadBalancing app.

    When the client provides a Chat appID, then it will be connected to the Chat app.

    On the client side you need to use the matching client API for the chosen product type as well, either LoadBalancing-cpp or Chat-cpp or PhotonVoice-cpp. Otherwise the client won't behave the server expects it to.


    Photon-cpp is the client-side equivalent to the Photon Core level on the server side:

    It provides the low-level networking functionality that is used by the aforementioned APIs to implement their higher level functionality.


    That means that in theory you could connect to Photon Cloud with a raw PhotonPeer, but for this to work you would need to implement the high-level connection flow of LoadBalancing-cpp from scratch yourself, basically writing your own LoadBalancing-cpp implementation, which in practice does not make sense.


    Hence the only case in which you might wanna use Photon-cpp directly from your code without any of the higher-level APIs in between, is when you want to connect to a self-hosted Photon server on which you are running a custom application, that is not compatible with the provided higher level client APIs, and even in that scenario you might be better of with adding custom modifications to LoadBalancing-cpp and operating on that customized LoadBalancing-cpp derivative rather than with operating directly on Photon-cpp.


    If no can we use litepeer instead of photonpeer?

    LitePeer is the client API for the server side Lite application, which is not available on Photon Cloud nor on Photon Server v4 and higher, but only on Photon Server v3 and lower. LitePeer is not compatible to Photon Cloud at all.


    And also can u list some unreal engine games which use photon sdk?

    We don't track which Photon user uses which game engine. So we only know, which game engine is used for a certain project, when the developer provides us with this information in a support ticket, in which case it is confidential and not publicly shared by us.

    That said, most customers that use Unity, use one of our Unity-specific products PUN, Photon Bolt, Photon Fusion and Photon Quantum.

    So, naturally, a big share of the games that are listed for Photon Realtime at https://www.photonengine.com/en-US/Realtime/Showcase uses our C++ Client SDK, either with Unreal or with a bespoken in-house engine.