首页 > 解决方案 > 超时无法从传输连接读取数据

问题描述

从 2020 年 2 月 2 日星期六上午 10 点左右开始,我们的 EC2 实例和运行 MySQL 5.6.44 的 RDS 实例之间出现了随机间歇性连接问题。

我们的 EC2 实例正在运行 Windows 2012 Server R2。我们有 ASMX 和 WCF Web 服务,它们都遇到了这个问题。

每个服务器对数据库进行不同的调用。

连接问题不仅与一次数据库调用/查询有关,而且自 2020 年 1 月 24 日以来没有部署任何应用程序或数据库更改。此外,我们没有看到任何过多的指标,如连接、CPU 等。这些都出现了与过去 2 周相比处于平均水平。

我尝试重新启动所有实例,包括 RDS 实例。但仍然收到这些错误。

一些示例例外都是随机的。一些查询是非常简单的SELECT语句,只返回 1 行数据。

System.TimeoutException:无法从传输连接中读取数据:连接尝试失败,因为连接方一段时间后没有正确响应,或者连接失败,因为连接的主机没有响应。---> System.IO.IOException: Unable to read data from the transport connection: 连接尝试失败,因为连接方在一段时间后没有正确响应,或者建立连接失败,因为连接的主机没有响应。---> System.Net.Sockets.SocketException: 连接尝试失败,因为连接方一段时间后没有正确响应,或建立连接失败,因为连接的主机没有响应

MySql.Data.MySqlClient.MySqlException (0x80004005):超时。操作完成前超时时间已过或服务器没有响应。---> System.TimeoutException: Unable to read data from the transport connection: 连接尝试失败,因为连接方一段时间后没有正确响应,或者建立连接失败,因为连接的主机没有响应。---> System.IO.IOException: Unable to read data from the transport connection: 连接尝试失败,因为连接方在一段时间后没有正确响应,或者建立连接失败,因为连接的主机没有响应。---> System.Net.Sockets.SocketException:

error host="WIN-H7RM59S7UK7" type="System.Exception"
message="Timeout expired. 在操作完成之前超时时间已过或服务器没有响应。requestGuid: db2badaf-8f17-4181-8e59-cbe656271491"
source="ProjectName" detail="System.Exception: Timeout expired。在操作完成之前超时时间已过或服务器没有响应。requestGuid: db2badaf-8f17-4181-8e59-cbe656271491 at ProjectName.BookingServices.GetExistingResponsiveBookingPage( c:\VSProjects\ProjectName\ProjectName\BookingServices.asmx.cs:line 158" time="2020-02-05T09:07:17.7473532Z" /> 中的字符串 requestId、字符串cultureCode、字符串优惠券)

error host="WIN-H7RM59S7UK7"
type="System.Net.Sockets.SocketException" message="连接尝试失败,因为连接方在一段时间后没有正确响应,或者连接失败,因为连接主机失败响应“源=“系统”
detail="System.TimeoutException: Unable to read data from the transport connection: 连接尝试失败,因为连接方在一段时间后没有正确响应,或者建立连接失败,因为连接的主机没有响应。---> System.IO.IOException: Unable to read data from the transport connection: 连接尝试失败,因为连接方在一段时间后没有正确响应,或者建立连接失败,因为连接的主机没有响应。--->系统.Net.Sockets.SocketException:连接尝试失败,因为连接方在一段时间后没有正确响应,或者连接失败,因为连接的主机在 System.Net.Sockets.NetworkStream.Read(Byte[]缓冲,Int32 偏移量,Int32 大小)---内部异常堆栈跟踪结束---在 MySql.Data.Common.MyNetworkStream.Read 的 System.Net.Sockets.NetworkStream.Read(Byte[] 缓冲区,Int32 偏移量,Int32 大小) (Byte[] buffer, Int32 offset, Int32 count) --- 内部异常堆栈跟踪结束 --- 在 MySql.Data.Common.MyNetworkStream.Read(Byte[] buffer, Int32 offset, Int32 count) 在 MySql.Data .MySqlClient.TimedStream.Read(Byte[] buffer, Int32 offset, Int32 count) at System.IO.BufferedStream.Read(Byte[] array, Int32 offset, Int32 count) at MySql.Data.MySqlClient.MySqlStream.ReadFully(Stream流,字节 [] 缓冲区,Int32 偏移量,Int32 计数)在 MySql.Data.MySqlClient.MySqlStream.ReadPacket() 在 MySql.Data.MySqlClient.NativeDriver 的 MySql.Data.MySqlClient.MySqlStream.LoadPacket()。ReadOk(布尔读取)
在 MySql.Data.MySqlClient.MySqlConnection.ChangeDatabase(String databaseName) 在 MySql.Data.MySqlClient.MySqlConnection.Open() 在 TMSShared.MySQL.General.CallMysqlSPReturnReader(String sName, List1 oParameters, Action1 fn) 在 c:\VSProjects\TMSShared\TMSShared\MySQL\General.cs: 第 163 行 API.DAL.POCO.Availability.MealPlan.GetAllHotelMealPlanBySupplierId(Int32 iSupplierId) 在 c:\VSProjects\ProjectNameAPI\API\DAL\POCO \Availability\MealPlan.cs:API.DAL.POCO.Availability.GlobalAvailability.Get(GlobalAvailabilityRequest globalAvailabilityRequest) 中的第 227 行:\VSProjects\ProjectName\API\DAL\POCO\Availability\GlobalAvailability.cs:API 中的第 409 行。 DAL.BusinessLogic.Request.GlobalAvailability(GlobalAvailabilityRequest globalAvailabilityRequest) 在 c:\VSProjects\ProjectName\API\DAL\BusinessLogic\Request.cs:line 463"
time="2020-02-05T09:52:19.6013482Z" />

