수정중인 페이지 입니다.
server | v5 switch to v4  

Photon Server Configuration

The main configuration file for Photon is the PhotonServer.config. It is located in the binaries-folder of the SDK. It is used to set up applications, listeners for IPs and performance specific values. It does not contain config values for the game logic.

The default values make sure Photon scales nicely on more cores but do not overwhelm a regular machine. In general, performance tweaks are not needed.

The settings listed here are most commonly used. More options are described in the Photon Server Config Settings Page.

목차

The Instance Node

Multiple instances are supported. Each instance has its separate node in the config file. An instance is a group of applications, listeners and other settings that should be used together when running the instance.

Example:

<Configuration>
  <LoadBalancing
    MaxMessageSize="512000"
    MaxQueuedDataPerPeer="512000"
    PerPeerMaxReliableDataInTransit="51200"
    PerPeerTransmitRateLimitKBSec="256"
    PerPeerTransmitRatePeriodMilliseconds="200"
    MinimumTimeout="5000"
    MaximumTimeout="30000"
      DirectDispatchToCLR="true"
    DisplayName="LoadBalancing (MyCloud)">

    <!-- instance config here -->

  </LoadBalancing>
</Configuration>

The instance node name is custom (e.g. "LoadBalancing") and can have these attributes:

  • MaxMessageSize: maximum size allowed of messages sent by a single peer in bytes.
  • MaxQueuedDataPerPeer: maximum buffer size capacity per peer in bytes.
  • PerPeerMaxReliableDataInTransit: The maximum amount of reliable data that a peer can send and which the peer has not as yet received an ACK for. In bytes. Once this amount of data has been sent, all future reliable data will be queued.
  • PerPeerTransmitRateLimitKBSec: The maximum amount of data (reliable AND unreliable) that can be sent in a second (in KB). This can be used to limit the amount of data that a peer can send. When the limit is reached further reliable data is queued and unreliable data is dropped.
  • PerPeerTransmitRatePeriodMilliseconds: How often we check the transmission rate limit. By default, we check every 250ms (i.e. 4 times per second) and we scale the PerPeerTransmitRateLimitKBSec by 4 for each check. A smaller value makes the data flow more consistent while a larger value makes the flow more jerky but uses less server resources.
  • MinimumTimeout (see "Timeout Settings")
  • MaximumTimeout (see "Timeout Settings")
  • DirectDispatchToCLR: If true, messages are pushed from the network to the managed layer directly without being queued in a native queue dispatched by a ThreadPool.
  • DisplayName: the name to be used for the instance by PhotonControl.
  • DataSendingDelayMilliseconds (see "Delay Settings")
  • AckSendingDelayMilliseconds (see "Delay Settings")
  • ProduceDumps: Switch to enable or disable creation of "dump files" in case of a crash. Dump files are essential to find issues in the Photon Core.
  • DumpType: Defines the type of crash dumps to write. The types are "Full", "Maxi" and "Mini" and they include less information from first to last but also require less storage space.
  • MaxDumpsToProduce: Configures how many dump files are written maximum. If the files are moved or deleted, new ones can be written.
  • LogFileLocation: log file location for the unmanaged Photon Socket Server. It can be either an absolute path or relative to "PhotonSocketServer.exe".
  • ...

메인 화면으로

Timeout Settings

Two values in the instance node describe how the server times out unresponsive UDP clients: MinimumTimeout and MaximumTimeout.

A peer connected with UDP has MinimumTimeout milliseconds to respond before it can be disconnected. The actual time until disconnect is determined dynamically per-peer based on the RTT history. Previously good RTTs will disconnect faster.

TCP connections have a separate InactivityTimeout setting in the nodes TCPListener (also in the PhotonServer.config). We set those to 5 seconds (5000ms). If no request arrives during this time, the connection will be timed out and closed. Clients will also regularly "ping" the server, to avoid this.

Keep in mind that a client independently monitors a connection and might time it out as well. Both sides should have similar timeouts, fitting your game.

메인 화면으로

Delay Settings

The attributes DataSendingDelayMilliseconds and AckSendingDelayMilliseconds represent a trade-off between performance and minimal response times. This delay directly adds some lag to reduce the traffic:

The wait allows the server to aggregate commands and sends them in one package. The send delay is triggered when the server sends anything, the ack delay by incoming reliable data.

As you can see above, the default values are 50ms each. We found this to be a good value but it causes a \~50ms round-trip time, even if the client and the server run on the same machine.

Depending on your game, you should load test with different values. A delay of 0 is a special case that skips usage of timers, so avoid low delays < 10.

메인 화면으로

The Application Node

The config file defines which applications Photon should load on startup. In the "Applications" node, several "Application" entries can be added.

To load multiple applications, simply add more application nodes (with unique names). One of them can be made the default application by using its name ("Master" in the example). The default app is the fall-back for clients that try to connect to an unknown application.

Applications that are not set up in the PhotonServer.config won't be loaded and don't need to be deployed. When an application is in the config but the files are missing Photon won't start and name the issue in the logs.

