SSL connection not taking place with RabbitMQ - ssl

While working on a issue found that SSL connection are not created when interacting to RabbitMQ. There is following exception that occurs:
Starting application. . . .
RabbitMQ.Client.Exceptions.BrokerUnreachableException: None of the specified endpoints were reachable ---> System.Security.Authentication.AuthenticationException: A call to SSPI failed, see inner exception. ---> System.ComponentModel.Win32Exception: One or more of the parameters passed to the function was invalid
--- End of inner exception stack trace ---
at System.Net.Security.SslState.StartSendAuthResetSignal(ProtocolToken message, AsyncProtocolRequest asyncRequest, Exception exception)
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.ProcessReceivedBlob(Byte[] buffer, Int32 count, AsyncProtocolRequest asyncRequest)
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.StartSendBlob(Byte[] incoming, Int32 count, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.ProcessReceivedBlob(Byte[] buffer, Int32 count, AsyncProtocolRequest asyncRequest)
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.StartSendBlob(Byte[] incoming, Int32 count, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.ProcessReceivedBlob(Byte[] buffer, Int32 count, AsyncProtocolRequest asyncRequest)
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.StartSendBlob(Byte[] incoming, Int32 count, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.ProcessReceivedBlob(Byte[] buffer, Int32 count, AsyncProtocolRequest asyncRequest)
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.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.Security.SslStream.AuthenticateAsClient(String targetHost, X509CertificateCollection clientCertificates, SslProtocols enabledSslProtocols, Boolean checkCertificateRevocation)
at RabbitMQ.Client.SslHelper.TcpUpgrade(Stream tcpStream, SslOption sslOption)
at RabbitMQ.Client.Impl.SocketFrameHandler..ctor(AmqpTcpEndpoint endpoint, Func2 socketFactory, Int32 connectionTimeout, Int32 readTimeout, Int32 writeTimeout) at RabbitMQ.Client.Framing.Impl.ProtocolBase.CreateFrameHandler(AmqpTcpEndpoint endpoint, Func2 socketFactory, Int32 connectionTimeout, Int32 readTimeout, Int32 writeTimeout)
at RabbitMQ.Client.ConnectionFactory.CreateFrameHandler(AmqpTcpEndpoint endpoint)
at RabbitMQ.Client.ConnectionFactory.CreateConnection(IList1 endpoints, String clientProvidedName) --- End of inner exception stack trace --- at RabbitMQ.Client.ConnectionFactory.CreateConnection(IList1 endpoints, String clientProvidedName)
at RabbitMQ.Client.ConnectionFactory.CreateConnection(IList`1 hostnames, String clientProvidedName)
at RabbitMQ.Client.ConnectionFactory.CreateConnection()
Here is the code snippet:
`
namespace ConsoleApp_Test
{
class Program
{
private static string certificatepath = #"C:\CertificatePath\4RMQClientCert.p12";
static void Main(string[] args)
{
try
{
Console.WriteLine("Starting application. . . . ");
ConnectionFactory connectionFactory = CreateConnectionFactory();
IConnection connection = connectionFactory.CreateConnection();
Console.ReadLine();
Console.WriteLine("Connection Created successfully . . .");
}
catch (Exception ex)
{
Console.WriteLine(ex);
CreateErrorTextFile(ex.StackTrace);
}
finally
{
Console.ReadLine();
}
}
private static ConnectionFactory CreateConnectionFactory()
{
XmlDocument xml = new XmlDocument();
xml.Load(#"TLSParameters.xml");
XmlNodeList parameters = xml.SelectNodes("Parameters");
ConnectionFactory connectionFactory = new ConnectionFactory();
foreach (XmlNode xnlNode in parameters)
{
XmlElement element = (XmlElement)xnlNode;
connectionFactory.HostName = element.GetElementsByTagName("HostName")[0].ChildNodes[0].InnerText;
connectionFactory.UserName = element.GetElementsByTagName("UserName")[0].ChildNodes[0].InnerText;
connectionFactory.Password = element.GetElementsByTagName("Password")[0].ChildNodes[0].InnerText;
connectionFactory.Ssl.CertPath = element.GetElementsByTagName("ClientCertPath")[0].ChildNodes[0].InnerText;
connectionFactory.Ssl.CertPassphrase = element.GetElementsByTagName("CertificatePassword")[0].ChildNodes[0].InnerText;
connectionFactory.Ssl.ServerName = element.GetElementsByTagName("ServerName")[0].ChildNodes[0].InnerText;
}
connectionFactory.Ssl.Enabled = true;
connectionFactory.Ssl.Version = SslProtocols.Tls12; // Error in wireshark . No Client hello
connectionFactory.Ssl.CertificateValidationCallback += new RemoteCertificateValidationCallback(ValidateServerCertificate);
return connectionFactory;
}
private static X509Certificate SelectLocalCertificate(object sender, string targetHost, X509CertificateCollection localCertificates, X509Certificate remoteCertificate, string[] acceptableIssuers)
{
Console.WriteLine("Client is selecting a local certificate.");
if (acceptableIssuers != null &&
acceptableIssuers.Length > 0 &&
localCertificates != null &&
localCertificates.Count > 0)
{
// Use the first certificate that is from an acceptable issuer.
foreach (X509Certificate certificate in localCertificates)
{
string issuer = certificate.Issuer;
if (Array.IndexOf(acceptableIssuers, issuer) != -1)
return certificate;
}
}
if (localCertificates != null &&
localCertificates.Count > 0)
return localCertificates[0];
return null;
}
private static bool ValidateServerCertificate(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
{
bool isServerVerified = false;
if ((sslPolicyErrors & ~SslPolicyErrors.RemoteCertificateNameMismatch) == SslPolicyErrors.None)
{
isServerVerified = true;
}
string sslError = sslPolicyErrors.ToString();
CreateErrorTextFile(sslError);
Console.WriteLine("Error:" + sslError);
return isServerVerified;
}
private static void CreateErrorTextFile(string error)
{
string fileName = #"C:\Temp\SSLErrors.txt";
using (FileStream fs = File.Create(fileName))
{
byte[] errors = new UTF8Encoding(true).GetBytes(error);
fs.Write(errors, 0, errors.Length);
}
}
}
}
`
Wireshark capture shows this:
enter image description here
As per my investigation proper wireshark capture should look like following:
enter image description here
Tried many things but none worked.
Steps taken to resolve this :
Ran IISCrypto
Certificates checked and are latest and have no problem according to me.
Verified TLS 1.2 is enabled or not, but it was enabled
Working on all other system, other than server machine.
Windows is updated to the latest.
Firewalls are also disabled.
Please let me know how can I make this hand shake successful so that application interacts successfully with RabbitMQ
Ran IISCrypto
Certificates checked and are latest and have no problem according to me.
Verified TLS 1.2 is enabled or not, but it was enabled
Working on all other system, other than server machine.
Windows is updated to the latest.
Firewalls are also disabled.
Please let me know how can I make this hand shake successful so that application interacts successfully with RabbitMQ

Related

Upgrade Asp.Net Core 2.2 to 3.1 Failed to authenticate HTTPS connection

I've upgraded solution from 2.2 to 3.1. It consists of several projects (APIs). They all use Kestrel and HTTPS.
After the upgrade I cannot call one service from another (by using HttpClient) and I cannot reroute them by using Ocelot, when i run things locally on localhost. In both cases I'm getting the same error:
Failed to authenticate HTTPS connection.
System.IO.IOException: Authentication failed because the remote party has closed the transport stream.
at System.Net.Security.SslStream.StartReadFrame(Byte[] buffer, Int32 readBytes, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslStream.StartReceiveBlob(Byte[] buffer, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslStream.ForceAuthentication(Boolean receiveFirst, Byte[] buffer, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslStream.ProcessAuthentication(LazyAsyncResult lazyResult, CancellationToken cancellationToken)
at System.Net.Security.SslStream.BeginAuthenticateAsServer(SslServerAuthenticationOptions sslServerAuthenticationOptions, CancellationToken cancellationToken, AsyncCallback asyncCallback, Object asyncState)
at System.Net.Security.SslStream.<>c.<AuthenticateAsServerAsync>b__69_0(SslServerAuthenticationOptions arg1, CancellationToken arg2, AsyncCallback callback, Object state)
at System.Threading.Tasks.TaskFactory`1.FromAsyncImpl[TArg1,TArg2](Func`5 beginMethod, Func`2 endFunction, Action`1 endAction, TArg1 arg1, TArg2 arg2, Object state, TaskCreationOptions creationOptions)
at System.Threading.Tasks.TaskFactory.FromAsync[TArg1,TArg2](Func`5 beginMethod, Action`1 endMethod, TArg1 arg1, TArg2 arg2, Object state, TaskCreationOptions creationOptions)
at System.Threading.Tasks.TaskFactory.FromAsync[TArg1,TArg2](Func`5 beginMethod, Action`1 endMethod, TArg1 arg1, TArg2 arg2, Object state)
at System.Net.Security.SslStream.AuthenticateAsServerAsync(SslServerAuthenticationOptions sslServerAuthenticationOptions, CancellationToken cancellationToken)
at Microsoft.AspNetCore.Server.Kestrel.Https.Internal.HttpsConnectionMiddleware.InnerOnConnectionAsync(ConnectionContext context)
When I call each API from postman, it is working.
Furthermore when I set verything to HTTP I'm getting the same error.
Sample code(returns 403 Forbidden):
HttpClient client = new HttpClient();
HttpResponseMessage response = await client.GetAsync("https://localhost:5004/version");
if (response.IsSuccessStatusCode)
{
serviceVersion = await response.Content.ReadAsStringAsync();
}

WCF-Exception while returning List<T>

in my following application, i generate a List of the class 'JobManager'.
List<JobManager>
The access to the database and filling my list is working perfect. It seems there is a problem for returning such list to my client.
In detail,my code looks like this
IService Class
OperationContract(Name = "ReadJobQueue")]
[FaultContract(typeof(FaultException))]
List<JobManager> AccessManager(List<string> status,string process, string dtFrom, string dtTo);
Service : IService
public List<JobManager> AccessManager(List<string> status, string process, string dtFrom, string dtTo)
{
//return 'new List<JobManager>()' does work, without any data being filled.
return new JobBuilder(status, process, dtFrom, dtTo);
}
[DataContract]
public class JobManager
{
List<JobManager> _jobManagerchildren = new List<JobManager>();
[DataMember(IsRequired = true, Order = 0)]
public string Description { get; set; }
[DataMember]
public List<JobManager> JobManagerChildren
{
get { return _jobManagerchildren; }
internal set { _jobManagerchildren = value; }
}
}
internal class JobBuilder : List<JobManager>
{
public JobBuilder(List<string> status, string process, string dtFrom, string dtTo)
: base()
{
DataTable dt = new Database().AccessJobQueue(status, process, dtFrom, dtTo);
foreach (DataRow row in dt.Rows)
{
Add(new JobManager { Description = row[1].ToString(), JobManagerChildren = JobDetail(row[0].ToString()) });
}
}
...
}
Have i missed something for my JobManager class?
edit error code / exception
System.Net.Sockets.SocketException:
An existing connection was been closed by the remotehost
bei System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size
, SocketFlags socketFlags)
bei System.ServiceModel.Channels.SocketConnection.ReadCore(Byte[] buffer, Int
32 offset, Int32 size, TimeSpan timeout, Boolean closing)
--- Ende der internen Ausnahmestapelüberwachung ---
bei System.ServiceModel.Channels.SocketConnection.ReadCore(Byte[] buffer, Int
32 offset, Int32 size, TimeSpan timeout, Boolean closing)
bei System.ServiceModel.Channels.SocketConnection.Read(Byte[] buffer, Int32 o
ffset, Int32 size, TimeSpan timeout)
bei System.ServiceModel.Channels.DelegatingConnection.Read(Byte[] buffer, Int
32 offset, Int32 size, TimeSpan timeout)
bei System.ServiceModel.Channels.ConnectionStream.Read(Byte[] buffer, Int32 o
ffset, Int32 count)
bei System.Net.FixedSizeReader.ReadPacket(Byte[] buffer, Int32 offset, Int32
count)
bei System.Net.Security.NegotiateStream.StartFrameHeader(Byte[] buffer, Int32
offset, Int32 count, AsyncProtocolRequest asyncRequest)
bei System.Net.Security.NegotiateStream.ProcessRead(Byte[] buffer, Int32 offs
et, Int32 count, AsyncProtocolRequest asyncRequest)
--- Ende der internen Ausnahmestapelüberwachung ---
bei System.Net.Security.NegotiateStream.ProcessRead(Byte[] buffer, Int32 offs
et, Int32 count, AsyncProtocolRequest asyncRequest)
bei System.Net.Security.NegotiateStream.Read(Byte[] buffer, Int32 offset, Int
32 count)
bei System.ServiceModel.Channels.StreamConnection.Read(Byte[] buffer, Int32 o
ffset, Int32 size, TimeSpan timeout)
--- Ende der internen Ausnahmestapelüberwachung ---
Server stack trace:
bei System.ServiceModel.Channels.StreamConnection.Read(Byte[] buffer, Int32 o
ffset, Int32 size, TimeSpan timeout)
bei System.ServiceModel.Channels.SessionConnectionReader.Receive(TimeSpan tim
eout)
bei System.ServiceModel.Channels.SynchronizedMessageSource.Receive(TimeSpan t
imeout)
bei System.ServiceModel.Channels.FramingDuplexSessionChannel.Receive(TimeSpan
timeout)
bei System.ServiceModel.Channels.FramingDuplexSessionChannel.TryReceive(TimeS
pan timeout, Message& message)
bei System.ServiceModel.Dispatcher.DuplexChannelBinder.Request(Message messag
e, TimeSpan timeout)
bei System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean o
neway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan ti
meout)
bei System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCal
lMessage methodCall, ProxyOperationRuntime operation)
bei System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
Exception rethrown at [0]:
bei System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage re
qMsg, IMessage retMsg)
bei System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgD
ata, Int32 type)
bei WcfSys.Shared.IService.AccessManager(List`1 status, String process, S
tring dtFrom, String dtTo)
bei WcfSys.Server.Program.Main() in WcfSys.Ser
ver\Program.cs:Zeile 66.
Actually, what you're sending back to the client is a List<JobManager>, but actually it's a derived class. So there are two ways of fixing this:
Copy all entries from JobBuilder to a new List<JobManager> and return that new list
Make JobBuilder a DataContract, too.
As - by OOP principles - it is know that the object you're returning is a JobBuilder, the runtime tries to serialize the JobBuilder instance. This, however, is not a know type for WCF communication.

WCF An error occurred while receiving the HTTP response

Here's what my WCF service should be returning. When I command PaymentData out of ResponseModel and add other DataMembers in that class it works.
[DataContract]
public class ResponseModel
{
[DataMember]
public PaymentData PaymentData { get; set; }
}
Here's the PaymentData class:
[DataContract]
public class PaymentData
{
[DataMember]
public PaymentType PaymentType { get; set; }
[DataMember]
public string CardNumber { get; set; }
[DataMember]
public DateTime ExpirationDate { get; set; }
/// <summary>
/// If true, then the CardNumber property will contain the token
/// </summary>
[DataMember]
public bool IsCardNumberTokenized { get; set; }
/// <summary>
/// Number on back of credit cards. This value CANNOT be stored anywhere
/// </summary>
[DataMember]
public string CardSecurityValue { get; set; }
[DataMember]
public CardSecurityPresence CardSecurityPresence { get; set; }
}
... and the enums defined in the PaymentData class
[DataContract(Name = "CardSecurityPresenceEnum")]
public enum CardSecurityPresence
{
[EnumMember(Value = "1")]
IsPresent = 1,
[EnumMember(Value = "2")]
Illegible = 2,
[EnumMember(Value = "9")]
NoCodeOnCard = 9,
[EnumMember(Value = " ")]
NotSent
}
[DataContract(Name = "PaymentTypeEnum")]
public enum PaymentType
{
[EnumMember]
Visa = CMPWSApiService.TransactionMop.VI,
[EnumMember]
MasterCard = CMPWSApiService.TransactionMop.MC,
[EnumMember]
AmericanExpress = CMPWSApiService.TransactionMop.AX,
[EnumMember]
Discover = CMPWSApiService.TransactionMop.DI,
[EnumMember]
PayPal = CMPWSApiService.TransactionMop.PP,
[EnumMember]
BillMeLater = CMPWSApiService.TransactionMop.BL
}
Does the serialization not like that my variable names have the same names as their classes?
Here's the error from the WCFTest Client:
An error occurred while receiving the HTTP response to
[service url omitted]. 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.
Server stack trace: at
System.ServiceModel.Channels.HttpChannelUtilities.ProcessGetResponseWebException(WebException
webException, HttpWebRequest request, HttpAbortReason abortReason)
at
System.ServiceModel.Channels.HttpChannelFactory.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)
Exception rethrown at [0]: at
System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage
reqMsg, IMessage retMsg) at
System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData&
msgData, Int32 type) at ICreditCardService.TestAuth() at
CreditCardServiceClient.TestAuth()
Inner Exception: The underlying connection was closed: An unexpected
error occurred on a receive. at
System.Net.HttpWebRequest.GetResponse() at
System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan
timeout)
Inner Exception: Unable to read data from the transport connection: An
existing connection was forcibly closed by the remote host. at
System.Net.Sockets.NetworkStream.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)
Inner Exception: 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)
In CardSecurityPresenceEnum I had a enum member called NotSent that was not initialized to a value. For some reason that was hanging things up.

