[Solved] Duplicating LoadBalancing Application

Options
mmetcalfe
edited November 2011 in Photon Server
I am in need of a test environment for our server which is a modification of the LoadBalancing application. Based on my Photon knowledge, and reading some posts on this forum it seems like I have it configured correctly, but I still cannot get my client to connect properly.

Here are the steps I performed to attempt the duplication:
  • Copied the deploy\Loadbalancing folder to a folder called deploy\LoadbalancingTEST
  • Added LoadbalancingTEST to my bin_Win32_xp\PhotonControl.exe.config file:
            <setting name="Instances" serializeAs="String">
                <value>InstanceLoadBalancing,InstanceLoadBalancingTEST</value>
            </setting>
[*]Modified the following in LoadbalancingTEST\Master\bin\Photon.LoadBalancing.dll.config:[/*]
GamingTcpPort = 5531
GamingUdpPort = 6056
OutgoingMasterServerPeerPort = 5520
IncomingGameServerPeerPort = 5520
[*]And added the following section to my bin_Win32_xp\PhotonServer.config file:[/*]
	<InstanceLoadBalancingTEST
		EnablePerformanceCounters = "true"
		DataSendingDelayMilliseconds="50"
		AckSendingDelayMilliseconds="50"
		PerPeerMaxReliableDataInTransit="16384"
		PerPeerTransmitRateLimitKBSec="128"
		MaxQueuedDataPerPeer="65536"
		MinimumTimeout="5000"
		MaximumTimeout="10000">
		<IOPool/>

		<ThreadPool
			InitialThreads="4"
			MinThreads="4"
			MaxThreads="4">
		</ThreadPool>

		<!-- Using the same value for initial, min and max makes the pool fixed size, which allows optimizations. -->
		<ENetThreadPool
			InitialThreads="2"
			MinThreads="2"
			MaxThreads="2">
		</ENetThreadPool>

		<!-- 0.0.0.0 opens listeners on all available IPs. Machines with multiple IPs should define the correct one here. -->
		<!-- Port 5055 is Photon's default for UDP connections. -->
		<UDPListeners>
			<UDPListener
				IPAddress="0.0.0.0"
				Port="6055"
				OverrideApplication="Master">
			</UDPListener>
			<UDPListener
				IPAddress="0.0.0.0"
				Port="6056"
				OverrideApplication="Game1">
			</UDPListener>
			<UDPListener
				IPAddress="0.0.0.0"
				Port="6057"
				OverrideApplication="Game2">
			</UDPListener>
		</UDPListeners>
		
		<!-- 0.0.0.0 opens listeners on all available IPs. Machines with multiple IPs should define the correct one here. -->
		<!-- Port 5055 is Photon's default for TCP connecttions. -->
		<TCPListeners>
			<!-- TCP listener for Game clients on Master application -->
			<TCPListener
				IPAddress="0.0.0.0"
				Port="5530"
				OverrideApplication="Master"
				DisableNagle="true"
				InactivityTimeout="0">
			</TCPListener>
			
			<TCPListener
				IPAddress="0.0.0.0"
				Port="5531"
				OverrideApplication="Game1"
				DisableNagle="true"
				InactivityTimeout="0">
			</TCPListener>

			<TCPListener
				IPAddress="0.0.0.0"
				Port="5532"
				OverrideApplication="Game2"
				DisableNagle="true"
				InactivityTimeout="0">
			</TCPListener>
			
			<!-- DON'T EDIT THIS. TCP listener for GameServers on Master application -->
			<TCPListener
				IPAddress="0.0.0.0"
				Port="5520"
				DisableNagle="true"
				InactivityTimeout="0">
			</TCPListener>
		</TCPListeners>
		
		<!-- Policy request listener for Unity and Flash (port 843) and Silverlight (port 943)  -->
		<TCPPolicyListeners>
			<!-- multiple Listeners allowed for different ports -->
			<TCPPolicyListener
				IPAddress="0.0.0.0"
				Port="843"
				Application="Policy"
				InactivityTimeout="5000">
			</TCPPolicyListener>
		</TCPPolicyListeners>

		<!-- Defines the Photon Runtime Assembly to use. -->
		<Runtime
			Assembly="PhotonHostRuntime, Culture=neutral"
			Type="PhotonHostRuntime.PhotonDomainManager"
			UnhandledExceptionPolicy="Ignore">
		</Runtime>

		<!-- 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_win32 folders. The BaseDirectory must include a "bin" folder. -->
		<Applications Default="Master">		
			<Application
				Name="Master"
				BaseDirectory="LoadBalancingTEST\Master"
				Assembly="Photon.LoadBalancing"
				Type="Photon.LoadBalancing.MasterServer.MasterApplication">
			</Application>
			<Application
				Name="Game1"
				BaseDirectory="LoadBalancingTEST\GameServer1"
				Assembly="Photon.LoadBalancing"
				Type="Photon.LoadBalancing.GameServer.GameApplication"
				EnableAutoRestart="true"
				WatchFiles="dll;config"
				ExcludeFiles="log4net.config">
			</Application>
			<Application
				Name="Game2"
				BaseDirectory="LoadBalancingTEST\GameServer2"
				Assembly="Photon.LoadBalancing"
				Type="Photon.LoadBalancing.GameServer.GameApplication"
				EnableAutoRestart="true"
				WatchFiles="dll;config"
				ExcludeFiles="log4net.config">
			</Application>
			<Application
				Name="Policy"
				BaseDirectory="Policy"
				Assembly="Policy.Application"
				Type="Exitgames.Realtime.Policy.Application.Policy"
				EnableAutoRestart="true"
				WatchFiles="dll;config;xml"
				ExcludeFiles="log4net.config">
			</Application>
		</Applications>
	</InstanceLoadBalancingTEST>


When I try to start the service from the control panel/services, I get the following error:
Could not start the Photon Socket Server: InstanceLoadBalancingTEST service on Local Computer.
Error 10048: Only one usage of each socket address (protocol/network address/port) is normally permitted.

Which would make me think I have it configured slightly wrong, but can't quite pick out what is incorrect. Does someone see the problem, or did I take the wrong steps all together to make a duplicate of my application?

Thanks,
Michael

p.s. - I used the defaults for the original application.

Comments

  • dreamora
    Options
    you likely forgot to reconfigure the Game server and master server ports in their distinct configurations
  • [Deleted User]
    edited November 2011
    Options
    Did I get it right - you are running two Photon instances on one server (one with the original Loadbalancing apps and one with your modifications)? If so, you probably try to use the policy port 843 twice. If Photon #1 already delivers policy files, you can remove the listener from Photon #2:
     <TCPPolicyListener
      IPAddress="0.0.0.0"
      Port="843"
      Application="Policy"
      InactivityTimeout="5000">
    </TCPPolicyListener>
    

    Also , please check the config files in \LoadbalancingTEST\Game1\bin\ and \LoadbalancingTEST\Game1\bin\.
  • dreamora wrote:
    you likely forgot to reconfigure the Game server and master server ports in their distinct configurations

    Thanks dreamora, but did I miss something in particular, that I didn't mention in configuring listed above? I did mirror changes made in LoadbalancingTEST\Master\bin\Photon.LoadBalancing.dll.config in the GameServer1\bin and GameServer2\bin config files for ports for the MasterIPAddress, PublicIPAddress, GamingTcpPort, GamingUdpPort, OutgoingMasterServerPeerPort, and IncomignGameServerPeerPort.
  • Nicole wrote:
    Did I get it right - you are running two Photon instances on one server (one with the original Loadbalancing apps and one with your modifications)? If so, you probably try to use the policy port 843 twice.

    Not exactly. Sorry for not being clear. What I have is one Photon server running on my local machine. We have made changes to the Loadbalancing project. I essentially copy/pasted the current (modified) Loadbalancing deploy folder and named it LoadbalancingTEST and tweaked some of the .config files. Maybe this won't even work correctly? Seems like it should just behave like another application, assuming I have the ports adjusted correctly?

    Actually, on reflection, maybe I am going about this wrong anyway. Maybe I can just copy/paste our deploy\Loadbalancing to deploy\LoadbalancingTEST and append TEST to the OverrideApplication names? Just seems like this should be pretty straight-forward and I might be overcomplicating.
  • Right. There is no need to modify the port settings in that case. Just keep the original ones, it should make your work much easier. :-) (You don't even need to change the "OverrideApplication" entries. They must match your application names, which have not been changed (Name="Game1" etc.). So no need for modification at all . Only the paths in the <Application> element need to be correct. )

    However, it SHOULD work to adjust the ports, and I can't see anything wrong with your config. You could check (with "netstat -a") which ports are already in use before you fire up Photon.
  • Thanks for the help Nicole, finally got it working.

    For completeness, in case someone else reads this post. As mentioned above, I just copy/pasted the deploy\Loadbalancing folder and renamed it.

    I then added a section to the deploy\bin_Win<yourversionhere>\PhotonServer.config file for the new application (LoadbalancingTEST in my case) -- after that, it was just a matter of adjusting the port numbers in the new application and the appropriate Loadbalancing\Master; Loadbalancing\Game1; and Loadbalancing\Game2 config files.

    I think I read somewhere that the PhotonControl application cannot fully control 2 instances, so I have just been starting/stopping the TEST application via the windows services application and/or the console. Someone correct me if I am wrong (I did use the PhotonControl to install the service, however).