fixer-m / snowflake-db-net-client

Snowflake .NET Client
Apache License 2.0
51 stars 14 forks source link

First request has 1 minute delay #23

Closed mbwilding closed 2 years ago

mbwilding commented 2 years ago

Hey, when I do my first request it takes a minute before the rest of the queries go through instantly. Do you know why there is a 1 min delay, I am assuming it's a timeout of some sort.

_http = new HttpClient(new HttpClientHandler
{
    SslProtocols = SslProtocols.Tls12,
    CheckCertificateRevocationList = true,
    ServerCertificateCustomValidationCallback = (message, cert, chain, errors) => true
});

Db = new SnowflakeClient(
    new SnowflakeClientSettings(
        new AuthInfo("REDACTED", snowflakeSecret, "REDACTED", "ap-southeast-2"),
        new SessionInfo
        {
            Role = "REDACTED",
            Database = "REDACTED",
            Warehouse = "REDACTED",
            Schema = "REDACTED"
        }));
Db.SetHttpClient(_http);
await Db.InitNewSessionAsync();
....QueryRawResponseAsync("SELECT bet_account_num " +
                                                                 "FROM account_activity " +
                                                                 $"WHERE bet_account_num = {req.BetAccountId} " +
                                                                 "LIMIT 1;")!;

This is where the initial one minute delay would occur.

mbwilding commented 2 years ago

Running this locally as a unit test it works instantly.

mbwilding commented 2 years ago

Solved by:

_http = new HttpClient(new HttpClientHandler
{
    SslProtocols = SslProtocols.Tls12,
    CheckCertificateRevocationList = false, // False
    ServerCertificateCustomValidationCallback = (message, cert, chain, errors) => true
});
fixer-m commented 2 years ago

I'm glad you've found solution. Usually this workaround helps to avoid SSL connection issue, but I haven't heard of any delay issues before. Maybe I need to investigate this issue. Thanks for reporting!

mbwilding commented 2 years ago

It was to do with certificate revocation. Setting to false solved that. Otherwise it takes a minute to connect within an AWS lambda.