error host="WIN-H7RM59S7UK7"
type="System.Threading.ThreadAbortException" message="线程被中止。" 来源="MySql.Data"
detail="System.Threading.ThreadAbortException: 线程被中止。在 MySql.Data.Common.MyNetworkStream.HandleOrRethrowException(Exception e) 在 MySql.Data.Common.MyNetworkStream.Read(Byte[] 缓冲区,Int32 偏移量,Int32 计数)在 MySql.Data.MySqlClient.TimedStream.Read(Byte[] buffer, Int32 offset, Int32 count) 在 System.IO.BufferedStream.Read(Byte[] array, Int32 offset, Int32 count) 在 MySql.Data.MySqlClient.MySqlStream .ReadFully(Stream stream, Byte[] buffer, Int32 offset, Int32 count) 在 MySql.Data.MySqlClient.MySqlStream.LoadPacket() 在 MySql.Data.MySqlClient.MySqlStream.ReadPacket() 在 MySql.Data.MySqlClient.NativeDriver。在 MySql.Data.MySqlClient.Driver.NextResult(Int32 statementId,布尔力) 在 MySql.Data.MySqlClient.MySqlDataReader.NextResult() 在 MySql.Data.MySqlClient.MySqlCommand.ExecuteReader(CommandBehavior 行为) 在 TMSShared.MySQL.General.CallMysqlSPReturnReader(String sName, List1 oParameters, Action1 fn) 在 c:\VSProjects\TMSShared\TMSShared\MySQL\General.cs:第 163 行,位于 c:\VSProjects\TMSShared\TMSShared\Utils\Message 中的 TMSShared.Utils.Message.GetLoginMessage(LoginMessage iStatusCode, LanguageCultureName languageCultureName)。 c:\VSProjects\ProjectName\API\DAL\APIUser.cs:API.DAL.APIUser.CheckCredentials 的第 170 行(字符串 sEmail,字符串 sPass,字符串 sUserIP,Int32 iUserType):API.HotelAPI.PostRoomUpdate 的第 107 行( ) 在 c:\VSProjects\ProjectName\API\Service.asmx.cs:line 97"
time="2020-02-03T11:10:18.2941871Z" />

编辑附加信息

该问题始于 2020 年 2 月 2 日 09:45:10,并且自此日期以来一直存在。在我们今天的 IIS HTTPErr 日志文件中,以下是我们开始遇到这些问题之前和之后的条目片段:

我已经屏蔽了外部 IP 地址

2020-02-02 09:36:28 *.*.*.* 62969 10.0.0.12 443 - Timer_ConnectionIdle
2020-02-02 09:38:29 *.*.*.* 58836 10.0.0.12 443 - Timer_ConnectionIdle
2020-02-02 09:41:44 *.*.*.* 38060 10.0.0.12 443 - Timer_ConnectionIdle
2020-02-02 09:43:35 *.*.*.* 39069 10.0.0.12 443 - Timer_ConnectionIdle
2020-02-02 09:43:35 *.*.*.* 36349 10.0.0.12 443 - Timer_ConnectionIdle

然后当问题第一次出现时,我们看到

