Cannot connect to localhost:5055

Options
BFGames
BFGames
edited February 2014 in Photon Server
So ive played with Photons Lite Server before, but wanted to create my own. Everything seems to work but when i try to connect the StatusCode i get back is timeout.

The server is running and everything. I did some Debug logging and it runs fine in Setup() and TearDown(), however my CreatePeer is never called when i try and connect from unity. Also tried 127.0.0.1:5055, with the same result. And did check, netstat -a in my CMD to make sure it was setup correctly which it seems to be.

Here is my applicationbase.

[code2=csharp]namespace PhotonServer
{
public class MyPhoton : ApplicationBase
{
private readonly ILogger Log = LogManager.GetCurrentClassLogger();

protected override PeerBase CreatePeer(InitRequest initRequest)
{
Log.Debug("CreatePeer");
return new UnityClient(initRequest.Protocol, initRequest.PhotonPeer);
}

protected override void Setup()
{
var file = new FileInfo(Path.Combine(BinaryPath, "log4net.config"));
if (file.Exists)
{
// Set logger: ExitGames.Logging, ExitGames.Logging.Log4Net;
LogManager.SetLoggerFactory(Log4NetLoggerFactory.Instance);
//Update file: log4net.Config;
XmlConfigurator.ConfigureAndWatch(file);
//At last set out log4net.config file property (click solution) to "Copy if newer" and rebuild!
}
Log.Debug("Setup");
}

protected override void TearDown()
{
Log.Debug("TearDown");
}
}
}[/code2]

My simple client:

[code2=csharp]namespace PhotonServer
{
public class UnityClient : PeerBase
{
private readonly ILogger Log = LogManager.GetCurrentClassLogger();

public UnityClient(IRpcProtocol protocol, IPhotonPeer peer) : base(protocol, peer)
{
Log.Debug("Connection from: " + peer.GetRemoteIP());
}

protected override void OnDisconnect(PhotonHostRuntimeInterfaces.DisconnectReason reasonCode, string reasonDetail)
{
Log.Debug("Client disconnected");
}

protected override void OnOperationRequest(OperationRequest operationRequest, SendParameters sendParameters)
{
Log.Error("Unknow OperationRequest received.");
}

}
}[/code2]

And from Unity, the cannot connect is never called.

[code2=csharp]if (!_peer.Connect("localhost:5055", "PhotonServer"))
Debug.Log("Cannot connect");[/code2]

At last my PhotonServer.config, should also be correct:

[code2=xml]<Application
Name="PhotonServer"
BaseDirectory="PhotonServer"
Assembly="PhotonServer"
Type="PhotonServer.MyPhoton"
ForceAutoRestart="true"
WatchFiles="dll;config"
ExcludeFiles="log4net.config">
</Application>[/code2]

Can't really find the problem. Just keeps throwing back the timeout.
Any help would be greatly appreciated.

