Snowflake session no longer exists. new login required to access the service

Viewed 69

I am pulling data from Snowflake into my .NET MVC 3.1 application using Snowflake .NET connector(Snowflake.Data) and running into an issue as below:

The issue occurs only when there is no call from app to Snowflake for more than 4 hours.

"Session no longer exists. New login required to access the service. SqlState: , VendorCode: 390111"

I understand this can be fixed by setting CLIENT_SESSION_KEEP_ALIVE=True which I guess is not supported by .NET ? Is there any workaround?

public async Task<List<PO>> FetchPO(string plant)
{
    using IDbConnection dbConnection = new SnowflakeDbConnection();
            dbConnection.ConnectionString = _configuration.GetConnectionString(Constants.ConnectionStrings.SnowflakeConnectionString);

    List<PO> po= (await dbConnection.QueryAsync<PO>($"select * from {Constants.Snowflake.Views.PO} ")).ToList();

    return po;
}
1 Answers

At the moment the .NET driver doesn't supports CLIENT_SESSION_KEEP_ALIVE as you mentioned.

One way for keeping the session alive would be to send a simple query before the session expires (by default when no activity the session expires after 4 hours), like a SELECT 1. But be aware if you have many clients using this it may impact your Cloud Services billing.

As for CLIENT_SESSION_KEEP_ALIVE in .NET you can create an Idea for this and the more customers need it the more chances to get it implemented.

Related