매우 실망스러운 문제가 예상되며 이유를 찾을 수 없습니다.제한 시간이 만료되었습니다 -> 지정된 MySQL 호스트에 연결할 수 없습니다.
MySQL 데이터베이스를 사용하는 Azure에서 호스팅되는 앱이 있습니다. Oracle (6.10.5)에서 MySQL.Data nuget을 사용하고 있습니다. 매우 자주 나는 지정된 MySQL 호스트 (24 시간당 12 개) 중 하나에 연결할 수 없음과 함께 제한 시간 만료 오류가 발생합니다.
Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.
Exception Details: MySql.Data.MySqlClient.MySqlException: Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.
스택 추적 :
Event code: 3005
Event message: An unhandled exception has occurred.
Event time: 22/12/2017 14:40:56
Event time (UTC): 22/12/2017 14:40:56
Event ID: 503190c80af54cdb87140fe1f808de22
Event sequence: 16
Event occurrence: 5
Event detail code: 0
Application information:
Application domain: /LM/W3SVC/41351921/ROOT-1-131584264107173868
Trust level: Full
Application Virtual Path:/
Application Path: D:\home\site\wwwroot\
Machine name: RD00155D58C141
Process information:
Process ID: 10784
Process name: w3wp.exe
Account name: IIS APPPOOL\xxxx
Exception information:
Exception type: MySqlException
Exception message: Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.
at MySql.Data.Common.StreamCreator.GetTcpStream(MySqlConnectionStringBuilder settings)
at MySql.Data.Common.StreamCreator.GetStream(MySqlConnectionStringBuilder settings)
at MySql.Data.MySqlClient.NativeDriver.Open()
Request information:
Request URL: http://xxxxx.azurewebsites.net/
Request path:/
User host address: xx.xxx.xxx.xx
User: xxxxx
Is authenticated: True
Authentication Type: ApplicationCookie
Thread account name: IIS APPPOOL\xxxx
Thread information:
Thread ID: 35
Thread account name: IIS APPPOOL\xxxx
Is impersonating: False
Stack trace: at MySql.Data.Common.StreamCreator.GetTcpStream(MySqlConnectionStringBuilder settings)
at MySql.Data.Common.StreamCreator.GetStream(MySqlConnectionStringBuilder settings)
at MySql.Data.MySqlClient.NativeDriver.Open()
내 로컬 컴퓨터에서이 오류를 트리거 할 수 없습니다
[MySqlException (0x80004005): Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.]
MySql.Data.Common.StreamCreator.GetTcpStream(MySqlConnectionStringBuilder settings) +177
MySql.Data.Common.StreamCreator.GetStream(MySqlConnectionStringBuilder settings) +37
MySql.Data.MySqlClient.NativeDriver.Open() +55
[MySqlException (0x80004005): Unable to connect to any of the specified MySQL hosts.]
MySql.Data.MySqlClient.NativeDriver.Open() +151
MySql.Data.MySqlClient.Driver.Open() +50
MySql.Data.MySqlClient.Driver.Create(MySqlConnectionStringBuilder settings) +225
MySql.Data.MySqlClient.MySqlPool.CreateNewPooledConnection() +15
MySql.Data.MySqlClient.MySqlPool.GetPooledConnection() +288
MySql.Data.MySqlClient.MySqlPool.TryToGetDriver() +93
MySql.Data.MySqlClient.MySqlPool.GetConnection() +65
MySql.Data.MySqlClient.MySqlConnection.Open() +629
SalesManager.Models.ConnectionClass.QueryExec() in C:\Users\Gabinet\Source\Repos\SalesManager\SalesManager\SalesManager\Models\Data\ConnectionClass.cs:39
SalesManager.Models.ProductDownload.GetStorageQuantity(Int32 id) in C:\Users\Gabinet\Source\Repos\SalesManager\SalesManager\SalesManager\Models\ProductDownload.cs:58
SalesManager.Controllers.SalesController.Index(String sortOrder, String df, String dt) in C:\Users\Gabinet\Source\Repos\SalesManager\SalesManager\SalesManager\Controllers\SalesController.cs:41
lambda_method(Closure , ControllerBase , Object[]) +194
System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters) +19
System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters) +169
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +27
System.Web.Mvc.Async.AsyncControllerActionInvoker.<BeginInvokeSynchronousActionMethod>b__39(IAsyncResult asyncResult, ActionInvocation innerInvokeState) +24
System.Web.Mvc.Async.WrappedAsyncResult`2.CallEndDelegate(IAsyncResult asyncResult) +31
System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +50
System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult) +33
System.Web.Mvc.Async.AsyncInvocationWithFilters.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3d() +50
System.Web.Mvc.Async.<>c__DisplayClass46.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3f() +228
System.Web.Mvc.Async.<>c__DisplayClass33.<BeginInvokeActionMethodWithFilters>b__32(IAsyncResult asyncResult) +15
System.Web.Mvc.Async.WrappedAsyncResult`1.CallEndDelegate(IAsyncResult asyncResult) +15
System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +50
System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethodWithFilters(IAsyncResult asyncResult) +35
System.Web.Mvc.Async.<>c__DisplayClass2b.<BeginInvokeAction>b__1c() +26
System.Web.Mvc.Async.<>c__DisplayClass21.<BeginInvokeAction>b__1e(IAsyncResult asyncResult) +100
System.Web.Mvc.Async.WrappedAsyncResult`1.CallEndDelegate(IAsyncResult asyncResult) +15
System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +50
System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult) +29
System.Web.Mvc.Controller.<BeginExecuteCore>b__1d(IAsyncResult asyncResult, ExecuteCoreState innerState) +15
System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +29
System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +50
System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +36
System.Web.Mvc.Controller.<BeginExecute>b__15(IAsyncResult asyncResult, Controller controller) +14
System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +22
System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +50
System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +27
System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.EndExecute(IAsyncResult asyncResult) +12
System.Web.Mvc.MvcHandler.<BeginProcessRequest>b__5(IAsyncResult asyncResult, ProcessRequestState innerState) +21
System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +29
System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +50
System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +29
System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +11
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +577
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +157
푸른 앱 통찰력은 제한 시간을 제공합니다. Azure에서 My SQL db에 대해 ping을 수행 할 수 있습니다. 자격증은 정상입니다. 로컬 컴퓨터에서 정상적으로 작동합니다.
연결 클래스 :
public static int GetStorageQuantity(int id)
{
if (id != 9999)
{
connection = new ConnectionClass();
string sql = "select quantity from ps_stock_available where id_product = @pId";
connection.MySqlQueryWithParam(sql, "@pId", id.ToString());
var dr = connection.QueryExec().Rows[0];
var quantity = Convert.ToInt32(dr["quantity"].ToString());
return quantity;
}
return 0;
}
내 생각은 내가 잘 알고 아니에요 연결 풀에 관련된 무언가를 놓치고 있다는 것입니다 : 실패
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using MySql.Data.MySqlClient;
namespace SalesManager.Models
{
public class ConnectionClass : IDisposable
{
private MySqlConnection _con;
private MySqlCommand _cmd;
private MySqlDataAdapter _da;
private DataTable _dt;
private string _constr =
"Server=mysqldb.com; Database=databaseName; Uid=database_user; Pwd=database_pass; Default Command Timeout=300000; ";
public ConnectionClass()
{
_con = new MySqlConnection(_constr);
}
public void MySqlQuery(string sqlquery)
{
_cmd = new MySqlCommand(sqlquery, _con);
}
public void MySqlQueryWithParam(string sqlquery, string paramName, string paramValue)
{
_cmd = new MySqlCommand(sqlquery, _con);
_cmd.Parameters.AddWithValue(paramName, paramValue);
}
public DataTable QueryExec()
{
_con.Open();
_da = new MySqlDataAdapter(_cmd);
_dt = new DataTable();
_da.Fill(_dt);
_con.Dispose();
return _dt;
}
public void NonQueryExec()
{
_con.Open();
_cmd.ExecuteNonQuery();
_con.Dispose();
}
public void Dispose()
{
_con.Close();
_con.Dispose();
}
}
}
방법.
어떤 이유 일 수 있습니다. 그 밖의 무엇을 확인할 수 있습니까?
귀하의 도움을 많이 주시면 감사하겠습니다. 이와 같은 경우에
이전 ConnectionClass 반복에서 "using"을 사용하고 있으며 같은 문제가 발생할 것으로 예상됩니다. 그러나 다시 시도 할 것입니다. 감사합니다 – beribazoo
정확히 같은 오류. 왜 그것이 로컬 컴퓨터에서 작동하고 Azure에서 실패하는지 이해할 수 없습니다. – beribazoo
Azure에서 작동합니까? 즉, 간헐적입니까? 매번? – Fenton