Comments

  • chvetsov
    Options
    Hi, BFGames,
    could you show your PhotonServer.config?
    Also please upload somewhere and attach link to PhotonServer log file. Usually its name is Photon-InstanceName-date.log
  • BFGames
    Options
    chvetsov wrote:
    Hi, BFGames,
    could you show your PhotonServer.config?
    Also please upload somewhere and attach link to PhotonServer log file. Usually its name is Photon-InstanceName-date.log

    PhotonServer.config:

    [code2=xml]<?xml version="1.0" encoding="Windows-1252"?>
    <!--
    (c) 2010 by Exit Games GmbH, http://www.exitgames.com
    Photon server configuration file.
    For details see the photon-config.pdf.

    This file contains two configurations:

    "Default"
    Default. Various applications and demos.
    Starts the apps: Lite, LiteLobby, MmoDemo, CounterPublisher and Policy
    Listens: udp-port 5055, tcp-port: 4530, 843 and 943
    "LoadBalancing"
    Loadbalanced setup for local development: A Master-server and two game-servers.
    Starts the apps: Game1, Game2, Master, CounterPublisher and Policy
    Listens: udp-port 5055, tcp-port: 4530, 843 and 943
    -->

    <Configuration>
    <!-- Multiple instances are supported. Each instance has its own node in the config file. -->
    <!-- PhotonControl will currently only start "Default" but the .cmd files could be modified to start other instances. -->

    <!-- Instance settings -->
    <Default
    MaxMessageSize="512000"
    MaxQueuedDataPerPeer="512000"
    PerPeerMaxReliableDataInTransit="51200"
    PerPeerTransmitRateLimitKBSec="256"
    PerPeerTransmitRatePeriodMilliseconds="200"
    MinimumTimeout="5000"
    MaximumTimeout="30000">

    <!-- 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="5055">
    </UDPListener>
    </UDPListeners>

    <!-- 0.0.0.0 opens listeners on all available IPs. Machines with multiple IPs should define the correct one here. -->
    <!-- Port 4530 is Photon's default for TCP connecttions. -->
    <!-- A Policy application is defined in case that policy requests are sent to this listener (known bug of some some flash clients) -->
    <TCPListeners>
    <TCPListener
    IPAddress="0.0.0.0"
    Port="4530"
    PolicyApplication="Policy"
    >
    </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">
    </TCPPolicyListener>
    <TCPPolicyListener
    IPAddress="0.0.0.0"
    Port="943"
    Application="Policy">
    </TCPPolicyListener>
    </TCPPolicyListeners>

    <!-- WebSocket (and Flash-Fallback) compatible listener -->
    <WebSocketListeners>
    <WebSocketListener
    IPAddress="0.0.0.0"
    Port="9090"
    DisableNagle="true"
    InactivityTimeout="10000"
    OverrideApplication="Lite">
    </WebSocketListener>
    </WebSocketListeners>

    <!-- 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="Lite">
    <!-- Lite Application -->
    <Application
    Name="Lite"
    BaseDirectory="Lite"
    Assembly="Lite"
    Type="Lite.LiteApplication"
    ForceAutoRestart="true"
    WatchFiles="dll;config"
    ExcludeFiles="log4net.config">
    </Application>

    <!-- LiteLobby Application -->
    <Application
    Name="LiteLobby"
    BaseDirectory="LiteLobby"
    Assembly="LiteLobby"
    Type="LiteLobby.LiteLobbyApplication"
    ForceAutoRestart="true"
    WatchFiles="dll;config"
    ExcludeFiles="log4net.config">
    </Application>

    <!-- MMO Demo Application -->
    <Application
    Name="MmoDemo"
    BaseDirectory="MmoDemo"
    Assembly="Photon.MmoDemo.Server"
    Type="Photon.MmoDemo.Server.PhotonApplication"
    ForceAutoRestart="true"
    WatchFiles="dll;config"
    ExcludeFiles="log4net.config">
    </Application>

    <!-- CounterPublisher Application -->
    <Application
    Name="CounterPublisher"
    BaseDirectory="CounterPublisher"
    Assembly="CounterPublisher"
    Type="Photon.CounterPublisher.Application"
    ForceAutoRestart="true"
    WatchFiles="dll;config"
    ExcludeFiles="log4net.config">
    </Application>

    <!-- Flash & Silverlight Policy Server -->
    <Application
    Name="Policy"
    BaseDirectory="Policy"
    Assembly="Policy.Application"
    Type="Exitgames.Realtime.Policy.Application.Policy">
    </Application>

    <!-- Own server: name = project name, BD = folder name under deploy, Assembly dll file in that folder, Type = our namespace dot applicationname class -->
    <Application
    Name="PhotonServer"
    BaseDirectory="PhotonServer"
    Assembly="PhotonServer"
    Type="PhotonServer.MyPhoton"
    ForceAutoRestart="true"
    WatchFiles="dll;config"
    ExcludeFiles="log4net.config">
    </Application>

    </Applications>
    </Default>

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

    <!-- 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="5055"
    OverrideApplication="Master">
    </UDPListener>
    <UDPListener
    IPAddress="0.0.0.0"
    Port="5056"
    OverrideApplication="Game1">
    </UDPListener>
    <UDPListener
    IPAddress="0.0.0.0"
    Port="5057"
    OverrideApplication="Game2">
    </UDPListener>
    </UDPListeners>

    <!-- 0.0.0.0 opens listeners on all available IPs. Machines with multiple IPs should define the correct one here. -->
    <TCPListeners>
    <!-- TCP listener for Game clients on Master application -->
    <TCPListener
    IPAddress="0.0.0.0"
    Port="4530"
    OverrideApplication="Master">
    </TCPListener>

    <TCPListener
    IPAddress="0.0.0.0"
    Port="4531"
    OverrideApplication="Game1">
    </TCPListener>

    <TCPListener
    IPAddress="0.0.0.0"
    Port="4532"
    OverrideApplication="Game2">
    </TCPListener>

    <!-- DON'T EDIT THIS. TCP listener for GameServers on Master application -->
    <TCPListener
    IPAddress="0.0.0.0"
    Port="4520">
    </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">
    </TCPPolicyListener>
    <TCPPolicyListener
    IPAddress="0.0.0.0"
    Port="943"
    Application="Policy">
    </TCPPolicyListener>
    </TCPPolicyListeners>

    <!-- WebSocket (and Flash-Fallback) compatible listener -->
    <WebSocketListeners>
    <WebSocketListener
    IPAddress="0.0.0.0"
    Port="9090"
    DisableNagle="true"
    InactivityTimeout="10000"
    OverrideApplication="Master">
    </WebSocketListener>

    <WebSocketListener
    IPAddress="0.0.0.0"
    Port="9091"
    DisableNagle="true"
    InactivityTimeout="10000"
    OverrideApplication="Game1">
    </WebSocketListener>

    <WebSocketListener
    IPAddress="0.0.0.0"
    Port="9092"
    DisableNagle="true"
    InactivityTimeout="10000"
    OverrideApplication="Game2">
    </WebSocketListener>
    </WebSocketListeners>

    <!-- 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="LoadBalancing\Master"
    Assembly="Photon.LoadBalancing"
    Type="Photon.LoadBalancing.MasterServer.MasterApplication"
    ForceAutoRestart="true"
    WatchFiles="dll;config"
    ExcludeFiles="log4net.config"
    >
    </Application>
    <Application
    Name="Game1"
    BaseDirectory="LoadBalancing\GameServer1"
    Assembly="Photon.LoadBalancing"
    Type="Photon.LoadBalancing.GameServer.GameApplication"
    ForceAutoRestart="true"
    WatchFiles="dll;config"
    ExcludeFiles="log4net.config">
    </Application>
    <Application
    Name="Game2"
    BaseDirectory="LoadBalancing\GameServer2"
    Assembly="Photon.LoadBalancing"
    Type="Photon.LoadBalancing.GameServer.GameApplication"
    ForceAutoRestart="true"
    WatchFiles="dll;config"
    ExcludeFiles="log4net.config">
    </Application>
    <Application
    Name="Policy"
    BaseDirectory="Policy"
    Assembly="Policy.Application"
    Type="Exitgames.Realtime.Policy.Application.Policy"
    ForceAutoRestart="true"
    WatchFiles="dll;config;xml"
    ExcludeFiles="log4net.config">
    </Application>

    <!-- CounterPublisher Application -->
    <Application
    Name="CounterPublisher"
    BaseDirectory="CounterPublisher"
    Assembly="CounterPublisher"
    Type="Photon.CounterPublisher.Application"
    ForceAutoRestart="true"
    WatchFiles="dll;config"
    ExcludeFiles="log4net.config">
    </Application>
    </Applications>
    </LoadBalancing>
    </Configuration>[/code2]

    My log:

    http://lasseknudsen.dk/Files/PhotonServer.log
  • chvetsov
    Options
    sent me please another log file for Photon. it has current 'date' in name for instance Photon-LoadBalancing-20140205.log

    From config point of view everything seems fine. Make sure that you were starting LoadBalancing instance
  • BFGames
    Options
    chvetsov wrote:
    sent me please another log file for Photon. it has current 'date' in name for instance Photon-LoadBalancing-20140205.log

    From config point of view everything seems fine. Make sure that you were starting LoadBalancing instance

    Why do i need to check LoadBalancing when i am working in the "default" ? Anyways here is both the LoadBalancing and Default log :)

    http://lasseknudsen.dk/Files/Photon-LoadBalancing-20140205.log
    http://lasseknudsen.dk/Files/Photon-Default-20140205.log
  • chvetsov
    Options
    hmm, everything seems to be ok

    Please, check how you create a peer, may be you create a TCP peer ?
  • BFGames
    Options
    Nope:

    [code2=csharp]PhotonPeer peer = new PhotonPeer(_photonServer, ConnectionProtocol.Udp);[/code2]

    And _photonServer is my IPhotonPeerListener:

    [code2=csharp]public class PhotonServer : IPhotonPeerListener[/code2]

    It is strange that it is not working...
  • chvetsov
    Options
    did you check your firewall settings?
    does other demos work?
  • BFGames
    Options
    chvetsov wrote:
    did you check your firewall settings?
    does other demos work?

    Did not check firewall. I did however run a modified Lite server a few months back without problems.
  • chvetsov
    Options
    few months back does not make sense. Try download last sdk server and client and try them
  • chvetsov
    Options
    few months back does not make sense. Try download last sdk server and client and try them
  • BFGames
    Options
    Did not have the newest client sdk laying around, so that helped! Works like a charm now. Thanks a lot.