<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Check for reachability of a PostgreSQL DB in ArcGIS Pro SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/check-for-reachability-of-a-postgresql-db/m-p/1670774#M13298</link>
    <description>&lt;LI-CODE lang="csharp"&gt;using Npgsql;
using System;
using System.Threading;
using System.Threading.Tasks;

public static async Task&amp;lt;bool&amp;gt; CanConnectWithCredentialsAsync(string host, int port, string database, string user, string password, int timeoutSeconds = 3)
{
    // Build a connection string tuned for fast failure (timeoutSeconds)
    var csb = new NpgsqlConnectionStringBuilder
    {
        Host = host,
        Port = port,
        Database = database,
        Username = user,
        Password = password,
        Timeout = timeoutSeconds,        // connection timeout (seconds)
        CommandTimeout = timeoutSeconds, // command timeout (seconds)
        Pooling = false                  // avoid pooled connections staying open
    };

    using var cts = new CancellationTokenSource(TimeSpan.FromSeconds(timeoutSeconds + 1));
    try
    {
        await using var conn = new NpgsqlConnection(csb.ConnectionString);
        await conn.OpenAsync(cts.Token).ConfigureAwait(false);

        // optional: run a tiny, fast query to ensure DB responds
        await using var cmd = new NpgsqlCommand("SELECT 1", conn);
        cmd.CommandTimeout = timeoutSeconds;
        var result = await cmd.ExecuteScalarAsync(cts.Token).ConfigureAwait(false);
        return result != null;
    }
    catch (Exception)
    {
        // log exception if you want; return false on any failure
        return false;
    }
}&lt;/LI-CODE&gt;</description>
    <pubDate>Fri, 05 Dec 2025 03:06:25 GMT</pubDate>
    <dc:creator>SumitMishra_016</dc:creator>
    <dc:date>2025-12-05T03:06:25Z</dc:date>
    <item>
      <title>Check for reachability of a PostgreSQL DB</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/check-for-reachability-of-a-postgresql-db/m-p/1669628#M13286</link>
      <description>&lt;P&gt;We've got a PostgreSQL database online which is available via a url and login. Before trying to access the database using an sde-file, I'd like to verify that the database is actually reachable from my current ArcGIS Pro project. What's the fastest way to do that?&lt;/P&gt;&lt;P&gt;I tested using the actual credentials, but that takes ages compared to checking with a bad login. But the bad login method sometimes opens the default database connection dialog which is not good practice.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I could verify externally (cmd, python, etc.) but I'd much rather perform the check from within the AddIn. Does anyone know a fast way to check if a given database is reachable?&lt;/P&gt;&lt;P&gt;thanks&lt;/P&gt;</description>
      <pubDate>Tue, 02 Dec 2025 12:57:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/check-for-reachability-of-a-postgresql-db/m-p/1669628#M13286</guid>
      <dc:creator>nadja</dc:creator>
      <dc:date>2025-12-02T12:57:30Z</dc:date>
    </item>
    <item>
      <title>Re: Check for reachability of a PostgreSQL DB</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/check-for-reachability-of-a-postgresql-db/m-p/1669654#M13287</link>
      <description>&lt;P&gt;If I understand your queston - "&lt;SPAN&gt;&amp;nbsp;Before trying to access the database using an sde-file,"&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;I would look at this documentation -&amp;nbsp;&amp;nbsp;&lt;BR /&gt;&lt;A href="https://pro.arcgis.com/en/pro-app/3.3/help/data/geodatabases/manage-postgresql/manage-connections-postgresql.htm" target="_self"&gt;&lt;FONT size="4"&gt;Manage connections to a geodatabase in PostgreSQL&lt;/FONT&gt;&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 02 Dec 2025 14:18:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/check-for-reachability-of-a-postgresql-db/m-p/1669654#M13287</guid>
      <dc:creator>JeffSilberberg</dc:creator>
      <dc:date>2025-12-02T14:18:09Z</dc:date>
    </item>
    <item>
      <title>Re: Check for reachability of a PostgreSQL DB</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/check-for-reachability-of-a-postgresql-db/m-p/1670774#M13298</link>
      <description>&lt;LI-CODE lang="csharp"&gt;using Npgsql;
using System;
using System.Threading;
using System.Threading.Tasks;

public static async Task&amp;lt;bool&amp;gt; CanConnectWithCredentialsAsync(string host, int port, string database, string user, string password, int timeoutSeconds = 3)
{
    // Build a connection string tuned for fast failure (timeoutSeconds)
    var csb = new NpgsqlConnectionStringBuilder
    {
        Host = host,
        Port = port,
        Database = database,
        Username = user,
        Password = password,
        Timeout = timeoutSeconds,        // connection timeout (seconds)
        CommandTimeout = timeoutSeconds, // command timeout (seconds)
        Pooling = false                  // avoid pooled connections staying open
    };

    using var cts = new CancellationTokenSource(TimeSpan.FromSeconds(timeoutSeconds + 1));
    try
    {
        await using var conn = new NpgsqlConnection(csb.ConnectionString);
        await conn.OpenAsync(cts.Token).ConfigureAwait(false);

        // optional: run a tiny, fast query to ensure DB responds
        await using var cmd = new NpgsqlCommand("SELECT 1", conn);
        cmd.CommandTimeout = timeoutSeconds;
        var result = await cmd.ExecuteScalarAsync(cts.Token).ConfigureAwait(false);
        return result != null;
    }
    catch (Exception)
    {
        // log exception if you want; return false on any failure
        return false;
    }
}&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 05 Dec 2025 03:06:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/check-for-reachability-of-a-postgresql-db/m-p/1670774#M13298</guid>
      <dc:creator>SumitMishra_016</dc:creator>
      <dc:date>2025-12-05T03:06:25Z</dc:date>
    </item>
    <item>
      <title>Re: Check for reachability of a PostgreSQL DB</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/check-for-reachability-of-a-postgresql-db/m-p/1676927#M13354</link>
      <description>&lt;P&gt;While the above code checks if the connection to Postgres is working you could precede it by checking if the URL is accessible altogether using .NET only, like:&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;using var client = new WebClient();
string html = client.DownloadString("&amp;lt;Postgres URL&amp;gt;");
Console.WriteLine(html);&lt;/LI-CODE&gt;&lt;P&gt;&lt;SPAN&gt;.NET has other options that you can explore to connect to Web APIs that might be more up to date than the above snippet.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Something even more basic would be to do a ping programmatically:&amp;nbsp;&lt;A href="https://learn.microsoft.com/en-us/dotnet/api/system.net.networkinformation.ping?view=net-8.0" target="_blank"&gt;Ping Class (System.Net.NetworkInformation) | Microsoft Learn&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;This could allow you to "fail faster" if the server is down or inaccessible.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Jan 2026 21:22:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/check-for-reachability-of-a-postgresql-db/m-p/1676927#M13354</guid>
      <dc:creator>SelimDissem</dc:creator>
      <dc:date>2026-01-08T21:22:11Z</dc:date>
    </item>
  </channel>
</rss>