Example:

<!-- Defines which applications are loaded on start and which of them is used by default. Make sure the default application is defined. -->
<!-- Application-folders must be located in the same folder as the bin_Win64 folders. The BaseDirectory must include a "bin" folder. -->
<Applications Default="Master">
    <Application
        Name="Master"
        BaseDirectory="LoadBalancing\Master"
        Assembly="Photon.LoadBalancing"
        Type="Photon.LoadBalancing.MasterServer.MasterApplication">
    </Application>
    <Application
        Name="Game"
        BaseDirectory="LoadBalancing\GameServer"
        Assembly="Photon.LoadBalancing"
        Type="Photon.LoadBalancing.GameServer.GameApplication">
    </Application>

    <!-- CounterPublisher Application -->
    <Application
        Name="CounterPublisher"
        BaseDirectory="CounterPublisher"
        Assembly="CounterPublisher"
        Type="Photon.CounterPublisher.Application">
    </Application>

    <Application
        Name="NameServer"
        BaseDirectory="NameServer"
        Assembly="Photon.NameServer"
        Type="Photon.NameServer.PhotonApp">
    </Application>
</Applications>

Each application is assigned a name by which the clients reference it on connect. The attributes supported by the application node:

  • BaseDirectory: defines the folder in which an application resides. It does not name the "bin" folder but expects it by convention.
  • Assembly: the ".dll" name of the application.
  • Type: the "main" class of the application (which derives from Photon.SocketServer.Application).

메인 화면으로

Listeners

These configure endpoints on your machine per protocol, IP and port. Multiple listeners types can be defined. Multiple listeners of the same type can be defined, opening several IP/port combinations.

메인 화면으로

Common Attributes

  • IPAddress: The default IP 0.0.0.0 makes Photon listen on any locally available IP. Machines with multiple IPs should define the correct one here. By replacing the wild-card IP, Photon will open only the specific IP address.
    Note: If you are using a license that's bound to an IP you need to set this IP in the configured listeners.
  • Port: port number to listen to.
  • OverrideApplication: any client that connects to this port will end up in the application named, no matter what the client connects to.
  • DefaultApplication: is a fall-back, in case the application named by a client is not found.

메인 화면으로

Certificate Setup For Secure Listeners

In v5 we use OpenSSL for certificates handling (format, configuration, etc.). Here are the settings that should be used for the applicable listeners (TCPListener, S2S, WebSocketListener, WebSocketS2S). In order to make a listener secure (use a certificate) set "Secure" to True. All other certificate related settings require this in order to be effective.

You can skip all settings if the certificate file(s) path(s) match(es) default expected value(s). "RootCertificate" file can be skipped as it's completely optional and the server can work without it.

For ciphers list string, we recommend TLS >= 1.2 as SSLv3, TLS 1.0 and 1.1 should be deprecated.

  • Secure: True or False to define if this listener uses a secure connection.
  • CipherList: OpenSSL's ciphers list string. See OpenSSL's ciphers documentation page for more information, especially "CIPHER STRINGS" and "EXAMPLES" parts. Requires "Secure" to be True.
  • CertificatePath: Absolute path of the directory that contains the certificate file with no trailing slash. Default is the "certs" subfolder of the folder containing "PhotonServer.config", i.e. "{PhotonServer.config folder}\certs", in SDK: "{SDK folder}\deploy\bin_Win64\certs". Requires "Secure" to be True.
  • Certificate: Name of the file containing the certificate. Default is "server.pem". Folder is defined by "CertificatePath". Requires "Secure" to be True.
  • RootCertificates: Name of the file containing root certificates if any. Default is "root.pem". Folder is defined by "CertificatePath". Requires "Secure" to be True.

메인 화면으로

TCPListeners

  • InactivityTimeout: how long before the server disconnects a non-responsive peer. "0" value means no timeout. In milliseconds.
  • DisableNagle: Determines if Nagle's algorithm is in use on the connection. If set to true then Nagle is disabled and outbound TCP data will be sent as soon as it reaches the TCP stack. If set to false then Nagle is in operation and the TCP stack will attempt to colasce outbound data into fewer datagrams. Setting this setting to true might improve the latency of your TCP connections a little, at the expense of there being more datagrams sent.

메인 화면으로

WebSocketListeners

  • AppDataInactivityTimeout: A timeout for the application (managed code) if it doesn't get any data as opposed to low level (native code) keep-alive pings.

메인 화면으로

Ports Configuration

To change the applications' ports, edit the "Port" attribute value in the configured listeners nodes. Change your client to connect to the new master server port. Restart Photon Server.

메인 화면으로

Changing Master Server Ports