How to dispose these objects?

The project I'm maintaining has a bunch of usercontrols where SPWeb and SPSite objects are initialized in the constructor from SPContext. These objects are then passed to other classes.
public MyUserControl : UserControl
{
private SPWeb web;
public MyUserControl() { web = SPContext.Current.Web; }
AnotherClass.SomeMethod ( web );
}
The logs are filled with the following two entries:
1)
Detected use of SPRequest for previously closed SPWeb object. Please close SPWeb objects when you are done with all objects obtained from them, but not before. Stack trace:
at Microsoft.SharePoint.SPListItemCollection.EnsureListItemsData()
at Microsoft.SharePoint.SPListItemCollection.GetEnumerator()
at XXXXXXXX.Web.UserControls.TopNavigation.LoadTopImage()
at XXXXXXXX.Web.UserControls.TopNavigation.OnLoad(EventArgs e)
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
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 System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
at System.Web.HttpApplication.PipelineStepManager.ResumeSteps(Exception error)
at System.Web.HttpApplication.BeginProcessRequestNotification(HttpContext context, AsyncCallback cb)
at System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context)
at System.Web.Hosting.PipelineRuntime.ProcessRequestNotificationHelper(IntPtr managedHttpContext, IntPtr nativeRequestContext, IntPtr moduleData, Int32 flags)
at System.Web.Hosting.PipelineRuntime.ProcessRequestNotification(IntPtr managedHttpContext, IntPtr nativeRequestContext, IntPtr moduleData, Int32 flags)
at System.Web.Hosting.PipelineRuntime.ProcessRequestNotificationHelper(IntPtr managedHttpContext, IntPtr nativeRequestContext, IntPtr moduleData, Int32 flags)
at System.Web.Hosting.PipelineRuntime.ProcessRequestNotification(IntPtr managedHttpContext, IntPtr nativeRequestContext, IntPtr moduleData, Int32 flags)
2)
An SPRequest object was not disposed before the end of this thread. To avoid wasting system resources, dispose of this object or its parent (such as an SPSite or SPWeb) as soon as you are done using it. This object will now be disposed. Allocation Id: {444DCCA1-C2F6-493D-9D02-D04F75C6E384} This SPRequest was allocated
at
at Microsoft.SharePoint.Library.SPRequest..ctor()
at Microsoft.SharePoint.SPGlobal.CreateSPRequestAndSetIdentity(SPSite site, String name, Boolean bNotGlobalAdminCode, String strUrl, Boolean bNotAddToContext, Byte[] UserToken, String userName, Boolean bIgnoreTokenTimeout, Boolean bAsAnonymous)
at Microsoft.SharePoint.SPWeb.InitializeSPRequest()
at Microsoft.SharePoint.SPWeb.InitWebPublic()
at Microsoft.SharePoint.SPWeb.get_LanguageCulture()
at Microsoft.SharePoint.SPWeb.get_Title()
at XXXXXXXXX.DataAccessUtility.<>c__DisplayClassc.<GetSitesTopNav>b__8()
at Microsoft.SharePoint.SPSecurity.<>c__DisplayClass4.<RunWithElevatedPrivileges>b__2()
at Microsoft.SharePoint.Utilities.SecurityContext.RunAsProcess(CodeToRunElevated secureCode)
at Microsoft.SharePoint.SPSecurity.RunWithElevatedPrivileges(WaitCallback secureCode, Object param)
at Microsoft.SharePoint.SPSecurity.RunWithElevatedPrivileges(CodeToRunElevated secureCode)
at XXXXXXXX.GetSitesTopNav(SPSite site, SPWeb Currentweb, String userName)
at XXXXXXXX.Web.UserControls.TopNavigation.PopulateSiteSelection()
at XXXXXXXX.Web.UserControls.TopNavigation.OnLoad(EventArgs e)
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
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 System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
at System.Web.HttpApplication.PipelineStepManager.ResumeSteps(Exception error)
at System.Web.HttpApplication.BeginProcessRequestNotification(HttpContext context, AsyncCallback cb)
at System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context)
at System.Web.Hosting.PipelineRuntime.ProcessRequestNotificationHelper(IntPtr managedHttpContext, IntPtr nativeRequestContext, IntPtr moduleData, Int32 flags)
at System.Web.Hosting.PipelineRuntime.ProcessRequestNotification(IntPtr managedHttpContext, IntPtr nativeRequestContext, IntPtr moduleData, Int32 flags)
at System.Web.Hosting.PipelineRuntime.ProcessRequestNotificationHelper(IntPtr managedHttpContext, IntPtr nativeRequestContext, IntPtr moduleData, Int32 flags)
at System.Web.Hosting.PipelineRuntime.ProcessRequestNotification(IntPtr managedHttpContext, IntPtr nativeRequestContext, IntPtr moduleData, Int32 flags)
Is passing the url obtained from SPContext.Current.Web.Url the right way? Any suggestions?

