PhotonApplication.TearDown not called; Timeouts

escjosh
edited March 2012 in Photon Server
I need to disconnect some ServerPeers when my app service restarts for fresh dlls. The peers don't disconnect and the application doesn't call TearDown. How can I hook in to the shutdown process?

Also, it's not clear how to go about configuring TCP connection timeouts for ServerPeers. What do I need to do to make server on the same LAN maintain a fairly short timeout (e.g. <5 sec).

Thanks

Comments

  • If Photon restarts an application because of file changes it creates a new application domain for the application. The old application instance stays alive until all connections to it are closed. Clients which connect after the restart will be bound to the new application instance of course.
    You can override the ApplicationBase.OnStopRequested method to detect if the application is about to restart.
  • escjosh wrote:
    ...
    Also, it's not clear how to go about configuring TCP connection timeouts for ServerPeers. What do I need to do to make server on the same LAN maintain a fairly short timeout (e.g. <5 sec).

    We don't have a timeout setting for the outbound peer - but you can configure a ping interval, its set in milliseconds:

    <S2S
    PingFrequency="2500">
    </S2S>

    If the "other" side simply disapears without a clean tcp-shutdown - we'll get a connection reset when we try writing to the socket. The ping will effectivly work as a timeout.

    Other settings supported (which are the same on the TCPListener!) are:
    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.
    RecvBufferSize: The size of the TCP recv buffer used by the TCP stack. This is also used to determine the TCP window size (which is used by the TCP stack for flow control). Defaults to zero which means "don’t change" which causes the operating system's default value to be used.
    SendBufferSize: The size of the TCP send buffer used by the TCP stack. Defaults to zero which means "don’t change" which causes the operating system's default value to be used.
    MaxPendingWrites: Defaults to 100. Flow control setting: configures the max amount of pending writes in buffers (see TCPBufferSize).
    MaxQueuedBuffers: Defaults to 1000. Flow control setting: configures the amount of buffers used to queue writes (see TCPBufferSize). More queueued buffers than pending writes means that we use less non-paged pool (a scarce resource) as only pending writes use non-paged pool.

    Note: the flow control settings are new in photon 3 and where introduced with the s2s feature. The default values should work fine. You should only change them if you are getting a bufferfull event "to early" meaning that you see your NIC isn't fully used (update to documentation is comming with next release).
  • escjosh wrote:
    I need to disconnect some ServerPeers when my app service restarts for fresh dlls. The peers don't disconnect and the application doesn't call TearDown. How can I hook in to the shutdown process?
    Thanks

    Alternativly you can set the follwing in your PhotonServer.config:

    <Application
    Name="YourApplication"
    ...
    ForceAutoRestart="true">
    </Application>

    ForceAutoRestart, if set to "true", implies "EnableAutoRestart" but aborts all existing connections rather than waiting for them to disconnect.
  • Awesome, thanks guys.