If you happen to change the port for the "Master" application, you need to update the configuration for the NameServer application. The idea is to change the setting(s) that match(es) the protocol(s) of the listener(s) where the port is changed. Use the following list to get the mapping between the listener name and the setting name:

  • Listener name in "deploy\bin_Win64\PhotonServer.config" -> Setting name in "deploy\NameServer\bin\Photon.NameServer.dll.config"
  • "UDPListener" -> "MasterServerPortUdp"
  • "TCPListener" -> "MasterServerPortTcp"
  • "WebSocketListener" -> "MasterServerPortWebSocket" / "MasterServerPortSecureWebSocket"
  • "RHTTPListener" -> "MasterServerPortHttp" / "MasterServerPortSecureHttp"

Example:

If you change the UDPListener port from default 5055 to 5555 in "deploy\bin_Win64\PhotonServer.config"

<UDPListener
    IPAddress="0.0.0.0"
    Port="5555"
    OverrideApplication="Master">
</UDPListener>

You need to edit the "MasterServerPortUdp" value in "deploy\NameServer\bin\Photon.NameServer.dll.config" to match the value set in UDPListener:

<setting name="MasterServerPortUdp" serializeAs="String">
    <value>5555</value>
</setting>

The values of the "MasterServerPortXXX" settings configured for the "NameServer" application in "deploy\NameServer\bin\Photon.NameServer.dll.config" correspond to the port numbers returned with the "Master" address to the client by the "NameServer" application when authenticating for each protocol. If the ports are not configured (missing) for a protocol or not configured properly (mismatch) for a protocol, clients could have issues connecting to the master server.

메인 화면으로

Changing Game Server Ports

If you happen to change the port for the "Game" application, you need to update the configuration for that application. The idea is to change the setting(s) that match(es) the protocol(s) of the listener(s) where the port is changed. Use the following list to get the mapping between the listener name and the setting name:

  • Listener name in "deploy\bin_Win64\PhotonServer.config" -> Setting name in "deploy\LoadBalancing\GameServer\bin\Photon.LoadBalancing.dll.config"
  • "UDPListener" -> "GamingUdpPort"
  • "TCPListener" -> "GamingTcpPort"
  • "WebSocketListener" -> "GamingWebSocketPort" / "GamingSecureWebSocketPort"
  • "RHTTPListener" -> "GamingHttpPort" / "GamingHttpsPort"

Example:

If you change the UDPListener port from default 5056 to 6666 in "deploy\bin_Win64\PhotonServer.config"

<UDPListener
    IPAddress="0.0.0.0"
    Port="6666"
    OverrideApplication="Game">
</UDPListener>

You need to edit the "GamingUdpPort" value in "deploy\LoadBalancing\GameServer\bin\Photon.LoadBalancing.dll.config" to match the value set in UDPListener:

<!-- Client-to-Gameserver UDP connections. Needs to match the UDPListener in PhotonServer.config -->
<setting name="GamingUdpPort" serializeAs="String">
    <value>6666</value>
</setting>

The values of the "GamingXXXPort" settings configured for the "Game" application in "deploy\LoadBalancing\GameServer\bin\Photon.LoadBalancing.dll.config" correspond to the port numbers returned with the "Game" address to the client by the "Master" application in matchmaking for each protocol. If the ports are not configured (missing) for a protocol or not configured properly (mismatch) for a protocol, clients could have issues joining or creating rooms using that protocol. In fact, they will not be able to connect to the "Game" server application.

메인 화면으로

Adding Ports

You can configure multiple ports per application. This could be useful if some clients have trouble reaching an application using a certain protocol and you cannot change that protocol for all clients. The client needs to explicitly switch to those ports when needed especially when connecting to the "Game" server application.

Example:

By default, we provide alternative UDP ports per application. Clients can use port 5055 to connect to Master and alternatively 27001. Clients can use port 5056 to connect to Game and alternatively 27002. Clients can use port 5058 to connect to NameServer and alternatively 27000.

    <UDPListeners>
      <UDPListener
        IPAddress="0.0.0.0"
        Port="5055"
        OverrideApplication="Master">
      </UDPListener>
      <UDPListener
        IPAddress="0.0.0.0"
        Port="27001"
        OverrideApplication="Master">
      </UDPListener>
      <UDPListener
        IPAddress="0.0.0.0"
        Port="5056"
        OverrideApplication="Game">
      </UDPListener>
      <UDPListener
        IPAddress="0.0.0.0"
        Port="27002"
        OverrideApplication="Game">
      </UDPListener>
      <UDPListener
        IPAddress="0.0.0.0"
        Port="5058"
        OverrideApplication="NameServer">
      </UDPListener>
      <UDPListener
        IPAddress="0.0.0.0"
        Port="27000"
        OverrideApplication="NameServer">
      </UDPListener>
    </UDPListeners>

메인 화면으로

Runtime Node

Defines the Photon Runtime Assembly to use.

<Runtime
    Assembly="PhotonHostRuntime, Culture=neutral"
    Type="PhotonHostRuntime.PhotonDomainManager"
    UnhandledExceptionPolicy="TerminateProcess">
</Runtime>
  • UnhandledExceptionPolicy: Ignore or TerminateProcess.

기술문서 TOP으로 돌아가기