Related
I'm encountering an app pool timing out on one request and it always times out around 5 minutes. I've enabled tracing, but no Warning, Error, Critical events are being logged. There are also no events in the EventViewer. I enabled FailedReqLogging and set it to log any requests over 4 minutes 30 sec. I've found the following in the C:\inetpub\logs\FailedReqLogFiles\W3SVC2 directory:
What IIS setting do I change to accomidate this request? By the Failure Reason it's listed as TIME_TAKEN so I'm guessing the AppPool exceeded some time limit. What is that limit?
I also notice that the Final Status is listed at 200. That would mean I wouldn't see anything in the logs for Warning, Critical, or Fatal because it was logged as OK. Am I right on that assumption?
Below is a stack trace of the exception found in the client trace logs. Note there is no error shown in the servers trace log. What's odd is that there is multiple nested exceptions within, but none hold real value.
...
...
<Exception>
<ExceptionType>System.ServiceModel.CommunicationException, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</ExceptionType>
<Message>The underlying connection was closed: A connection that was expected to be kept alive was closed by the server.</Message>
<StackTrace>
at System.ServiceModel.Channels.HttpChannelUtilities.ProcessGetResponseWebException(WebException webException, HttpWebRequest request, HttpAbortReason abortReason)
at System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
at System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout)
at System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message message, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at OSI.Framework.ServiceContracts.IWCFObjectDirectorWebService.Fetch(Byte[] serializedObjectRequest)
at OSI.Framework.WCF.Director.WCFWebObjectDirectorProxy.Fetch(Byte[] serializedObjectRequest)
at OSI.Framework.WCF.Director.WCFWebObjectDirector.Fetch(Object criteria)
at ActvMonitorSystemBusiness.Views.ActvView.GetActvDetails(DateTime fromDate, DateTime thruDate, String userGrpCd, String userCatCd, String userMajorCd, String userStatusCd, Nullable`1 userMemberNbr, Nullable`1 subjNbr, String searchBy, String dispActivity, Boolean showUncategorizedActv, Object[] fetchOptions)
at ActvMonitorSystemScreen.frmActvMonitor.Populate(Object sender, EventArgs e)
at ActvMonitorSystemScreen.frmActvMonitor.InitializeExtension(Object sender, EventArgs e)
at OpenSolutions.Sys.DnaExtensions.Client.SecureCoreBaseForm.Initialize(Object sender, EventArgs e)
at OSI.Base.Windows.Forms.BaseForm.OnShown(EventArgs e)
at OSI.Core.Windows.Forms.CoreBaseForm.OnShown(EventArgs e)
at ActvMonitorSystemScreen.SecureCoreBaseFormShim.OnShown(EventArgs e)
at System.Windows.Forms.Form.CallShownEvent()
at System.Windows.Forms.Control.InvokeMarshaledCallbackDo(ThreadMethodEntry tme)
at System.Windows.Forms.Control.InvokeMarshaledCallbackHelper(Object obj)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Windows.Forms.Control.InvokeMarshaledCallback(ThreadMethodEntry tme)
at System.Windows.Forms.Control.InvokeMarshaledCallbacks()
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.Form.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at OSI.Runtime.Program.Main(String[] args)
</StackTrace>
<ExceptionString>System.ServiceModel.CommunicationException: The underlying connection was closed: A connection that was expected to be kept alive was closed by the server. ---> System.Net.WebException: The underlying connection was closed: A connection that was expected to be kept alive was closed by the server. ---> System.IO.IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host. ---> System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host
at System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
--- End of inner exception stack trace ---
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
at System.Net.FixedSizeReader.ReadPacket(Byte[] buffer, Int32 offset, Int32 count)
at System.Net.Security._SslStream.StartFrameHeader(Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest)
at System.Net.Security._SslStream.StartReading(Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest)
at System.Net.Security._SslStream.ProcessRead(Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest)
at System.Net.TlsStream.Read(Byte[] buffer, Int32 offset, Int32 size)
at System.Net.PooledStream.Read(Byte[] buffer, Int32 offset, Int32 size)
at System.Net.Connection.SyncRead(HttpWebRequest request, Boolean userRetrievedStream, Boolean probeRead)
--- End of inner exception stack trace ---
at System.Net.HttpWebRequest.GetResponse()
at System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
--- End of inner exception stack trace ---</ExceptionString>
<InnerException>
<ExceptionType>System.Net.WebException, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</ExceptionType>
<Message>The underlying connection was closed: A connection that was expected to be kept alive was closed by the server.</Message>
<StackTrace>
at System.Net.HttpWebRequest.GetResponse()
at System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
</StackTrace>
<ExceptionString>System.Net.WebException: The underlying connection was closed: A connection that was expected to be kept alive was closed by the server. ---> System.IO.IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host. ---> System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host
at System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
--- End of inner exception stack trace ---
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
at System.Net.FixedSizeReader.ReadPacket(Byte[] buffer, Int32 offset, Int32 count)
at System.Net.Security._SslStream.StartFrameHeader(Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest)
at System.Net.Security._SslStream.StartReading(Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest)
at System.Net.Security._SslStream.ProcessRead(Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest)
at System.Net.TlsStream.Read(Byte[] buffer, Int32 offset, Int32 size)
at System.Net.PooledStream.Read(Byte[] buffer, Int32 offset, Int32 size)
at System.Net.Connection.SyncRead(HttpWebRequest request, Boolean userRetrievedStream, Boolean probeRead)
--- End of inner exception stack trace ---
at System.Net.HttpWebRequest.GetResponse()
at System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)</ExceptionString>
<InnerException>
<ExceptionType>System.IO.IOException, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</ExceptionType>
<Message>Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.</Message>
<StackTrace>
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
at System.Net.FixedSizeReader.ReadPacket(Byte[] buffer, Int32 offset, Int32 count)
at System.Net.Security._SslStream.StartFrameHeader(Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest)
at System.Net.Security._SslStream.StartReading(Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest)
at System.Net.Security._SslStream.ProcessRead(Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest)
at System.Net.TlsStream.Read(Byte[] buffer, Int32 offset, Int32 size)
at System.Net.PooledStream.Read(Byte[] buffer, Int32 offset, Int32 size)
at System.Net.Connection.SyncRead(HttpWebRequest request, Boolean userRetrievedStream, Boolean probeRead)
</StackTrace>
<ExceptionString>System.IO.IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host. ---> System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host
at System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
--- End of inner exception stack trace ---
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
at System.Net.FixedSizeReader.ReadPacket(Byte[] buffer, Int32 offset, Int32 count)
at System.Net.Security._SslStream.StartFrameHeader(Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest)
at System.Net.Security._SslStream.StartReading(Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest)
at System.Net.Security._SslStream.ProcessRead(Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest)
at System.Net.TlsStream.Read(Byte[] buffer, Int32 offset, Int32 size)
at System.Net.PooledStream.Read(Byte[] buffer, Int32 offset, Int32 size)
at System.Net.Connection.SyncRead(HttpWebRequest request, Boolean userRetrievedStream, Boolean probeRead)</ExceptionString>
<InnerException>
<ExceptionType>System.Net.Sockets.SocketException, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</ExceptionType>
<Message>An existing connection was forcibly closed by the remote host</Message>
<StackTrace>
at System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
</StackTrace>
<ExceptionString>System.Net.Sockets.SocketException (0x80004005): An existing connection was forcibly closed by the remote host
at System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)</ExceptionString>
<NativeErrorCode>2746</NativeErrorCode>
This service works for other clients just fine. It's just this client that's having an issue with requests over 5 minutes. Other clients on different web servers complete the request fine.
The five minute limit doesn't sound like any of the default timeouts
so I took a look at the Advanced settings for app pools and looked for settings that default to 5 minutes and look possibly problematic. I found a couple you might try. You might want to take this approach:
In IIS Manager, go to App Pools
Find your app pool, right click, select Advanced Settings
Scan the list of settings and look for the 5 minute settings and try selectively tuning by increasing the values (strongly suggest reading and learning what each does first)
A couple of 5 minute settings that jump out at me are Limit Interval (minutes) under CPU and Failure Interval (minutes) under Rapid-Fail Protection.
Can't guarantee this will be it but unless you are manually setting a default value to 5 minutes somewhere, this is a reasonable place to start looking for a 5 minute setting. Change one setting at a time, restart the app pool, and test. Note that if you have a problem like an infinite loop in your code, obviously no timeout value is going to help :-(
Good luck.
We are developing a .Net application (compiled for .net 4.0) that communicates to a soap web service.
The application has been working fine on several machines when retreiving the http web response content. However on one of the machines (Windows Server 2008 R2) the application is not able to retreive the response. This is a code example:
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://200.57.3.82:3443/AdministradorQr/WebServiceDodaPort?wsdl");
request.Method = "GET";
WebResponse response;
Stream responseStream = response.GetResponseStream();
string result = string.Empty;
using (StreamReader streamReader = new StreamReader(responseStream))
{
result = streamReader.ReadToEnd();
}
The exception we get is:
The underlying connection was closed: An unexpected error occurred on a send. System.Net.WebException: The underlying connection was closed: An unexpected error occurred on a send. ---> System.IO.IOException: Unable to read data from the transport connection: An established connection was aborted by the software in your host machine. ---> System.Net.Sockets.SocketException: An established connection was aborted by the software in your host machine
at System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
--- End of inner exception stack trace ---
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
at System.Net.FixedSizeReader.ReadPacket(Byte[] buffer, Int32 offset, Int32 count)
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.StartSendBlob(Byte[] incoming, Int32 count, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.ForceAuthentication(Boolean receiveFirst, Byte[] buffer, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.ProcessAuthentication(LazyAsyncResult lazyResult)
at System.Net.TlsStream.CallProcessAuthentication(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Net.TlsStream.ProcessAuthentication(LazyAsyncResult result)
at System.Net.TlsStream.Write(Byte[] buffer, Int32 offset, Int32 size)
at System.Net.PooledStream.Write(Byte[] buffer, Int32 offset, Int32 size)
at System.Net.ConnectStream.WriteHeaders(Boolean async)
--- End of inner exception stack trace ---
at System.Net.HttpWebRequest.GetResponse()
The thing is that using the same code with a different URL we get a sucessfull response, and the problem is only happening in one machine even though there is another machinge also using Windows 2008 that works just fine.
Currently we cannot upgrade .net framework to try using solutions like use of TLS 1.2 found in some places like this one: "The underlying connection was closed: An unexpected error occurred on a send." With SSL Certificate
As I mentioned, it is very strange that the same code works just fine in other machines using the same Windows/.net version and it is also strange that for other URLs like http://www.yahoo.com works fine
Not sure if it can help you but you can try adding below line in "Global.asax -> Application_Start" function. See it it works. Basically this code will force your application to use TLS1.2 only and you do not need to upgrade your framework.
"System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12;"
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 2 years ago.
Improve this question
I am getting an issue in PROD while connecting to Oracle. It worked well till the last week and suddenly stopped working with below error. My app uses EF and ASP.NET MVC. Connection becomes success on the first attempt and oracle session is closed immediate after session went to INACTIVE. But I can see the INACTIVE session in oracle from other app servers hence DBA is saying everything is good from oracle server side. Below are my observations
Sessions are created from this server being killed immediately when it goes to INACTIVE state. Connection is success for the first query and its failing for the second query onward
TCP connections from our server is going to TIME_WAIT state and closing after some time.
I checked with N/w team and DBA on this to check why the sessions killed but they said no issue from their SIDE.
I also checked on the Firewall rules in server but didn't find anything here. And there is no External firewall in between the oracle server and app server.
An error occurred while executing the command definition. See the inner exception for details.
Connection Failed:Oracle.ManagedDataAccess.Client.OracleException (0x80004005): Oracle error ORA-12571 encountered
OracleInternal.Network.NetworkException (0x80004005): Oracle error ORA-12571 encountered System.Net.Sockets.SocketException
(0x80004005): An existing connection was forcibly closed by the remote
host
at System.Net.Sockets.Socket.Send(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)
at OracleInternal.Network.TcpTransportAdapter.Send(OraBuf OB)
at OracleInternal.Network.TcpTransportAdapter.Send(OraBuf OB)
at OracleInternal.Network.WriterStream.Write(OraBuf OB)
at OracleInternal.TTC.OraBufWriter.FlushData()
at OracleInternal.TTC.TTCExecuteSql.WriteOall8Message(Byte[] sqlStmtByteStream, Int32 cursorId, Int64 dbChangeRegistrationId, Int64
executeOptions, ColumnDescribeInfo[] colDefinesInfoArray, Int32
longFetchSize, Int32 arrayBindCount, Int32 numDefineCols, Int64
noOfRowsToFetch, SqlStatementType stmtType,
MarshalBindParameterValueHelper& marshalBindParamsHelper, Int32
startIndex)
at Oracle.ManagedDataAccess.Client.OracleException.HandleError(OracleTraceLevel
level, OracleTraceTag tag, Exceptionex)
at OracleInternal.TTC.TTCExecuteSql.WriteOall8Message(Byte[] sqlStmtByteStream, Int32 cursorId, Int64 dbChangeRegistrationId, Int64
executeOptions, ColumnDescribeInfo[] colDefinesInfoArray, Int32
longFetchSize, Int32 arrayBindCount, Int32 numDefineCols, Int64
noOfRowsToFetch, SqlStatementType stmtType,
MarshalBindParameterValueHelper& marshalBindParamsHelper, Int32
startIndex)
at OracleInternal.TTC.TTCExecuteSql.SendExecuteRequest(OracleConnectionImpl
commImpl, Byte[] sqlStmtByteStream, Boolean bHasReturningClause, Int32
cursorId, Int64 dbChangeRegistrationId, ColumnDescribeInfo[]
columnDefines, Int64 noOfRowsToFetch, Boolean parse, Boolean execute,
Boolean fetch, Boolean define, Boolean bAutoCommit, Boolean
bDisableCompressedFetch, SqlStatementType stmtType, Int32
longFetchSize, Int32 noOfIters, Int64[] scnForSnapshot,
MarshalBindParameterValueHelper& marshalBindParamsHelper, Int32
startIndex)
at OracleInternal.ServiceObjects.OracleCommandImpl.ExecuteReader(String
commandText, OracleParameterCollection paramColl, CommandType
commandType, OracleConnectionImpl connectionImpl,
OracleDataReaderImpl& rdrImpl, Int32 longFetchSize, Int64
clientInitialLOBFS, OracleDependencyImpl orclDependencyImpl, Int64[]
scnForExecution, Int64[]& scnFromExecution, OracleParameterCollection&
bindByPositionParamColl, Boolean& bBindParamPresent, Int64&
internalInitialLOBFS, OracleException& exceptionForArrayBindDML,
Boolean isDescribeOnly, Boolean isFromEF)
at Oracle.ManagedDataAccess.Client.OracleCommand.ExecuteReader(Boolean
requery, Boolean fillRequest, CommandBehaviorbehavior)
at Oracle.ManagedDataAccess.Client.OracleCommand.ExecuteDbDataReader(CommandBehavior
behavior)
at System.Data.Common.DbCommand.ExecuteReader(CommandBehavior behavior)
at System.Data.EntityClient.EntityCommandDefinition.ExecuteStoreCommands(EntityCommand
entityCommand, CommandBehavior behavior)
Please help. Thanks in Advance.
Issue resolved by changing the Server gateway. But not sure whats issue with the Current Gateway.
Ok, for our site, which I will say is "https://www.foo-bar.com", and is a .NET MVC 4.5.1 application, we have the following code:
var http = (HttpWebRequest)WebRequest.Create("https://www.foo-bar.com/category.rss");
var response = http.GetResponse();
var stream = response.GetResponseStream();
var sr = new StreamReader(stream);
s = sr.ReadToEnd();
This works locally, AND it works in production under "http", but as soon as we go to https, we get the following error:
{
"ClassName":"System.Net.WebException",
"Message":"The underlying connection was closed: An unexpected error occurred on a send.",
"Data":null,
"InnerException":{
"ClassName":"System.IO.IOException",
"Message":"Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.",
"Data":null,
"InnerException":{
"NativeErrorCode":10054,
"ClassName":"System.Net.Sockets.SocketException",
"Message":"An existing connection was forcibly closed by the remote host",
"Data":null,
"InnerException":null,
"HelpURL":null,
"StackTraceString":" at System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)\r\n at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)",
"RemoteStackTraceString":null,
"RemoteStackIndex":0,
"ExceptionMethod":"8\nReceive\nSystem, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089\nSystem.Net.Sockets.Socket\nInt32 Receive(Byte[], Int32, Int32, System.Net.Sockets.SocketFlags)",
"HResult":-2147467259,
"Source":"System",
"WatsonBuckets":null
},
"HelpURL":null,
"StackTraceString":" at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)\r\n at System.Net.FixedSizeReader.ReadPacket(Byte[] buffer, Int32 offset, Int32 count)\r\n at System.Net.Security.SslState.StartReceiveBlob(Byte[] buffer, AsyncProtocolRequest asyncRequest)\r\n at System.Net.Security.SslState.CheckCompletionBeforeNextReceive(ProtocolToken message, AsyncProtocolRequest asyncRequest)\r\n at System.Net.Security.SslState.StartSendBlob(Byte[] incoming, Int32 count, AsyncProtocolRequest asyncRequest)\r\n at System.Net.Security.SslState.ForceAuthentication(Boolean receiveFirst, Byte[] buffer, AsyncProtocolRequest asyncRequest)\r\n at System.Net.Security.SslState.ProcessAuthentication(LazyAsyncResult lazyResult)\r\n at System.Net.TlsStream.CallProcessAuthentication(Object state)\r\n at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)\r\n at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)\r\n at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)\r\n at System.Net.TlsStream.ProcessAuthentication(LazyAsyncResult result)\r\n at System.Net.TlsStream.Write(Byte[] buffer, Int32 offset, Int32 size)\r\n at System.Net.PooledStream.Write(Byte[] buffer, Int32 offset, Int32 size)\r\n at System.Net.ConnectStream.WriteHeaders(Boolean async)",
"RemoteStackTraceString":null,
"RemoteStackIndex":0,
"ExceptionMethod":"8\nRead\nSystem, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089\nSystem.Net.Sockets.NetworkStream\nInt32 Read(Byte[], Int32, Int32)",
"HResult":-2146232800,
"Source":"System",
"WatsonBuckets":null
},
"HelpURL":null,
"StackTraceString":" at System.Net.HttpWebRequest.GetResponse()\r\n at ASP._Page_Views_home_Test_cshtml.Execute() in c:\\inetpub\\wwwroot\\foobarweb_dev\\Views\\Home\\Test.cshtml:line 14",
"RemoteStackTraceString":null,
"RemoteStackIndex":0,
"ExceptionMethod":"8\nGetResponse\nSystem, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089\nSystem.Net.HttpWebRequest\nSystem.Net.WebResponse GetResponse()",
"HResult":-2146233079,
"Source":"System",
"WatsonBuckets":null
}
I've read suggestion to edit the following settings, and I have tinkered with them all, but no matter what combination I use, I still get the above error:
http.KeepAlive
http.ProtocolVersion
http.ServicePoint.ConnectionLimit
http.Timeout
If I try this in another project on my local computer, connecting to the "https" version of the site works. It is only when connecting from within the site over SSL.
I am stumped, and I'm not even sure if this is a code issue, a server issue, or maybe even a proxy/firewall issue.
Check the TLS version of the host "https://www.foo-bar.com" and the .NET TLS version of your project. They should be equal.
Check by "Immediate window":
System.Net.ServicePointManager.SecurityProtocol
The issue is something with the SSL -- probably a certificate issue of some sort. If it is public facing I would start by running SSL Labs Analyizer at it to see if that helps sniff out the cert problem.
I had this same problem and resolved it by adding the following to my Powershell script:
$AllProtocols = [System.Net.SecurityProtocolType]'Ssl3,Tls,Tls11,Tls12'
[System.Net.ServicePointManager]::SecurityProtocol = $AllProtocols
[System.Net.ServicePointManager]::CertificatePolicy = New-Object TrustAllCertsPolicy
Had this on a .NET Framework 4.0 app and the solution for us was as found here. Create the following four DWORD keys and set them all to a value of 1 to enable strong cryptography and have the OS manage which version to use:
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\.NETFramework\v4.0.30319\SystemDefaultTlsVersions
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\.NETFramework\v4.0.30319\SchUseStrongCrypto
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\v4.0.30319\SystemDefaultTlsVersions
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\v4.0.30319\SchUseStrongCrypto
I am using MS Dynamics CRM api to get data (more then 5000 records) from it.
I am using XML based query to get data
EntityCollection resultSet = _orgServiceProxy.RetrieveMultiple(new FetchExpression(query));
sometime time it works and most of the time it throws exception, from logs, I am getting this long exception.
An error occurred while receiving the HTTP response to https://orgno.api.crm.dynamics.com/XRMServices/2011/Organization.svc. This could be due to the service endpoint binding not using the HTTP protocol. This could also be due to an HTTP request context being aborted by the server (possibly due to the service shutting down). See server logs for more details. ---> System.ServiceModel.CommunicationException: An error occurred while receiving the HTTP response to https://orgno.api.crm.dynamics.com/XRMServices/2011/Organization.svc. This could be due to the service endpoint binding not using the HTTP protocol. This could also be due to an HTTP request context being aborted by the server (possibly due to the service shutting down). See server logs for more details. ---> System.Net.WebException: The underlying connection was closed: An unexpected error occurred on a receive. ---> System.IO.IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host. ---> System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size) --- End of inner exception stack trace --- at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size) at System.Net.FixedSizeReader.ReadPacket(Byte[] buffer, Int32 offset, Int32 count) at System.Net.Security._SslStream.StartFrameHeader(Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest) at System.Net.Security._SslStream.StartReading(Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest) at System.Net.Security._SslStream.ProcessRead(Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest) at System.Net.TlsStream.Read(Byte[] buffer, Int32 offset, Int32 size) at System.Net.PooledStream.Read(Byte[] buffer, Int32 offset, Int32 size) at System.Net.Connection.SyncRead(HttpWebRequest request, Boolean userRetrievedStream, Boolean probeRead) --- End of inner exception stack trace --- at System.Net.HttpWebRequest.GetResponse() at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout) --- End of inner exception stack trace
I don't know why this is happening?
CRM service doesn't like at all retrieve much data in one request.
I suggested you to use a paging cookie to retrieve your records by sets. It should resolve your issue and improve the performance of your code.
You can find a nice tutorial on msdn here.
Regards,
Kévin