Getting ProtocolException with running DotNetOpenAuth sample - c#

I have downloaded DotNetOpenAuth-3.4.6.10357 built it (had to exclude OpenIdOfflineProvider because of build errors) and run OAuthConsumerWpf. After clicking Authorize I got the exception below. Please bear in mind I modified app.config as instructed. This is from the Google tab. I also tried Generic tab with the same results.
What could be wrong here? Shouldn't things as simple as this work out of the box?
DotNetOpenAuth.Messaging.ProtocolException was unhandled
Message=Error occurred while sending a direct message or getting the response.
Source=DotNetOpenAuth
StackTrace:
at DotNetOpenAuth.Messaging.StandardWebRequestHandler.GetResponse(HttpWebRequest request, DirectWebRequestOptions options) in c:\Users\andarno\git\dotnetopenid\src\DotNetOpenAuth\Messaging\StandardWebRequestHandler.cs:line 172
at DotNetOpenAuth.Messaging.StandardWebRequestHandler.GetResponse(HttpWebRequest request) in c:\Users\andarno\git\dotnetopenid\src\DotNetOpenAuth\Messaging\StandardWebRequestHandler.cs:line 100
at DotNetOpenAuth.Messaging.Channel.GetDirectResponse(HttpWebRequest webRequest) in c:\Users\andarno\git\dotnetopenid\src\DotNetOpenAuth\Messaging\Channel.cs:line 607
at DotNetOpenAuth.Messaging.Channel.RequestCore(IDirectedProtocolMessage request) in c:\Users\andarno\git\dotnetopenid\src\DotNetOpenAuth\Messaging\Channel.cs:line 628
at DotNetOpenAuth.Messaging.Channel.Request(IDirectedProtocolMessage requestMessage) in c:\Users\andarno\git\dotnetopenid\src\DotNetOpenAuth\Messaging\Channel.cs:line 451
at DotNetOpenAuth.Messaging.Channel.Request[TResponse](IDirectedProtocolMessage requestMessage) in c:\Users\andarno\git\dotnetopenid\src\DotNetOpenAuth\Messaging\Channel.cs:line 431
at DotNetOpenAuth.OAuth.ConsumerBase.PrepareRequestUserAuthorization(Uri callback, IDictionary`2 requestParameters, IDictionary`2 redirectParameters, String& requestToken) in c:\Users\andarno\git\dotnetopenid\src\DotNetOpenAuth\OAuth\ConsumerBase.cs:line 222
at DotNetOpenAuth.OAuth.DesktopConsumer.RequestUserAuthorization(IDictionary`2 requestParameters, IDictionary`2 redirectParameters, String& requestToken) in c:\Users\andarno\git\dotnetopenid\src\DotNetOpenAuth\OAuth\DesktopConsumer.cs:line 42
at DotNetOpenAuth.ApplicationBlock.GoogleConsumer.RequestAuthorization(DesktopConsumer consumer, Applications requestedAccessScope, String& requestToken) in C:\Users\user\Desktop\DotNetOpenAuth-3.4.6.10357\Samples\DotNetOpenAuth.ApplicationBlock\GoogleConsumer.cs:line 204
at DotNetOpenAuth.Samples.OAuthConsumerWpf.MainWindow.<beginAuthorizationButton_Click>b__3(DesktopConsumer consumer, String& requestToken) in C:\Users\user\Desktop\DotNetOpenAuth-3.4.6.10357\Samples\OAuthConsumerWpf\MainWindow.xaml.cs:line 92
at DotNetOpenAuth.Samples.OAuthConsumerWpf.Authorize.<>c__DisplayClass4.<.ctor>b__0(Object state) in C:\Users\user\Desktop\DotNetOpenAuth-3.4.6.10357\Samples\OAuthConsumerWpf\Authorize.xaml.cs:line 33
at System.Threading._ThreadPoolWaitCallback.WaitCallback_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading._ThreadPoolWaitCallback.PerformWaitCallbackInternal(_ThreadPoolWaitCallback tpWaitCallBack)
at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback(Object state)
InnerException: System.Net.WebException
Message=The remote server returned an error: (400) Bad Request.
Source=System
StackTrace:
at System.Net.HttpWebRequest.GetResponse()
at DotNetOpenAuth.Messaging.StandardWebRequestHandler.GetResponse(HttpWebRequest request, DirectWebRequestOptions options) in c:\Users\andarno\git\dotnetopenid\src\DotNetOpenAuth\Messaging\StandardWebRequestHandler.cs:line 126
InnerException:

