I can't connect my C# application to SQL database using mobile data.
If I try to connect to DB using my home Wi-Fi, it works normally.
When I try, I get this error:
MySqlConnector.MySqlException (0x80004005): Connect Timeout expired. ---> MySqlConnector.MySqlException (0x80004005): Unable to connect to any of the specified MySQL hosts.
at MySqlConnector.Core.ServerSession.ConnectAsync (MySqlConnector.Core.ConnectionSettings cs, MySqlConnector.MySqlConnection connection, System.Int32 startTickCount, MySqlConnector.Core.ILoadBalancer loadBalancer, MySqlConnector.Protocol.Serialization.IOBehavior ioBehavior, System.Threading.CancellationToken cancellationToken) [0x002fb] in /_/src/MySqlConnector/Core/ServerSession.cs:437
at MySqlConnector.Core.ConnectionPool.ConnectSessionAsync (MySqlConnector.MySqlConnection connection, System.String logMessage, System.Int32 startTickCount, MySqlConnector.Protocol.Serialization.IOBehavior ioBehavior, System.Threading.CancellationToken cancellationToken) [0x000bc] in /_/src/MySqlConnector/Core/ConnectionPool.cs:367
at MySqlConnector.Core.ConnectionPool.GetSessionAsync (MySqlConnector.MySqlConnection connection, System.Int32 startTickCount, MySqlConnector.Protocol.Serialization.IOBehavior ioBehavior, System.Threading.CancellationToken cancellationToken) [0x00519] in /_/src/MySqlConnector/Core/ConnectionPool.cs:94
at MySqlConnector.Core.ConnectionPool.GetSessionAsync (MySqlConnector.MySqlConnection connection, System.Int32 startTickCount, MySqlConnector.Protocol.Serialization.IOBehavior ioBehavior, System.Threading.CancellationToken cancellationToken) [0x00767] in /_/src/MySqlConnector/Core/ConnectionPool.cs:124
at System.Threading.Tasks.ValueTask`1[TResult].get_Result () [0x0001b] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/Common/src/CoreLib/System/Threading/Tasks/ValueTask.cs:813
at MySqlConnector.MySqlConnection.CreateSessionAsync (MySqlConnector.Core.ConnectionPool pool, System.Int32 startTickCount, System.Nullable`1[T] ioBehavior, System.Threading.CancellationToken cancellationToken) [0x00120] in /_/src/MySqlConnector/MySqlConnection.cs:919
at MySqlConnector.MySqlConnection.CreateSessionAsync (MySqlConnector.Core.ConnectionPool pool, System.Int32 startTickCount, System.Nullable`1[T] ioBehavior, System.Threading.CancellationToken cancellationToken) [0x002f6] in /_/src/MySqlConnector/MySqlConnection.cs:941
at System.Threading.Tasks.ValueTask`1[TResult].get_Result () [0x0001b] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/Common/src/CoreLib/System/Threading/Tasks/ValueTask.cs:813
at MySqlConnector.MySqlConnection.OpenAsync (System.Nullable`1[T] ioBehavior, System.Threading.CancellationToken cancellationToken) [0x001c7] in /_/src/MySqlConnector/MySqlConnection.cs:425
at MySqlConnector.MySqlConnection.Open () [0x00000] in /_/src/MySqlConnector/MySqlConnection.cs:373
And this is my Server string:
"Server=xxx;Port=3306;Database=xxx;Uid=xxx;Password=xxx.;Convert Zero Datetime=True;"
Why I can connect to my DB only using Wi-Fi connection and not using mobile data?
SOLUTION: set the outbound of group security as 0.0.0.0/0
I'm using Amazon RDS as host.
The solution was edit the outbound role of db group security and set the IP: 0.0.0.0/0 in order to accept all IP.
Related
I have Postgres running on Docker, I'm trying to update the DB with EntityFramework and I get an error in the Package Manager Console: Failed to connect to 172.17.0.2:5432. The postgres was created directly in Docker Desktop app.
PM> Update-Database
Build started...
Build succeeded.
Npgsql.NpgsqlException (0x80004005): Failed to connect to 172.17.0.2:5432
---> System.TimeoutException: Timeout during connection attempt
at Npgsql.Internal.NpgsqlConnector.Connect(NpgsqlTimeout timeout)
at Npgsql.Internal.NpgsqlConnector.Connect(NpgsqlTimeout timeout)
at Npgsql.Internal.NpgsqlConnector.RawOpen(SslMode sslMode, NpgsqlTimeout timeout, Boolean async, CancellationToken cancellationToken, Boolean isFirstAttempt)
at Npgsql.Internal.NpgsqlConnector.<Open>g__OpenCore|208_1(NpgsqlConnector conn, SslMode sslMode, NpgsqlTimeout timeout, Boolean async, CancellationToken cancellationToken, Boolean isFirstAttempt)
at Npgsql.Internal.NpgsqlConnector.Open(NpgsqlTimeout timeout, Boolean async, CancellationToken cancellationToken)
at Npgsql.UnpooledDataSource.Get(NpgsqlConnection conn, NpgsqlTimeout timeout, Boolean async, CancellationToken cancellationToken)
at Npgsql.NpgsqlConnection.<Open>g__OpenAsync|45_0(Boolean async, CancellationToken cancellationToken)
at Npgsql.NpgsqlConnection.Open()
at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.OpenDbConnection(Boolean errorsExpected)
at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.OpenInternal(Boolean errorsExpected)
at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.Open(Boolean errorsExpected)
at Npgsql.EntityFrameworkCore.PostgreSQL.Storage.Internal.NpgsqlDatabaseCreator.Exists(Boolean async, CancellationToken cancellationToken)
at Npgsql.EntityFrameworkCore.PostgreSQL.Storage.Internal.NpgsqlDatabaseCreator.Exists(Boolean async, CancellationToken cancellationToken)
at Npgsql.EntityFrameworkCore.PostgreSQL.Storage.Internal.NpgsqlDatabaseCreator.Exists()
at Microsoft.EntityFrameworkCore.Migrations.HistoryRepository.Exists()
at Microsoft.EntityFrameworkCore.Migrations.Internal.Migrator.Migrate(String targetMigration)
at Microsoft.EntityFrameworkCore.Design.Internal.MigrationsOperations.UpdateDatabase(String targetMigration, String connectionString, String contextType)
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.UpdateDatabaseImpl(String targetMigration, String connectionString, String contextType)
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.UpdateDatabase.<>c__DisplayClass0_0.<.ctor>b__0()
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.Execute(Action action)
Failed to connect to 172.17.0.2:5432
Program.cs
builder.Services.AddDbContext<AppDbContext>(options =>
options.UseNpgsql(builder.Configuration.GetConnectionString("AppDbConnection")));
Connection string in appsettings.json
"ConnectionStrings": {
"AppDbConnection": "Host=172.17.0.2; Port=5432; Database=MyNewDb; Username=postgres; Password=postgrespw;"
}
I checked on what ip and port the container is running:
❯ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
f9b7485b6473 dpage/pgadmin4 "/entrypoint.sh" 59 minutes ago Up 58 minutes 443/tcp, 0.0.0.0:5050->80/tcp pgadmin4
f1422d67616e postgres:latest "docker-entrypoint.s…" About an hour ago Up About an hour 0.0.0.0:49153->5432/tcp postgres-O7pV
❯ docker inspect f1422 | grep IPAddress
"SecondaryIPAddresses": null,
"IPAddress": "172.17.0.2",
"IPAddress": "172.17.0.2",
❯ docker network ls
NETWORK ID NAME DRIVER SCOPE
5a77b8e238bc bridge bridge local
aae4971464e6 host host local
59c3a23f98d4 none null local
Have some VStests running on Ubuntu 18.04 using Mono
-7cdd897b68-j95rh:/# mono --version
Mono JIT compiler version 6.12.0.182 (tarball Tue Jun 14 22:29:01 UTC 2022)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
TLS: __thread
SIGSEGV: altstack
Notifications: epoll
Architecture: amd64
Disabled: none
Misc: softdebug
Interpreter: yes
LLVM: yes(610)
Suspend: hybrid
GC: sgen (concurrent by default)
The tests are trying to connect to sharepoint by sending HTTP requests.
However, we get the following error.
System.Net.Http.HttpRequestException: The SSL connection could not be established, see inner exception. ---> System.Security.Authentication.AuthenticationException: Authentication failed, see inner exception. ---> Mono.Btls.MonoBtlsException: Ssl error:1000007d:SSL routines:OPENSSL_internal:CERTIFICATE_VERIFY_FAILED
at /build/mono-6.12.0.182/external/boringssl/ssl/handshake_client.c:1132
Stack Trace:
at Mono.Btls.MonoBtlsContext.ProcessHandshake () [0x00048] in <33b19a7ad5234d94abf4fd9b47566616>:0
at Mono.Net.Security.MobileAuthenticatedStream.ProcessHandshake (Mono.Net.Security.AsyncOperationStatus status, System.Boolean renegotiate) [0x000da] in <33b19a7ad5234d94abf4fd9b47566616>:0
at (wrapper remoting-invoke-with-check) Mono.Net.Security.MobileAuthenticatedStream.ProcessHandshake(Mono.Net.Security.AsyncOperationStatus,bool)
at Mono.Net.Security.AsyncHandshakeRequest.Run (Mono.Net.Security.AsyncOperationStatus status) [0x00006] in <33b19a7ad5234d94abf4fd9b47566616>:0
at Mono.Net.Security.AsyncProtocolRequest.ProcessOperation (System.Threading.CancellationToken cancellationToken) [0x000fc] in <33b19a7ad5234d94abf4fd9b47566616>:0
--- End of inner exception stack trace ---
at Mono.Net.Security.MobileAuthenticatedStream.ProcessAuthentication (System.Boolean runSynchronously, Mono.Net.Security.MonoSslAuthenticationOptions options, System.Threading.CancellationToken cancellationToken) [0x00262] in <33b19a7ad5234d94abf4fd9b47566616>:0
at System.Net.Http.ConnectHelper.EstablishSslConnectionAsyncCore (System.IO.Stream stream, System.Net.Security.SslClientAuthenticationOptions sslOptions, System.Threading.CancellationToken cancellationToken) [0x000c3] in <58d2f9f618534cba97faacbe0f54503d>:0
--- End of inner exception stack trace ---
at System.Net.Http.ConnectHelper.EstablishSslConnectionAsyncCore (System.IO.Stream stream, System.Net.Security.SslClientAuthenticationOptions sslOptions, System.Threading.CancellationToken cancellationToken) [0x00102] in <58d2f9f618534cba97faacbe0f54503d>:0
at System.Net.Http.HttpConnectionPool.CreateConnectionAsync (System.Net.Http.HttpRequestMessage request, System.Threading.CancellationToken cancellationToken) [0x00322] in <58d2f9f618534cba97faacbe0f54503d>:0
at System.Net.Http.HttpConnectionPool.WaitForCreatedConnectionAsync (System.Threading.Tasks.ValueTask`1[TResult] creationTask) [0x000a2] in <58d2f9f618534cba97faacbe0f54503d>:0
at System.Net.Http.HttpConnectionPool.SendWithRetryAsync (System.Net.Http.HttpRequestMessage request, System.Boolean doRequestAuth, System.Threading.CancellationToken cancellationToken) [0x00089] in <58d2f9f618534cba97faacbe0f54503d>:0
at System.Net.Http.RedirectHandler.SendAsync (System.Net.Http.HttpRequestMessage request, System.Threading.CancellationToken cancellationToken) [0x000ba] in <58d2f9f618534cba97faacbe0f54503d>:0
at System.Net.Http.HttpClient.FinishSendAsyncBuffered (System.Threading.Tasks.Task`1[TResult] sendTask, System.Net.Http.HttpRequestMessage request, System.Threading.CancellationTokenSource cts, System.Boolean disposeCts) [0x0017e] in <58d2f9f618534cba97faacbe0f54503d>:0
Tried following https://www.mono-project.com/docs/faq/security/ and cert-sync
I'm running ChromeDriver (v89) & Selenium 4.1 on MacOS and am getting an exception when instantiating ChromeDriver by passing an instance of ChromeDriverService and these options:
{
"browserName": "chrome",
"goog:chromeOptions": {
"args": [
"no-sandbox"
],
"debuggerAddress": "127.0.0.1:8080"
}
}
Details of the exception:
OpenQA.Selenium.WebDriverException: The HTTP request to the remote WebDriver server for URL http://localhost:49385/session timed out after 60 seconds.
---> System.Threading.Tasks.TaskCanceledException: The operation was canceled.
---> System.IO.IOException: Unable to read data from the transport connection: Operation canceled.
---> System.Net.Sockets.SocketException (89): Operation canceled
--- End of inner exception stack trace ---
at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.ThrowException(SocketError error, CancellationToken cancellationToken)
at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.GetResult(Int16 token)
at System.Net.Http.HttpConnection.FillAsync()
at System.Net.Http.HttpConnection.ReadNextResponseHeaderLineAsync(Boolean foldedHeadersAllowed)
at System.Net.Http.HttpConnection.SendAsyncCore(HttpRequestMessage request, CancellationToken cancellationToken)
--- End of inner exception stack trace ---
at System.Net.Http.HttpConnection.SendAsyncCore(HttpRequestMessage request, CancellationToken cancellationToken)
at System.Net.Http.HttpConnectionPool.SendWithNtConnectionAuthAsync(HttpConnection connection, HttpRequestMessage request, Boolean doRequestAuth, CancellationToken cancellationToken)
at System.Net.Http.HttpConnectionPool.SendWithRetryAsync(HttpRequestMessage request, Boolean doRequestAuth, CancellationToken cancellationToken)
at System.Net.Http.RedirectHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
at System.Net.Http.HttpClient.FinishSendAsyncBuffered(Task1 sendTask, HttpRequestMessage request, CancellationTokenSource cts, Boolean disposeCts) at OpenQA.Selenium.Remote.HttpCommandExecutor.MakeHttpRequest(HttpRequestInfo requestInfo) at OpenQA.Selenium.Remote.HttpCommandExecutor.Execute(Command commandToExecute) --- End of inner exception stack trace --- at OpenQA.Selenium.Remote.HttpCommandExecutor.Execute(Command commandToExecute) at OpenQA.Selenium.Remote.DriverServiceCommandExecutor.Execute(Command commandToExecute) at OpenQA.Selenium.WebDriver.Execute(String driverCommandToExecute, Dictionary2 parameters)
at OpenQA.Selenium.WebDriver.StartSession(ICapabilities desiredCapabilities)
at OpenQA.Selenium.WebDriver..ctor(ICommandExecutor executor, ICapabilities capabilities)
at OpenQA.Selenium.Chromium.ChromiumDriver..ctor(ChromiumDriverService service, ChromiumOptions options, TimeSpan commandTimeout)
at OpenQA.Selenium.Chrome.ChromeDriver..ctor(ChromeDriverService service, ChromeOptions options, TimeSpan commandTimeout)
at OpenQA.Selenium.Chrome.ChromeDriver..ctor(ChromeDriverService service, ChromeOptions options)
The same code worked fine on Windows, so I dare to say that it's been tested.
Libraries I'm using:
OpenQA,/Users/mbaas/.nuget/packages/Selenium.WebDriver/4.1.0/lib/netstandard2.1/WebDriver.dll
OpenQA.Selenium,/Users/mbaas/.nuget/packages/Selenium.WebDriver/4.1.0/lib/netstandard2.1/WebDriver.dll
OpenQA.Selenium.Chrome,/Users/mbaas/.nuget/packages/Selenium.WebDriver/4.1.0/lib/netstandard2.1/WebDriver.dll
Newtonsoft.Json,/Users/mbaas/.nuget/packages/Newtonsoft.Json/12.0.3/lib/netstandard2.0/Newtonsoft.Json.dll
OpenQA.Selenium.Support,/Users/mbaas/.nuget/packages/Selenium.Support/4.1.0/lib/netstandard2.1/WebDriver.Support.dll
OpenQA.Selenium.Support.UI,/Users/mbaas/.nuget/packages/Selenium.Support/4.1.0/lib/netstandard2.1/WebDriver.Support.dll
I think I found the answer: the plan was to launch a separate process beforehand that runs CEF and the site - but that step failed, so there is no browser it could talk to.
My bad - I should have checked that before posting here.
I have a Azure function which gets XML files and sends it to Event Grid after splitting XML based on batch size. There is another Event Grid Trigger function which gets this message from and does the processing and continues the flow of application. For large xml files also it is working as expected.
But sometimes I get an error on intermittent basic. When I analyze the issue, I see failure in the event grid. If I reprocess the same file again it works. So it is not the issue with the file I am processing.
As per the logs I am getting error message as below for the line of code which send message to event grid.
Is it possible that this happening due to some limitations of event grid but from error message it says no such host is known? How i can troubleshoot this. What may be the reason for the failures.
System.AggregateException: One or more errors occurred. (No such host is known.)
---> System.Net.Http.HttpRequestException: No such host is known.
---> System.Net.Sockets.SocketException (11001): No such host is known.
at System.Net.Http.ConnectHelper.ConnectAsync(String host, Int32 port, CancellationToken cancellationToken)
--- End of inner exception stack trace ---
at System.Net.Http.ConnectHelper.ConnectAsync(String host, Int32 port, CancellationToken cancellationToken)
at System.Net.Http.HttpConnectionPool.ConnectAsync(HttpRequestMessage request, Boolean allowHttp2, CancellationToken cancellationToken)
at System.Net.Http.HttpConnectionPool.CreateHttp11ConnectionAsync(HttpRequestMessage request, CancellationToken cancellationToken)
at System.Net.Http.HttpConnectionPool.GetHttpConnectionAsync(HttpRequestMessage request, CancellationToken cancellationToken)
at System.Net.Http.HttpConnectionPool.SendWithRetryAsync(HttpRequestMessage request, Boolean doRequestAuth, CancellationToken cancellationToken)
at System.Net.Http.RedirectHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
at System.Net.Http.DiagnosticsHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
at Microsoft.Extensions.Http.Logging.LoggingHttpMessageHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
at Microsoft.Extensions.Http.Logging.LoggingScopeHttpMessageHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
at System.Net.Http.HttpClient.FinishSendAsyncBuffered(Task`1 sendTask, HttpRequestMessage request, CancellationTokenSource cts, Boolean disposeCts)
at PwC.Bos.Al.Common.Data.Service.CallHttpClientFactory.MyService.GetPage(String _data, String URL, String ContentType, HttpMethod methodType, Dictionary`2 headers)
I've met a strange problem recently. I have Xamarin Android project, every time I call http request using real device with mobile data, it will throw me HttpRequestException, if I am using WiFi, everything is good.
My code of calling HttpRequest is
var url = "some/parameter"
var client = new HttpClient();
client.BaseAddress = new Uri("http://xxx.xxx.xxx");
await client.GetAsync(url);
Following is the detail of HttpRequestException:
Inner Exception: {System.Net.Sockets.SocketException (0x80004005): No such host is known at System.Net.Http.ConnectHelper.ConnectAsync (System.String host, System.Int32 port, System.Threading.CancellationToken cancellationToken) [0x000c8] in /Users/builder/jenkins/workspace/a…}
Error Code: 11001
Message: No such host is known
SocketErrorCode: HostNotFound
StackTrace as below:
at System.Net.Http.ConnectHelper.ConnectAsync (System.String host, System.Int32 port, System.Threading.CancellationToken cancellationToken) [0x00180] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/ConnectHelper.cs:84
at System.Threading.Tasks.ValueTask`1[TResult].get_Result () [0x0001b] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/Common/src/CoreLib/System/Threading/Tasks/ValueTask.cs:813
at System.Net.Http.HttpConnectionPool.CreateConnectionAsync (System.Net.Http.HttpRequestMessage request, System.Threading.CancellationToken cancellationToken) [0x000ea] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpConnectionPool.cs:385
at System.Threading.Tasks.ValueTask`1[TResult].get_Result () [0x0001b] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/Common/src/CoreLib/System/Threading/Tasks/ValueTask.cs:813
at System.Net.Http.HttpConnectionPool.WaitForCreatedConnectionAsync (System.Threading.Tasks.ValueTask`1[TResult] creationTask) [0x000a2] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpConnectionPool.cs:543
at System.Threading.Tasks.ValueTask`1[TResult].get_Result () [0x0001b] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/Common/src/CoreLib/System/Threading/Tasks/ValueTask.cs:813
at System.Net.Http.HttpConnectionPool.SendWithRetryAsync (System.Net.Http.HttpRequestMessage request, System.Boolean doRequestAuth, System.Threading.CancellationToken cancellationToken) [0x0003f] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpConnectionPool.cs:284
at System.Net.Http.RedirectHandler.SendAsync (System.Net.Http.HttpRequestMessage request, System.Threading.CancellationToken cancellationToken) [0x00070] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/RedirectHandler.cs:32
at System.Net.Http.HttpClient.FinishSendAsyncBuffered (System.Threading.Tasks.Task`1[TResult] sendTask, System.Net.Http.HttpRequestMessage request, System.Threading.CancellationTokenSource cts, System.Boolean disposeCts) [0x0017e] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/System.Net.Http/src/System/Net/Http/HttpClient.cs:506
I have included these in my Android.Manifest.xml
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
My mobile data connection is good as I still can access other app using mobile data, I have no idea why there is difference between using WiFi and mobile data especially HttpRequest? What can I do to fix this problem in my project? Any help?