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
CodePudding user response:
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.
CodePudding user response:
There are quite a few possibilities of what could have gone wrong.
First, it is worth checking the firewall (security group) of your RDS instance. Maybe you haven't allowed connections from your mobile network IP.
If that doesn't help, try using a proxy/VPN, maybe your ISP is blocking access to RDS