Every time I try to connect to a snowflake database in .NET 6 using the Snowflake.Data NuGet package, I get a timeout after 120 seconds. I've tried it with all correct credentials in the connection string, as well as all incorrect credentials. No matter what the response is the same:
[2022-06-26T21:05:06.742Z] Snowflake.Data.Client.SnowflakeDbException (0x80004005): Error: Snowflake Internal Error: Unable to connect SqlState: 08006, VendorCode: 270001, QueryId:
[2022-06-26T21:05:06.743Z] ---> System.AggregateException: One or more errors occurred. (Error: Request reach its timeout. SqlState: , VendorCode: 270007, QueryId: )
My code setup looks like this to connect:
using (var conn = new SnowflakeDbConnection())
{
conn.ConnectionString = #"
ACCOUNT=<account>;
USER=<user>;
PASSWORD=<password>;
ROLE=<role>;
DB=<db>;
WAREHOUSE=<warehouse>";
_log.Information("Attempting connection to Snowflake...");
await conn.OpenAsync();
...
Every time after attempting to open the connection it hangs for 120 seconds then produces the above error. I've tried async and non-async as well as a bunch of different connection string properties. I also verified I was able to establish an outbound connection to another database with a regular SqlConnection and that worked with no issues. Not sure what could be going wrong.
Also ran the Snowcd connection diagnostic tool as descripted in the docs, results were all passing:
After much trial and error, adding the specific HOST value to the connection string was what fixed it for me. Specifying the full account with region for the ACCOUNT value did not work. Only when done under HOST. Although the GitHub documentation states that HOST is not required, specifying it with the region is the only thing that prevented timeouts on my end.
Related
I am trying to connect SAP HANA database in MVC, but I'm getting this error.
general error: database 'T' not connected
This is the code for connection:
using (HanaConnection sqlConnection = new HanaConnection("Server='192.168.0.13:30015'; UserName='S'; Password='E'; DATABASENAME='T'"))
{
sqlConnection.Open();
}
What could be the cause of this? I also tried changing my port to
30013
but got this error:
Connection failed (RTE:[89006] System call 'connect' failed, rc=10061:No connection could be made because the target machine actively refused it.
I can connect with this connection string using PHP.
It seems like there is no tenant database named 'T' available. If you have not configured this tenant, please try to omit the databaseName property and simply connect using
new HanaConnection("Server='192.168.0.13:30015'; UserName='S'; Password='E'")
Based on the error messages it seems that port 30015 is correct as the first error is originating from the database itself and the second is not.
I'm building a winform app that initially connects to a MongoDB server using Driver 2.10.
When I try and connect on my own machine everything works smooth, but when trying to install
clients on other computers via a msi file, the app crashes and I get the following:
ERROR - List of configured name servers must not be empty.
Parameter name: servers
at DnsClient.LookupClient.QueryInternal(DnsQuestion question, DnsQuerySettings queryOptions, IReadOnlyCollection`1 servers)
at DnsClient.LookupClient.Query(DnsQuestion question)
at MongoDB.Driver.Core.Configuration.ConnectionString.Resolve(Boolean resolveHosts)
at MongoDB.Driver.MongoUrl.Resolve(Boolean resolveHosts)
at MongoDB.Driver.MongoClientSettings.FromUrl(MongoUrl url)
at MongoDB.Driver.MongoClient..ctor(String connectionString)
at PaladinFormV2.MongoCRUD..ctor(String i_database)
at PaladinFormV2.Paladin..ctor(Boolean onboarding)
at PaladinFormV2.Program.Main()
I'm connecting through a connection string as follows:
MongoClient client = new MongoClient("mongodb+srv://[name]:[pass]#mcsamples-nwups.mongodb.net/test?retryWrites=true&w=majority");
What am I doing wrong and what information am I missing here to solve this?
Thanks
So after a long time trying to figure out what went wrong here, I came to the conclusion that using the '+srv' inside the connection string tries to resolve the DNS server on which your mongo instance is running, for clients using this it may cause the app to crash.
My fix was using a different connection string that does not use this prefix.
The info on connection string was taken from here https://docs.mongodb.com/manual/reference/connection-string/
Edit your connection string
From
`MongoClient client = new MongoClient("mongodb+srv://[name]:[pass]#mcsamples-nwups.mongodb.net/test?retryWrites=true&w=majority")`
To
`MongoClient client = new MongoClient("mongodb+srv://[name]:[pass]#mcsamples-nwups.mongodb.net/test")`
Also make sure you have internet connection to the cloud server
I am currently working on a project with someone. We are connecting to a oracle Database using the NuGet Package Oracle.ManagedDataAccess.Core.
We are connecting using a connection string that looks like this:
"User Id={this._dbUser};Password={this._dbPassword};Data Source={this._dbServer};"
The Parameters we pass on are correct we checked multiple times.
At first I got a Connection Timed out error which we fixed by adding persist security info=false;Connection Timeout=120; to the connection string.
At first it seemed to be working but then we encountered a new error.
This time it was saying:
Oracle communication: Connection to server could not be established or connection string not parsed
(Might not be 100% accurate because I had to translate it from German to English)
We could not find a solution for this error but we discovered that the error only gets thrown when we run the code on my machine. His is doing totally fine and can connect without any problems.
Could it be that I have some settings set on my machine that would prevent me from accessing the Database?
I am trying to access remote Oracle database using vpn connection. Using Oracle Sql Developer tool I am able to connect the database. But when I use ADO.NET model and Devart dotconnect for Oracle, it gives me error that server did not respond with in specified timeout interval.
Any one has face this issue?
UPDATE: I increases the timeout to 60s from default 15s. Now I am getting error:
ORA-12154: TNS:could not resolve the connect identifier specified
1st Issue is quiet common that server did not respond in defined time, increasing the connection time should do the trick. For this just append
;connection timeout = 60; (here time in seconds) to your connection string.
2nd After your update looks like Tns is not resolved properly:
You can check:
Do the tnsping (DB name in tns ora file). See you should not get any error and connection should be ok.
If problem still persist check your oracle home in registry have the correct path in case you have multiple client.
When I try to do the following code, the program hangs indefinitely. I don't know why and there seems to be other unanswered topics on the matter. Although, if the IP\website cannot be reached, then it works as intended.
private void DoStuff()
{
string connectionString = "Data Source=www.google.com;Connection Timeout=5";
using (SqlConnection connection = new SqlConnection(connectionString))
{
connection.Open(); //Hangs here indefinitely
Console.WriteLine("Test");
}
}
For example, if I set the connection string to
connectionString = "Data Source=www.nonexistentsite.com;Connection Timeout=5";
then it will throw an exception. How do I get it to throw an exception for an active site? ... Also google is just for testing purposes, obviously.
EDIT :
If I try to connect to an unreachable server name or IP address I WILL get this exception...
A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)
UPDATE :
After letting the program run for quite a while, it usually times out finally after 3-5 minutes and gives me the error I posted above. How can I get it to timeout quicker?
If you have set an FQDN (Fully Qualified Domain Name) for your Data Source such as example.com and the DNS server is unable to resolve this FQDN for a long time it is pretty obvious that your request will hang out. Make sure that the machine from which you are running your application can reach the SQL server and resolve it without any issues. Also you probably want to make sure that there is no firewall that might be blocking the request.
Another possible cause for those symptoms is if you have exhausted the connection pool of ADO.NET. This could happen if you have many slow SQL queries running in parallel, each of them taking a physical connection to the database. There is a limit in the number of available connections on this pool and when this limit is reached the next call to connection.Open() might wait for an available connection to be returned to the pool.
Remark: you might also need to specify in your connection string how you want to authenticate against the SQL server. Checkout connectionstrings.com for more examples.
All this is to say that there is absolutely nothing wrong in the C# code you have posted in your question. It looks more like a network related problem that you could bring to the attention of your network administrators.
To get the connection to exit after a specified amount of time without success, you can use the Connection Timeout parameter in the connection string. The number you specify is in seconds, so for example, Connection Timeout=240 is equal to 240 seconds\60 seconds = 4 minutes.
Sample connection string:
<add name="MyConnectionString"
connectionString="
Data Source=MyServer\MSSQL2017;
Initial Catalog=MyDatabase;
Integrated Security=True;
Connection Timeout=10;"/>
In the above connection string, the Open() command will timeout after 10 seconds.