When server connection failed

2490
1
08-26-2015 04:56 AM
PetrMusial
New Contributor

Is there some general easy way to recognize that server response is too long. Something like navigation timeout for laye. Or indication that service connection failed during communication not only when load layer. Thanks.

0 Kudos
1 Reply
ThadTilton
Esri Contributor

Are you thinking about an event, for example, that would be raised if the object (layer, e.g.) lost the server connection (or had some other server-related issue)? There's no mechanism in place for that (that I'm aware of). Instead, I think you need to be a little proactive if you want to check server status.

You can do a manual check by pinging a server for a response.

For example:

    var status = this.CheckServer("myserver.com");

    if (status == System.Net.NetworkInformation.IPStatus.Success)

    {

        // ok

    }

private System.Net.NetworkInformation.IPStatus CheckServer(string url)

{

    System.Net.NetworkInformation.PingReply reply;

    using (System.Net.NetworkInformation.Ping ping = new System.Net.NetworkInformation.Ping())

    {

        reply = ping.Send(url);

    }

    return reply.Status;

}

... but unfortunately, 'ping' will be disabled for many servers.

Another option is to call GetAllDetailsAsync for a service (an ArcGISDynamicMapServiceLayer, e.g.). You can use that info to get the number of layers and tables in the service, metadata about all layers, the maximum record count returned, etc. (and verify that you get a response, of course). For example:

var info = await arcGISDynLayer.GetAllDetailsAsync();

var layerCount = info.Layers.Count;

var tableCount = info.Tables.Count;

foreach (var l in info.Layers)

{

    // get info about each layer

}

foreach (var t in info.Tables)

{

    // get info about each table

}

0 Kudos