CommunicationObjectAbortedException during reading large array from server

I'm receiving such exception during reading array of 40000 items.
Is there an idea why does it happen.
I've changed send/receive timeout to 30 min. Not helped.
System.ServiceModel.CommunicationObjectAbortedException was unhandled
by user code Message=The socket connection has been disposed.
Source=mscorlib StackTrace:
Server stack trace:
at System.ServiceModel.Channels.StreamConnection.Read(Byte[] buffer, Int32 offset, Int32 size, TimeSpan timeout)
at System.ServiceModel.Channels.ConnectionStream.Read(Byte[] buffer, Int32 offset, Int32 count, TimeSpan timeout)
at System.ServiceModel.Channels.ConnectionStream.Read(Byte[] buffer, Int32 offset, Int32 count)
at System.ServiceModel.Channels.SingletonConnectionReader.SingletonInputConnectionStream.ReadCore(Byte[]
buffer, Int32 offset, Int32 count)
at System.ServiceModel.Channels.SingletonConnectionReader.SingletonInputConnectionStream.Read(Byte[]
buffer, Int32 offset, Int32 count)
at System.ServiceModel.Channels.DelegatingStream.Read(Byte[] buffer, Int32 offset, Int32 count)
at System.ServiceModel.Channels.MaxMessageSizeStream.Read(Byte[] buffer,
Int32 offset, Int32 count)
at System.ServiceModel.Channels.SingletonConnectionReader.Close(TimeSpan
timeout)
at System.ServiceModel.Channels.SingletonConnectionReader.DoneReceiving(Boolean
atEof, TimeSpan timeout)
at System.ServiceModel.Channels.SingletonConnectionReader.DoneReceiving(Boolean
atEof)
at System.ServiceModel.Channels.SingletonConnectionReader.SingletonInputConnectionStream.Close()
at System.ServiceModel.Channels.DelegatingStream.Close()
at System.Xml.XmlBufferReader.Close()
at System.Xml.XmlBaseReader.Close()
at System.Xml.XmlBinaryReader.Close()
at System.Xml.XmlReader.Dispose(Boolean disposing)
at System.Xml.XmlReader.System.IDisposable.Dispose()
at System.ServiceModel.Dispatcher.OperationFormatter.DeserializeBodyContents(Message
message, Object[] parameters, Boolean isRequest)
at System.ServiceModel.Dispatcher.OperationFormatter.DeserializeReply(Message
message, Object[] parameters)
at System.ServiceModel.Dispatcher.ProxyOperationRuntime.AfterReply(ProxyRpc&
rpc)
at System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime
operation, ProxyRpc& rpc)
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins,
Object[] outs, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins,
Object[] outs)
at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage
methodCall, ProxyOperationRuntime operation)
at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage
message)
Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage
reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData&
msgData, Int32 type)
at AlexSoft.Core.RemoteFacade.Contract.AdministrationSvc.IAdministrationRmService.GetAllBins()
at _dynamic_AlexSoft.Core.RemoteFacade.Contract.AdministrationSvc.IAdministrationRmService.GetAllBins(Object
, Object[] )
at Spring.Reflection.Dynamic.SafeMethod.Invoke(Object target, Object[] arguments)
at Spring.Aop.Framework.DynamicMethodInvocation.InvokeJoinpoint()
at Spring.Aop.Framework.AbstractMethodInvocation.Proceed()
at AlexSoft.Desktop.Services.RemoteFacade.ExtractRemoteExceptionAdvice.Invoke(IMethodInvocation
invocation) in
D:\proj\communic\trunk_fix_not_opened\src\SmartClient\Desktop.Services\RemoteFacade\ExtractRemoteExceptionAdvice.cs:line
15
at Spring.Aop.Framework.AbstractMethodInvocation.Proceed()
at Spring.Aop.Framework.DynamicProxy.AdvisedProxy.Invoke(Object proxy, Object target, Type targetType, MethodInfo targetMethod,
MethodInfo proxyMethod, Object[] args, IList interceptors)
at CompositionAopProxy_8e3e641f50c44b68b5809af44bfae8bd.GetAllBins()
at AlexSoft.Desktop.Services.RemoteFacade.RemoteAdministrationService.<>c__DisplayClass2.b__0(IAdministrationRmService
svc) in
D:\proj\communic\trunk_fix_not_opened\src\SmartClient\Desktop.Services\RemoteFacade\RemoteAdministrationService.cs:line
18
at AlexSoft.Desktop.Services.RemoteFacade.AbstractRemoteService1.ExecuteRmAction(RmAction
action) in
D:\proj\communic\trunk_fix_not_opened\src\SmartClient\Desktop.Services\RemoteFacade\AbstractRemoteService.cs:line
121
at AlexSoft.Desktop.Services.RemoteFacade.RemoteAdministrationService.GetAllBins()
in
D:\proj\communic\trunk_fix_not_opened\src\SmartClient\Desktop.Services\RemoteFacade\RemoteAdministrationService.cs:line
24
at AlexSoft.MPObjects.Desktop.Controllers.UseCaseBinListController.ShowBinListView(IUseCaseBinListController
controller) in
D:\proj\communic\trunk_fix_not_opened\src\SmartClient\AlexSoft.MPObjects.Desktop\Controllers\UseCaseBinListController.cs:line
95
at Microsoft.Practices.Composite.Presentation.Commands.DelegateCommand1.Execute(T
parameter)
at Microsoft.Practices.Composite.Presentation.Commands.DelegateCommand`1.System.Windows.Input.ICommand.Execute(Object
parameter)
at MS.Internal.Commands.CommandHelpers.CriticalExecuteCommandSource(ICommandSource
commandSource, Boolean userInitiated)
at System.Windows.Controls.Primitives.ButtonBase.OnClick()
at System.Windows.Controls.Button.OnClick()
at System.Windows.Controls.Primitives.ButtonBase.OnMouseLeftButtonUp(MouseButtonEventArgs
e)
at System.Windows.UIElement.OnMouseLeftButtonUpThunk(Object sender, MouseButtonEventArgs e)
at System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(Delegate
genericHandler, Object genericTarget)
at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
at System.Windows.UIElement.ReRaiseEventAs(DependencyObject sender, RoutedEventArgs args, RoutedEvent newEvent)
at System.Windows.UIElement.OnMouseUpThunk(Object sender, MouseButtonEventArgs e)
at System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(Delegate
genericHandler, Object genericTarget)
at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
at System.Windows.UIElement.RaiseTrustedEvent(RoutedEventArgs args)
at System.Windows.UIElement.RaiseEvent(RoutedEventArgs args, Boolean trusted)
at System.Windows.Input.InputManager.ProcessStagingArea()
at System.Windows.Input.InputManager.ProcessInput(InputEventArgs input)
at System.Windows.Input.InputProviderSite.ReportInput(InputReport
inputReport)
at System.Windows.Interop.HwndMouseInputProvider.ReportInput(IntPtr hwnd,
InputMode mode, Int32 timestamp, RawMouseActions actions, Int32 x,
Int32 y, Int32 wheel)
at System.Windows.Interop.HwndMouseInputProvider.FilterMessage(IntPtr
hwnd, WindowMessage msg, IntPtr wParam, IntPtr lParam, Boolean&
handled)
at System.Windows.Interop.HwndSource.InputFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate
callback, Object args, Int32 numArgs)
at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object
source, Delegate method, Object args, Int32 numArgs, Delegate
catchHandler) InnerException: System.IO.IOException
Message=The read operation failed, see inner exception.
Source=System
StackTrace:
at System.Net.Security.NegotiateStream.ProcessRead(Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest)
at System.Net.Security.NegotiateStream.Read(Byte[] buffer, Int32 offset, Int32 count)
at System.ServiceModel.Channels.StreamConnection.Read(Byte[] buffer,
Int32 offset, Int32 size, TimeSpan timeout)
InnerException: System.ServiceModel.CommunicationObjectAbortedException
Message=The socket connection has been disposed.
Source=System.ServiceModel
StackTrace:
at System.ServiceModel.Channels.SocketConnection.ThrowIfNotOpen()
at System.ServiceModel.Channels.SocketConnection.Read(Byte[] buffer,
Int32 offset, Int32 size, TimeSpan timeout)
at System.ServiceModel.Channels.DelegatingConnection.Read(Byte[] buffer,
Int32 offset, Int32 size, TimeSpan timeout)
at System.ServiceModel.Channels.ConnectionStream.Read(Byte[] buffer,
Int32 offset, Int32 count, TimeSpan timeout)
at System.ServiceModel.Channels.ConnectionStream.Read(Byte[] buffer,
Int32 offset, Int32 count)
at System.Net.FixedSizeReader.ReadPacket(Byte[] buffer, Int32 offset, Int32 count)
at System.Net.Security.NegotiateStream.StartFrameHeader(Byte[] buffer,
Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest)
at System.Net.Security.NegotiateStream.ProcessRead(Byte[] buffer, Int32
offset, Int32 count, AsyncProtocolRequest asyncRequest)
InnerException: System.ObjectDisposedException
Message=The socket connection has been disposed. Object name: 'System.ServiceModel.Channels.SocketConnection'.
ObjectName=System.ServiceModel.Channels.SocketConnection
InnerException:
Did you try to increase the maximum message sizes in the client and server configurations?
You can also have a look at the server to see if an exception has been logged.
The parameter named MaxSerializedObjectsInGraph may also reach its limit when serializing a lot of objects.
This can happen when the server cannot serialise the result object.
Make sure there is no exceptions on serialisation.