Works for me. Perhaps your computer is behind a firewall or needs a proxy server registered?

Related

An unhandled exception was generated during the execution of the current web request.[HttpAntiForgeryException]

I have a C# .NET MVC app and I am getting "anti-forgery token could not be decrypted". I don't know where the error is and I need help resolving this issue. And I am running this application on my localhost. Below is the error I am getting.
Server Error in '/' Application.
The anti-forgery token could not be decrypted. If this application is hosted by a Web Farm or cluster, ensure that all machines are running the same version of ASP.NET Web Pages and that the <machineKey> configuration specifies explicit encryption and validation keys. AutoGenerate cannot be used in a cluster.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Web.Mvc.HttpAntiForgeryException: The anti-forgery token could not be decrypted. If this application is hosted by a Web Farm or cluster, ensure that all machines are running the same version of ASP.NET Web Pages and that the <machineKey> configuration specifies explicit encryption and validation keys. AutoGenerate cannot be used in a cluster.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[HttpAntiForgeryException (0x80004005): The anti-forgery token could not be decrypted. If this application is hosted by a Web Farm or cluster, ensure that all machines are running the same version of ASP.NET Web Pages and that the <machineKey> configuration specifies explicit encryption and validation keys. AutoGenerate cannot be used in a cluster.]
System.Web.Helpers.AntiXsrf.AntiForgeryTokenSerializer.Deserialize(String serializedToken) +337
System.Web.Helpers.AntiXsrf.AntiForgeryTokenStore.GetFormToken(HttpContextBase httpContext) +91
System.Web.Helpers.AntiXsrf.AntiForgeryWorker.Validate(HttpContextBase httpContext) +44
System.Web.Helpers.AntiForgery.Validate() +92
System.Web.Mvc.ValidateAntiForgeryTokenAttribute.OnAuthorization(AuthorizationContext filterContext) +18
System.Web.Mvc.ControllerActionInvoker.InvokeAuthorizationFilters(ControllerContext controllerContext, IList`1 filters, ActionDescriptor actionDescriptor) +97
System.Web.Mvc.Async.<>c__DisplayClass21.<BeginInvokeAction>b__19(AsyncCallback asyncCallback, Object asyncState) +743
System.Web.Mvc.Async.WrappedAsyncResult`1.CallBeginDelegate(AsyncCallback callback, Object callbackState) +14
System.Web.Mvc.Async.WrappedAsyncResultBase`1.Begin(AsyncCallback callback, Object state, Int32 timeout) +128
System.Web.Mvc.Async.AsyncControllerActionInvoker.BeginInvokeAction(ControllerContext controllerContext, String actionName, AsyncCallback callback, Object state) +343
System.Web.Mvc.Controller.<BeginExecuteCore>b__1c(AsyncCallback asyncCallback, Object asyncState, ExecuteCoreState innerState) +25
System.Web.Mvc.Async.WrappedAsyncVoid`1.CallBeginDelegate(AsyncCallback callback, Object callbackState) +30
System.Web.Mvc.Async.WrappedAsyncResultBase`1.Begin(AsyncCallback callback, Object state, Int32 timeout) +128
System.Web.Mvc.Controller.BeginExecuteCore(AsyncCallback callback, Object state) +465
System.Web.Mvc.Controller.<BeginExecute>b__14(AsyncCallback asyncCallback, Object callbackState, Controller controller) +18
System.Web.Mvc.Async.WrappedAsyncVoid`1.CallBeginDelegate(AsyncCallback callback, Object callbackState) +20
System.Web.Mvc.Async.WrappedAsyncResultBase`1.Begin(AsyncCallback callback, Object state, Int32 timeout) +128
System.Web.Mvc.Controller.BeginExecute(RequestContext requestContext, AsyncCallback callback, Object state) +374
System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.BeginExecute(RequestContext requestContext, AsyncCallback callback, Object state) +16
System.Web.Mvc.MvcHandler.<BeginProcessRequest>b__4(AsyncCallback asyncCallback, Object asyncState, ProcessRequestState innerState) +52
System.Web.Mvc.Async.WrappedAsyncVoid`1.CallBeginDelegate(AsyncCallback callback, Object callbackState) +30
System.Web.Mvc.Async.WrappedAsyncResultBase`1.Begin(AsyncCallback callback, Object state, Int32 timeout) +128
System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContextBase httpContext, AsyncCallback callback, Object state) +384
System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContext httpContext, AsyncCallback callback, Object state) +48
System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.BeginProcessRequest(HttpContext context, AsyncCallback cb, Object extraData) +16
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +103
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155
When ASP.NET generates the token, it uses some machine key for that. If you later try to decrypt that token with another key, you will get this type of exception.
It is very strange that you can get this by just running localhost, since this usually happens on a load balanced scenario e.g. when you have not set up the machine key to be the same.
Another possible reason is that you manipulate the token on the frontend somehow or get the web page from another machine, though both scenarios seem to be unlikely.
Anyway, if you have troubles with the load balancing or something like this, you need to set up the same machine key in all web.config files.

Upload Large File In MVC Encountered an Error

I have a .txt file that the size up to 2GB, i want to upload that file from client to a folder in a server, while uploading that file, there is an error, this is what the page says:
An operation was attempted on a nonexistent network connection. (Exception from HRESULT: 0x800704CD)
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Runtime.InteropServices.COMException: An operation was attempted on a nonexistent network connection. (Exception from HRESULT: 0x800704CD)
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[COMException (0x800704cd): An operation was attempted on a nonexistent network connection. (Exception from HRESULT: 0x800704CD)]
[HttpException (0x80004005): An error occurred while communicating with the remote host. The error code is 0x800704CD.]
System.Web.Hosting.IIS7WorkerRequest.RaiseCommunicationError(Int32 result, Boolean throwOnDisconnect) +3399867
System.Web.Hosting.IIS7WorkerRequest.ReadEntityCoreSync(Byte[] buffer, Int32 offset, Int32 size) +9621484
System.Web.Hosting.IIS7WorkerRequest.ReadEntityBody(Byte[] buffer, Int32 size) +24
System.Web.HttpRequest.GetEntireRawContent() +315
System.Web.HttpRequest.GetMultipartContent() +63
System.Web.HttpRequest.FillInFormCollection() +160
System.Web.HttpRequest.EnsureForm() +69
System.Web.HttpRequest.get_Form() +13
System.Web.HttpRequestWrapper.get_Form() +14
System.Web.Mvc.HttpRequestExtensions.GetHttpMethodOverride(HttpRequestBase request) +121
System.Web.Mvc.AcceptVerbsAttribute.IsValidForRequest(ControllerContext controllerContext, MethodInfo methodInfo) +37
System.Web.Mvc.HttpGetAttribute.IsValidForRequest(ControllerContext controllerContext, MethodInfo methodInfo) +39
System.Web.Mvc.ActionMethodSelectorBase.IsValidMethodSelector(ReadOnlyCollection`1 attributes, ControllerContext controllerContext, MethodInfo method) +54
System.Web.Mvc.ActionMethodSelectorBase.RunSelectionFilters(ControllerContext controllerContext, List`1 methodInfos) +132
System.Web.Mvc.ActionMethodSelectorBase.FindActionMethods(ControllerContext controllerContext, String actionName) +142
System.Web.Mvc.ActionMethodSelectorBase.FindActionMethod(ControllerContext controllerContext, String actionName) +104
System.Web.Mvc.Async.ReflectedAsyncControllerDescriptor.FindAction(ControllerContext controllerContext, String actionName) +54
System.Web.Mvc.ControllerActionInvoker.FindAction(ControllerContext controllerContext, ControllerDescriptor controllerDescriptor, String actionName) +16
System.Web.Mvc.Async.AsyncControllerActionInvoker.BeginInvokeAction(ControllerContext controllerContext, String actionName, AsyncCallback callback, Object state) +114
System.Web.Mvc.Controller.<BeginExecuteCore>b__1c(AsyncCallback asyncCallback, Object asyncState, ExecuteCoreState innerState) +25
System.Web.Mvc.Async.WrappedAsyncVoid`1.CallBeginDelegate(AsyncCallback callback, Object callbackState) +30
System.Web.Mvc.Async.WrappedAsyncResultBase`1.Begin(AsyncCallback callback, Object state, Int32 timeout) +128
System.Web.Mvc.Controller.BeginExecuteCore(AsyncCallback callback, Object state) +468
System.Web.Mvc.Controller.<BeginExecute>b__14(AsyncCallback asyncCallback, Object callbackState, Controller controller) +18
System.Web.Mvc.Async.WrappedAsyncVoid`1.CallBeginDelegate(AsyncCallback callback, Object callbackState) +20
System.Web.Mvc.Async.WrappedAsyncResultBase`1.Begin(AsyncCallback callback, Object state, Int32 timeout) +128
System.Web.Mvc.Controller.BeginExecute(RequestContext requestContext, AsyncCallback callback, Object state) +374
System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.BeginExecute(RequestContext requestContext, AsyncCallback callback, Object state) +16
System.Web.Mvc.MvcHandler.<BeginProcessRequest>b__3(AsyncCallback asyncCallback, Object asyncState, ProcessRequestState innerState) +52
System.Web.Mvc.Async.WrappedAsyncVoid`1.CallBeginDelegate(AsyncCallback callback, Object callbackState) +30
System.Web.Mvc.Async.WrappedAsyncResultBase`1.Begin(AsyncCallback callback, Object state, Int32 timeout) +128
System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContextBase httpContext, AsyncCallback callback, Object state) +384
System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContext httpContext, AsyncCallback callback, Object state) +48
System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.BeginProcessRequest(HttpContext context, AsyncCallback cb, Object extraData) +16
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +103
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155
And this is some of the code:
public ActionResult UploadFile_Post(FormCollection dt, string btn, HttpPostedFileBase uploadFile, FileUpload dataFile)
{
string nameFile, getExtension = "";
nameFile = System.IO.Path.GetFileNameWithoutExtension(uploadFile.FileName.ToString().Trim()) + "_" + usernm.Trim() + "_" + DateTime.Now.ToString("yyyyMMdd_HHmmss").Trim();
getExtension = System.IO.Path.GetExtension(uploadFile.FileName.ToString().Trim());
string FilePath = Server.MapPath("~\\Upload\\" + nameFile + ".txt");
string pathFile = Server.MapPath("~\\Upload\\");
if (System.IO.File.Exists(FilePath))
{
System.IO.File.Delete(FilePath);
}
uploadFile.SaveAs(FilePath);//i think failed at this process
}
In the Web.config file, i already set the configuration for maxRequestLength , executionTimeout, and maxAllowedContentLength.
Maybe my code is wrong, can you guys give me the better way to upload such file?
Thank You,
Sorry for my bad english.
<system.web>
<httpRuntime executionTimeout="3600" maxRequestLength="102400"
appRequestQueueLimit="100" requestLengthDiskThreshold="10024000"/>
</system.web>
executionTimeout : Specifies the maximum number of seconds that a request is allowed to execute before being automatically shut down by ASP.NET.
maxRequestLength : Specifies the limit for the input stream buffering threshold, in KB
appRequestQueueLimit : Specifies the maximum number of requests that ASP.NET queues for the application.
requestLengthDiskThreshold: Specifies the limit for the input stream buffering threshold, in bytes. This value should not exceed the maxRequestLength attribute.
Change these setting and see what happens. It also would be nice to know the version of IIS you are using.
https://msdn.microsoft.com/en-us/library/e1f13641%28v=vs.100%29.aspx
You should never allow an upload of a file that large to a web server because it will take up all the memory and crash your web server. Remember that when you upload file to a web server, all that data gets stored in memory while its trying to write to your database or your file system. For files that large, you need to upload the file via file streaming or via FTP. If you google Jon Galloway, he might have some answers for you on other ways to upload large files.

Unhandled Aggregate Exception

I have followed the tutorial in ( http://www.c-sharpcorner.com/UploadFile/a6fd36/understand-self-host-of-a-web-apiC-Sharp/ ) and ( http://www.c-sharpcorner.com/uploadfile/a6fd36/understanding-how-to-call-the-web-api-from-a-client-applica/ ) but seem to still be getting System.AggregateException on
//Call HttpClient.GetAsync to send a GET request to the appropriate URI
HttpResponseMessage resp = client.GetAsync("api/books").Result;
and
var resp = client.GetAsync(string.Format("api/books/{0}", id)).Result;
and
var resp = client.GetAsync(query).Result;
The error states: An unhandled exception of type 'System.AggregateException' occurred in mscorlib.dll
Exception Detail -
System.AggregateException was unhandled
HResult=-2146233088
Message=One or more errors occurred.
Source=mscorlib
StackTrace:
at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)
at System.Threading.Tasks.Task`1.get_Result()
at TestClient.Program.ListAllBooks() in c:\Users\wa\Documents\Visual Studio 2013\Projects\SelfHost\TestClient\Program.cs:line 35
at TestClient.Program.Main(String[] args) in c:\Users\wa\Documents\Visual Studio 2013\Projects\SelfHost\TestClient\Program.cs:line 20
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
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.Threading.ThreadHelper.ThreadStart()
InnerException: System.Net.Http.HttpRequestException
HResult=-2146233088
Message=An error occurred while sending the request.
InnerException: System.Net.WebException
HResult=-2146233079
Message=Unable to connect to the remote server
Source=System
StackTrace:
at System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
at System.Net.Http.HttpClientHandler.GetResponseCallback(IAsyncResult ar)
InnerException: System.Net.Sockets.SocketException
HResult=-2147467259
Message=No connection could be made because the target machine actively refused it [::1]:8080
Source=System
ErrorCode=10061
NativeErrorCode=10061
StackTrace:
at System.Net.Sockets.Socket.EndConnect(IAsyncResult asyncResult)
at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Exception& exception)
InnerException:
Any Ideas?
Thank You
Please read the last line :)
InnerException: System.Net.WebException
HResult=-2146233079
Message=Unable to connect to the remote server

C# SignalR within a class library

I've been developing a Web Service (C# WebAPI2) so can simply send messages using SignalR and then store the message transcript within a TSQL database. However, after moving the SignalR hubs within a class library I can't seem to access them now. I have developed a very simply console application to communicate with the Web Service but I am getting a strange exception being thrown.
Here is the exception which is being thrown:
"StatusCode: 500, ReasonPhrase: 'Internal Server Error', Version: 1.1,
Content: System.Net.Http.StreamContent, Headers:\r\n{\r\n
Transfer-Encoding: chunked\r\n X-SourceFiles:
=?UTF-8?B?QzpcRGV2ZWxvcG1lbnRcU291cmNlQ29kZVxTVVBTZXJ2aWNlXFNVUC5TZXJ2aWNlXHNpZ25hbHJcbmVnb3RpYXRl?=\r\n
Cache-Control: private\r\n Date: Wed, 11 Mar 2015 10:50:18 GMT\r\n
Server: Microsoft-IIS/8.0\r\n X-AspNet-Version: 4.0.30319\r\n
X-Powered-By: ASP.NET\r\n Content-Type: text/html;
charset=utf-8\r\n}"
An unhandled exception of type 'System.AggregateException' occurred
in SignalR Client Connection.exe
The Owin Startup file is placed within the Web Service App_Start folder, here is what it looks like:
using System;
using System.Threading.Tasks;
using Microsoft.Owin;
using Owin;
using Microsoft.AspNet.SignalR;
[assembly: OwinStartup(typeof(Service.App_Start.Startup))]
namespace Service.App_Start
{
public class Startup
{
public void Configuration(IAppBuilder app)
{
app.Map("/signalr", map =>
{
var hubConfiguration = new HubConfiguration
{
EnableDetailedErrors = true,
EnableJSONP = true
};
map.RunSignalR(hubConfiguration);
});
}
}
}
Many thanks.
I am not sure the details in your case, but for me I found that I was receiving the System.AggregationException:
System.AggregateException was unhandled
HResult=-2146233088
Message=One or more errors occurred.
Source=mscorlib
StackTrace:
at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
at System.Threading.Tasks.Task.Wait()
at Client.CommunicationHandler.AddMessage(String method, String args, String serverUri, String hubName) in c:\Workspace\EnvisionRealTimeRemoteOps\CodeProjectSelfHostedBroadcastServiceSignalRSample\Client\CommunicationHandler.cs:line 24
at Client.Program.Main(String[] args) in c:\Workspace\EnvisionRealTimeRemoteOps\CodeProjectSelfHostedBroadcastServiceSignalRSample\Client\Program.cs:line 15
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
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.Threading.ThreadHelper.ThreadStart()
InnerException: System.Net.Http.HttpRequestException
HResult=-2146233088
Message=An error occurred while sending the request.
InnerException: System.Net.WebException
HResult=-2146233079
Message=Unable to connect to the remote server
Source=System
StackTrace:
at System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
at System.Net.Http.HttpClientHandler.GetResponseCallback(IAsyncResult ar)
InnerException: System.Net.Sockets.SocketException
HResult=-2147467259
Message=No connection could be made because the target machine actively refused it 127.0.0.1:8083
Source=System
ErrorCode=10061
NativeErrorCode=10061
StackTrace:
at System.Net.Sockets.Socket.EndConnect(IAsyncResult asyncResult)
at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Exception& exception)
InnerException:
Until I added a call to the following:
WebApp.Start("http://localhost:8083"); // Put your desired URL in...
Please note that in my case my application is using Self-Hosted SignalR.

Random double Web Requests C# IIS7 PollLockedSessionCallback

I sometimes have double web requests (no double clickers).
Can anyone please tell me what causes them, so I can prevent them?
initial situation:
It is a .Net 3.5 C# Application running in IIS7. No Asp.Net with ViewState. Just PageHandlers with
Xml/Xslt Transformations.
The code is very old. This problem just appeared out of the blue some time ago.
We send emails there and thats how it popped up. We sometimes suddenly received two mails instead of one.
My observations so far:
It happens seldom, but nonetheless sometimes. Apparently random.
The Sent Bytes at the first Request are 0, but they are not double clickers. HttpContext.Current.Response.IsClientConnected is true.
My assumptions so far:
It seems that something goes wrong in the SessionHandling (via Sql-Server) and this reopens the request?
IIS Log:
2012-03-02 08:16:43 W3SVC9026 [Server] [Server IP] POST [Internal URL] - 80 - [Client IP] HTTP/1.1 Mozilla/4.0+(compatible;+MSIE+8.0;+Windows+NT+5.1;+Trident/4.0;+AskTbORJ/5.14.1.20007) ASP.NET_SessionId=[Session Id] [Absolute URL] [Host name] 200 0 64 0 899 937
2012-03-02 08:16:43 W3SVC9026 [Server] [Server IP] POST [internal URL] - 80 - [Client IP] HTTP/1.1 Mozilla/4.0+(compatible;+MSIE+8.0;+Windows+NT+5.1;+Trident/4.0;+AskTbORJ/5.14.1.20007) ASP.NET_SessionId=[Session Id] [Absolute URL] [Host name] 200 0 0 45888 923 1343
StackTrace:
08:16:43 Regular Request (All normal requests which only run once look that way too)
at System.Environment.get_StackTrace()
at [MyPageHandler.ProcessRequest(HttpContext httpContext) and so on]
at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
at System.Web.HttpApplication.ApplicationStepManager.ResumeSteps(Exception error)
at System.Web.HttpApplication.System.Web.IHttpAsyncHandler.BeginProcessRequest(HttpContext context, AsyncCallback cb, Object extraData)
at System.Web.HttpRuntime.ProcessRequestInternal(HttpWorkerRequest wr)
at System.Web.HttpRuntime.ProcessRequestNoDemand(HttpWorkerRequest wr)
at System.Web.Hosting.ISAPIRuntime.ProcessRequest(IntPtr ecb, Int32 iWRType)
08:16:44 Additional Request
at System.Environment.get_StackTrace()
at [MyPageHandler.ProcessRequest(HttpContext httpContext) and so on]
at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
at System.Web.HttpApplication.ApplicationStepManager.ResumeSteps(Exception error)
at System.Web.HttpApplication.ResumeStepsFromThreadPoolThread(Exception error)
at System.Web.HttpApplication.AsyncEventExecutionStep.ResumeStepsWithAssert(Exception error)
at System.Web.HttpApplication.AsyncEventExecutionStep.OnAsyncEventCompletion(IAsyncResult ar)
at System.Web.HttpAsyncResult.Complete(Boolean synchronous, Object result, Exception error, RequestNotificationStatus status)
at System.Web.SessionState.SessionStateModule.PollLockedSessionCallback(Object state)
at System.Threading.ExecutionContext.runTryCode(Object userData)
at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading._TimerCallback.PerformTimerCallback(Object state)

Categories

Resources