2020-02-02 09:45:10 *.*.*.* 53951 10.0.0.12 443 HTTP/1.1 POST /API/V1.04/AdvService.asmx/GetAdvGlobalAvailability - 1 Connection_Abandoned_By_ReqQueue mydomain.com+(API+V1.04)
2020-02-02 09:45:41 *.*.*.* 53967 10.0.0.12 443 HTTP/1.1 POST /API/V1.04/AdvService.asmx/GetAdvGlobalAvailability - 1 Connection_Abandoned_By_ReqQueue mydomain.com+(API+V1.04)
2020-02-02 09:46:04 *.*.*.* 53971 10.0.0.12 443 HTTP/1.1 POST /API/V1.04/AdvService.asmx/GetAdvGlobalAvailability - 1 Connection_Abandoned_By_ReqQueue mydomain.com+(API+V1.04)
2020-02-02 09:46:29 *.*.*.* 51898 10.0.0.12 443 HTTP/1.1 POST /API/V1.04/AdsHotelService.asmx/getRoomAvailability 503 1 AppOffline mydomain.com+(API+V1.04)
...
...
...
2020-02-02 12:47:26 *.*.*.* 64846 10.0.0.12 443 HTTP/1.1 POST /API/V1.04/AdsHotelService.asmx/getRoomAvailability 503 1 AppOffline mydomain.com+(API+V1.04)
2020-02-02 12:47:33 *.*.*.* 40169 10.0.0.12 443 HTTP/1.1 POST /API/V1.04/Service.asmx/PostRoomUpdate 503 1 AppOffline mydomain.com+(API+V1.04)
2020-02-02 12:47:33 *.*.*.* 18340 10.0.0.12 443 HTTP/1.1 POST /API/V1.04/AdsHotelService.asmx/getRoomAvailability 503 1 AppOffline mydomain.com+(API+V1.04)
2020-02-02 12:47:35 *.*.*.* 18426 10.0.0.12 443 HTTP/1.1 POST /API/V1.04/AdsHotelService.asmx/getRoomAvailability 503 1 AppOffline mydomain.com+(API+V1.04)
2020-02-02 12:47:38 *.*.*.* 18938 10.0.0.12 443 HTTP/1.1 POST /API/V1.04/AdsHotelService.asmx/getRoomAvailability 503 1 AppOffline mydomain.com+(API+V1.04)
2020-02-02 12:47:38 *.*.*.* 18950 10.0.0.12 443 HTTP/1.1 POST /API/V1.04/AdsHotelService.asmx/getRoomAvailability 503 1 AppOffline mydomain.com+(API+V1.04)
2020-02-02 12:47:40 *.*.*.* 19124 10.0.0.12 443 HTTP/1.1 POST /API/V1.04/AdsHotelService.asmx/getRoomAvailability 503 1 AppOffline mydomain.com+(API+V1.04)
2020-02-02 12:47:40 *.*.*.* 64424 10.0.0.12 443 HTTP/1.1 POST /API/V1.01/AdvService.asmx/GetAdvAvailability 503 1 Disabled mydomain.com+(API)
2020-02-02 12:56:07 *.*.*.* 38634 10.0.0.12 80 HTTP/1.0 GET / 404 - NotFound -
#Software: Microsoft HTTP API 2.0
#Version: 1.0
#Date: 2020-02-02 13:05:22
#Fields: date time c-ip c-port s-ip s-port cs-version cs-method cs-uri sc-status s-siteid s-reason s-queuename
2020-02-02 13:05:21 *.*.*.* 58945 10.0.0.12 443 - - - - - Timer_ConnectionIdle -
2020-02-02 13:05:21 *.*.*.* 58948 10.0.0.12 443 - - - - - Timer_ConnectionIdle -
2020-02-02 13:05:21 *.*.*.* 58944 10.0.0.12 443 - - - - - Timer_ConnectionIdle -
2020-02-02 13:05:26 *.*.*.* 58946 10.0.0.12 443 - - - - - Timer_ConnectionIdle -
2020-02-02 13:06:27 *.*.*.* 58984 10.0.0.12 443 - - - - - Timer_ConnectionIdle -
2020-02-02 13:06:31 *.*.*.* 38084 10.0.0.12 443 - - - - - Timer_ConnectionIdle -
2020-02-02 13:06:31 *.*.*.* 33065 10.0.0.12 443 - - - - - Timer_ConnectionIdle -
2020-02-02 13:09:23 *.*.*.* 46315 10.0.0.12 443 - - - - - Timer_ConnectionIdle -
2020-02-02 13:10:02 *.*.*.* 58386 10.0.0.12 443 - - - - - Timer_MinBytesPerSecond -
2020-02-02 13:13:48 *.*.*.* 58382 10.0.0.12 443 - - - - - Timer_MinBytesPerSecond -

我现在在日志文件中没有看到 503 错误,但是我们在运行 IIS 的 EC2 实例和我们的 RDS 数据库之间遇到了连接问题。

2020-02-04 09:00:26 *.*.*.* 45371 10.0.0.12 443 - - - - - Timer_ConnectionIdle -
2020-02-04 09:03:22 *.*.*.* 53461 10.0.0.12 443 - - - - - Timer_ConnectionIdle -
2020-02-04 09:04:07 *.*.*.* 55266 10.0.0.12 443 - - - - - Timer_ConnectionIdle -
2020-02-04 09:04:07 *.*.*.* 33402 10.0.0.12 443 - - - - - Timer_ConnectionIdle -
2020-02-04 09:04:07 *.*.*.* 48068 10.0.0.12 443 - - - - - Timer_ConnectionIdle -
2020-02-04 09:04:17 *.*.*.* 44998 10.0.0.12 443 - - - - - Timer_ConnectionIdle -
2020-02-04 09:06:38 *.*.*.* 38659 10.0.0.12 443 - - - - - Timer_ConnectionIdle -
2020-02-04 09:06:58 *.*.*.* 35861 10.0.0.12 443 - - - - - Timer_ConnectionIdle -

我不确定这个问题是否与 Windows、IIS、MySQL 或两个实例之间的连接有关。

标签: c#mysql.netamazon-web-servicesiis

解决方案


推荐阅读