The stack trace details:
System.Web.HttpUnhandledException (0x80004005): Exception of type 'System.Web.HttpUnhandledException' was thrown. ---> System.AggregateException: One or more errors occurred. ---> System.IO.IOException: Received an unexpected EOF or 0 bytes from the transport stream.
at System.Net.FixedSizeReader.ReadPacket(Byte[] buffer, Int32 offset, Int32 count)
at System.Net.Security.SslState.StartReadFrame(Byte[] buffer, Int32 readBytes, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.StartReceiveBlob(Byte[] buffer, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.CheckCompletionBeforeNextReceive(ProtocolToken message, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.ProcessReceivedBlob(Byte[] buffer, Int32 count, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.StartReceiveBlob(Byte[] buffer, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.CheckCompletionBeforeNextReceive(ProtocolToken message, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.ProcessReceivedBlob(Byte[] buffer, Int32 count, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.StartReceiveBlob(Byte[] buffer, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.CheckCompletionBeforeNextReceive(ProtocolToken message, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.ProcessReceivedBlob(Byte[] buffer, Int32 count, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.StartReceiveBlob(Byte[] buffer, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.CheckCompletionBeforeNextReceive(ProtocolToken message, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.ProcessReceivedBlob(Byte[] buffer, Int32 count, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.StartReceiveBlob(Byte[] buffer, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.CheckCompletionBeforeNextReceive(ProtocolToken message, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.ProcessReceivedBlob(Byte[] buffer, Int32 count, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.StartReceiveBlob(Byte[] buffer, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.CheckCompletionBeforeNextReceive(ProtocolToken message, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.ForceAuthentication(Boolean receiveFirst, Byte[] buffer, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.ProcessAuthentication(LazyAsyncResult lazyResult)
at MySql.Data.MySqlClient.NativeDriver.StartSSL()
at MySql.Data.MySqlClient.NativeDriver.Open()
at MySql.Data.MySqlClient.Driver.Open()
at MySql.Data.MySqlClient.Driver.Create(MySqlConnectionStringBuilder settings)
at MySql.Data.MySqlClient.MySqlPool.GetPooledConnection()
at MySql.Data.MySqlClient.MySqlPool.TryToGetDriver()
at MySql.Data.MySqlClient.MySqlPool.GetConnection()
at MySql.Data.MySqlClient.MySqlConnection.Open()
at WebAppClassLibrary.MySqlShell.ExecuteScalar(String query, MySqlConnection mySqlConnection, MySqlParameter[] mySqlParameters) in N:\webApp\WebAppClassLibrary\MySqlShell.cs:line 147
at WebAppClassLibrary.ServiceOperations.GetServiceType(Int32 login) in N:\webApp\WebAppClassLibrary\ServiceOperations.cs:line 57
at WebAppClassLibrary.PartnerDetailLibrary.GetAccountData(PartnerDetailAccount partnerDetailAccount, MySqlConnection mtInstaConnection, MySqlConnection secureConnection, MySqlParameter paramStartTime, MySqlParameter paramEndTime, Dictionary`2 lastActivity, Dictionary`2 balances, Boolean exactPeriod, Boolean allowProfit, Boolean allowEquity, Boolean allowAdditionalPercentFor, Boolean usingCache, Boolean IsCryptoOnly, Double minCommission, Boolean showAgent) in N:\webApp\WebAppClassLibrary\PartnerDetailLibrary.cs:line 40
at PartnerDetail.<>c_DisplayClass118_0.<FillDataGridByClients>b_1(Int32 i) in N:\webApp\WebApp\PartnerDetail.aspx.cs:line 0
at System.Threading.Tasks.Parallel.<>c_DisplayClass17_0`1.<ForWorker>b_1()
at System.Threading.Tasks.Task.InnerInvokeWithArg(Task childTask)
at System.Threading.Tasks.Task.<>c_DisplayClass176_0.<ExecuteSelfReplicating>b_0(Object )
— End of inner exception stack trace —
at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
at System.Threading.Tasks.Parallel.ForWorker[TLocal](Int32 fromInclusive, Int32 toExclusive, ParallelOptions parallelOptions, Action`1 body, Action`2 bodyWithState, Func`4 bodyWithLocal, Func`1 localInit, Action`1 localFinally)
at System.Threading.Tasks.Parallel.For(Int32 fromInclusive, Int32 toExclusive, ParallelOptions parallelOptions, Action`1 body)
at PartnerDetail.FillDataGridByClients(Int32 from, Int32 to) in N:\webApp\WebApp\PartnerDetail.aspx.cs:line 1129
at PartnerDetail.BtnSearchClick(Object sender, EventArgs e) in N:\webApp\WebApp\PartnerDetail.aspx.cs:line 566
at System.Web.UI.WebControls.Button.OnClick(EventArgs e)
at System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
---> (Inner Exception #0) System.IO.IOException: Received an unexpected EOF or 0 bytes from the transport stream.
at System.Net.FixedSizeReader.ReadPacket(Byte[] buffer, Int32 offset, Int32 count)
at System.Net.Security.SslState.StartReadFrame(Byte[] buffer, Int32 readBytes, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.StartReceiveBlob(Byte[] buffer, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.CheckCompletionBeforeNextReceive(ProtocolToken message, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.ProcessReceivedBlob(Byte[] buffer, Int32 count, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.StartReceiveBlob(Byte[] buffer, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.CheckCompletionBeforeNextReceive(ProtocolToken message, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.ProcessReceivedBlob(Byte[] buffer, Int32 count, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.StartReceiveBlob(Byte[] buffer, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.CheckCompletionBeforeNextReceive(ProtocolToken message, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.ProcessReceivedBlob(Byte[] buffer, Int32 count, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.StartReceiveBlob(Byte[] buffer, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.CheckCompletionBeforeNextReceive(ProtocolToken message, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.ProcessReceivedBlob(Byte[] buffer, Int32 count, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.StartReceiveBlob(Byte[] buffer, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.CheckCompletionBeforeNextReceive(ProtocolToken message, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.ProcessReceivedBlob(Byte[] buffer, Int32 count, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.StartReceiveBlob(Byte[] buffer, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.CheckCompletionBeforeNextReceive(ProtocolToken message, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.ForceAuthentication(Boolean receiveFirst, Byte[] buffer, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.ProcessAuthentication(LazyAsyncResult lazyResult)
at MySql.Data.MySqlClient.NativeDriver.StartSSL()
at MySql.Data.MySqlClient.NativeDriver.Open()
at MySql.Data.MySqlClient.Driver.Open()
at MySql.Data.MySqlClient.Driver.Create(MySqlConnectionStringBuilder settings)
at MySql.Data.MySqlClient.MySqlPool.GetPooledConnection()
at MySql.Data.MySqlClient.MySqlPool.TryToGetDriver()
at MySql.Data.MySqlClient.MySqlPool.GetConnection()
at MySql.Data.MySqlClient.MySqlConnection.Open()
at WebAppClassLibrary.MySqlShell.ExecuteScalar(String query, MySqlConnection mySqlConnection, MySqlParameter[] mySqlParameters) in N:\webApp\WebAppClassLibrary\MySqlShell.cs:line 147
at WebAppClassLibrary.ServiceOperations.GetServiceType(Int32 login) in N:\webApp\WebAppClassLibrary\ServiceOperations.cs:line 57
at WebAppClassLibrary.PartnerDetailLibrary.GetAccountData(PartnerDetailAccount partnerDetailAccount, MySqlConnection mtInstaConnection, MySqlConnection secureConnection, MySqlParameter paramStartTime, MySqlParameter paramEndTime, Dictionary`2 lastActivity, Dictionary`2 balances, Boolean exactPeriod, Boolean allowProfit, Boolean allowEquity, Boolean allowAdditionalPercentFor, Boolean usingCache, Boolean IsCryptoOnly, Double minCommission, Boolean showAgent) in N:\webApp\WebAppClassLibrary\PartnerDetailLibrary.cs:line 40
at PartnerDetail.<>c_DisplayClass118_0.<FillDataGridByClients>b_1(Int32 i) in N:\webApp\WebApp\PartnerDetail.aspx.cs:line 0
at System.Threading.Tasks.Parallel.<>c_DisplayClass17_0`1.<ForWorker>b_1()
at System.Threading.Tasks.Task.InnerInvokeWithArg(Task childTask)
at System.Threading.Tasks.Task.<>c_DisplayClass176_0.<ExecuteSelfReplicating>b_0(Object )<---
at System.Web.UI.Page.HandleError(Exception e)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
at System.Web.UI.Page.ProcessRequest()
at System.Web.UI.Page.ProcessRequest(HttpContext context)
at ASP.agentsdetalization_aspx.ProcessRequest(HttpContext context) in c:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\79e9f1d9\6267efd7\App_Web_fixgkyq0.4.cs:line 0
at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step)
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
I am getting this rear exception but surely approximately 1 or 2 times in every 1000 requests. Though I tried to rid this in different ways, but could not get any solution instead of dilemmas.
I went through this question similar to my exception, but there is no solution yet. I also found this question, but just fall in dilemma now what would be the solution for my exception. And I tried to write this piece of line in method Global.asax.cs/Application_BeginRequest():
ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;
Note: my application's target .NET framework version is 4.7, and I have to fix this exception in my application code. I don't have right to work on the server. So, please help me if I am in the correct way or not. Also, please ensure if this line of code is relevant to my exception. If this is correct, should I use bitwise shorthand operator '|=' in place '=' at the above line of code?
Thanks in advance.
UPDATE: Full stack trace and exception details added at the bottom of the code block as some persons asked to help to understand. Please note that, james-mead's answer doesn't work yet. I would like to ask more answers from experts to get rid of this exception. I am really stuck at this point.
Change:
To:
Obviously you need to run this code before making the first HTTP request. To make sure the most recent TLS version is used you need to try catch it. Something like this: