SignalR not working when deployed on remote machine - c#

I developing a web chat application, and having a weird problem. the application is working fine on my local machine but just stuck on remote machine.
totally im lost, how to provide clue about my problem (please advice if there are trick to trace the problem), the only error i got from $.connection.hub.error is
Protocol error: Unknown transport.
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.InvalidOperationException: Protocol error: Unknown transport.
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:
[InvalidOperationException: Protocol error: Unknown transport.]
Microsoft.AspNet.SignalR.PersistentConnection.ProcessRequest(HostContext context) +866
Microsoft.AspNet.SignalR.Hubs.HubDispatcher.ProcessRequest(HostContext context) +174
Microsoft.AspNet.SignalR.Owin.CallHandler.Invoke(IDictionary`2 environment) +628
Microsoft.AspNet.SignalR.Owin.Handlers.HubDispatcherHandler.Invoke(IDictionary`2 environment) +222
Microsoft.Owin.Host.SystemWeb.OwinCallContext.Execute() +55
Microsoft.Owin.Host.SystemWeb.OwinHttpHandler.BeginProcessRequest(HttpContextBase httpContext, AsyncCallback callback, Object extraData) +259
[TargetInvocationException: Exception has been thrown by the target of an invocation.]
Microsoft.Owin.Host.SystemWeb.CallContextAsyncResult.End(IAsyncResult result) +110
Microsoft.Owin.Host.SystemWeb.OwinHttpHandler.EndProcessRequest(IAsyncResult result) +7
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +8836913
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +184
and here is what the console log provided.
SignalR: Negotiating with '<root_url>/signalr/negotiate'. jquery.signalR-1.0.0-rc2.js:54
SignalR: Attempting to connect to SSE endpoint '<root_url>/signalr/connect?transport=serverSentEv…2fc32a4&connectionData=%5B%7B%22name%22%3A%22xmppservicehub%22%7D%5D&tid=7' jquery.signalR-1.0.0-rc2.js:54
SignalR: EventSource timed out trying to connect jquery.signalR-1.0.0-rc2.js:54
SignalR: EventSource readyState: 0 jquery.signalR-1.0.0-rc2.js:54
SignalR: EventSource calling close() jquery.signalR-1.0.0-rc2.js:54
SignalR: This browser supports SSE, skipping Forever Frame. jquery.signalR-1.0.0-rc2.js:54
SignalR: SignalR: Initializing long polling connection with server. jquery.signalR-1.0.0-rc2.js:54
SignalR: Attempting to connect to '<root_url>/signalr/connect?transport=longPolling&…fc32a4&connectionData=%5B%7B%22name%22%3A%22xmppservicehub%22%7D%5D&tid=10' using longPolling. jquery.signalR-1.0.0-rc2.js:54
SignalR: Longpolling connected jquery.signalR-1.0.0-rc2.js:54
SignalR: Attempting to connect to '<root_url>/signalr?transport=longPolling&connecti…%7CS%2C1%7CT%2C0%7CQ%2C0&groups=%5B%22XmppServiceHub.howtodemo%22%5D&tid=2' using longPolling. jquery.signalR-1.0.0-rc2.js:54
SignalR: Attempting to connect to '<root_url>/signalr?transport=longPolling&connecti…%7CR%2C0%7CS%2C1%7CT%2C0&groups=%5B%22XmppServiceHub.howtodemo%22%5D&tid=8' using longPolling. jquery.signalR-1.0.0-rc2.js:54
SignalR: Attempting to connect to '<root_url>/signalr?transport=longPolling&connecti…%7CR%2C0%7CS%2C1%7CT%2C0&groups=%5B%22XmppServiceHub.howtodemo%22%5D&tid=5' using longPolling. jquery.signalR-1.0.0-rc2.js:54
SignalR: An error occurred using longPolling. Status = error. <html>
<head>
<title>Protocol error: Unknown transport.</title>
FYI:
Server side is a SignalR Hub with readonly session described
here
Asp.Net MVC 4
IIS 6 Webserver
I'm lost about how to provide any clue, if those information not enough please tell me what info should i provide more.
EDIT
After update with the latest libs from nuget (version 1.0.0) i got the following eror (still the same console log, still working fine on local machine but on remote machine)
[ObjectDisposedException]: The CancellationTokenSource has been disposed.
Server stack trace:
at System.Threading.CancellationTokenSource.ThrowIfDisposed()
at System.Threading.CancellationTokenRegistration.Dispose()
at Microsoft.AspNet.SignalR.Infrastructure.CancellationTokenExtensions.<>c__DisplayClass6`1.<SafeRegister>b__1()
at Microsoft.AspNet.SignalR.Infrastructure.DisposableAction.Dispose(Boolean disposing)
at Microsoft.AspNet.SignalR.Infrastructure.DisposableAction.Dispose()
at Microsoft.AspNet.SignalR.Transports.TransportHeartbeat.EndConnection(ConnectionMetadata metadata)
at Microsoft.AspNet.SignalR.Transports.TransportHeartbeat.AddConnection(ITrackingConnection connection)
at Microsoft.AspNet.SignalR.Transports.LongPollingTransport.ProcessRequest(ITransportConnection connection)
at Microsoft.AspNet.SignalR.PersistentConnection.ProcessRequest(HostContext context)
at Microsoft.AspNet.SignalR.Hubs.HubDispatcher.ProcessRequest(HostContext context)
at Microsoft.AspNet.SignalR.Owin.CallHandler.Invoke(IDictionary`2 environment)
at Microsoft.AspNet.SignalR.Owin.Handlers.HubDispatcherHandler.Invoke(IDictionary`2 environment)
at Microsoft.Owin.Host.SystemWeb.OwinCallContext.Execute()
at Microsoft.Owin.Host.SystemWeb.OwinHttpHandler.BeginProcessRequest(HttpContextBase httpContext, AsyncCallback callback, Object extraData)
Exception rethrown at [0]:
at Microsoft.Owin.Host.SystemWeb.Utils.<>c__DisplayClass1.<GetRethrowWithNoStackLossDelegate>b__0(Exception ex)
at Microsoft.Owin.Host.SystemWeb.Utils.RethrowWithOriginalStack(Exception ex)
at Microsoft.Owin.Host.SystemWeb.CallContextAsyncResult.End(IAsyncResult result)
at Microsoft.Owin.Host.SystemWeb.OwinHttpHandler.EndProcessRequest(IAsyncResult result)
at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
Thanks in advance

SignalR does not support < IIS 7.
Edit:
We do not support IIS < 7 but there are configurations that can be setup in order to support it.
It looks like your application is working but you're running into this issue here https://github.com/SignalR/SignalR/issues/1549, it's been fixed in the next release.

Transport issue also come when you are providing Wrong Hub URL. Even if you add one extra forward slash at the end of URL this issue occurs.

Related

DotNetCore SocketException "Cannot assign requested address" SmtpClient

I have an dotnet 5 service that sends emails using the SmtpClient. This service is deployed as a linux docker image running in AWS EKS (Kubernetes).
Running locally on my machine, everything works fine, but when it's deployed to our K8s environment, every SmtpClient.SentAsync call sits for around 10 minutes, before it finally crashes with the following exception:
System.Net.Mail.SmtpException: Failure sending mail.
---> System.Net.Sockets.SocketException (99): Cannot assign requested address
I've researched this error, and there is a lot of talk about using/not using localhost as a host name. In my case, I'm not using local host at all. I'm just trying to send outbound emails using SmtpClient, where the host is a 3rd party SMTP server.
I've tried running this as a linux docker container on my own dev machine, and it also works fine, so it seems to not like something about my EKS environment, yet I can't figure out what that is. Any ideas?
Update:
FYI, the pod can access the internet just fine, using the HttpClient for example. I can also make http calls to it's API on port 80. So it's binding just fine in that regard. It just seems to be an issue when using the SmtpClient.
Stack Track:
System.Net.Mail.SmtpException: Failure sending mail.
---> System.Net.Sockets.SocketException (99): Cannot assign requested address
at System.Net.Sockets.Socket.BeginConnectEx(EndPoint remoteEP, Boolean flowContext, AsyncCallback callback, Object state)
at System.Net.Sockets.Socket.UnsafeBeginConnect(EndPoint remoteEP, AsyncCallback callback, Object state, Boolean flowContext)
at System.Net.Sockets.Socket.PostOneBeginConnect(MultipleAddressConnectAsyncResult context)
--- End of stack trace from previous location ---
at System.Net.Sockets.Socket.DoMultipleAddressConnectCallback(Object result, MultipleAddressConnectAsyncResult context)
at System.Net.Sockets.Socket.MultipleAddressConnectCallback(IAsyncResult result)
--- End of stack trace from previous location ---
at System.Net.Sockets.Socket.EndConnect(IAsyncResult asyncResult)
at System.Net.Sockets.TcpClient.EndConnect(IAsyncResult asyncResult)
at System.Net.Mail.SmtpConnection.ConnectAndHandshakeAsyncResult.InitializeConnectionCallback(IAsyncResult result)
--- End of stack trace from previous location ---
at System.Net.Mail.SmtpConnection.ConnectAndHandshakeAsyncResult.End(IAsyncResult result)
at System.Net.Mail.SmtpClient.ConnectCallback(IAsyncResult result)
...

Intermittent SocketException while trying to contact external web service from Azure web app

I'm encountering a situation on production that is difficult to debug.
Sometimes the connection to an external service can't be established with the following error:
System.Net.Http.HttpRequestException: An error occurred while sending the request. ---> System.Net.WebException: Unable to connect to the remote server ---> System.Net.Sockets.SocketException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 93.39.196.220:443
at System.Net.Sockets.Socket.InternalEndConnect(IAsyncResult asyncResult)
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)
--- End of inner exception stack trace ---
at System.Net.HttpWebRequest.EndGetRequestStream(IAsyncResult asyncResult, TransportContext& context)
at System.Net.Http.HttpClientHandler.GetRequestStreamCallback(IAsyncResult ar)
--- End of inner exception stack trace ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
Sometimes it works without any problem. This is what I've tried:
Replacing the way I perform the connection (from Restsharp to HttpClient)
HttpClient is long lived as suggested by this post
Adjusting the timeout
Using async and sync code
Analyzing SNAT Port exhaustion
More info:
The IPs of my server are authorized by the external service (and if they weren't I would be receiving a different error)
While on production I'm having the problem I'm able to connect to the service from development or staging (so it shouldn't be a problem with the external service)
While I'm having trouble contacting this service I don't have trouble contacting a different (but similar) service
I'm on a Web App Service on Azure. I'm using the .NET framework 4.7.2
The same code sometimes works and sometimes it doesn't
This is (more or less) the current iteration
private async Task<ResultSet> SendRequestAsync(HttpClient client, RateRequestBody document){
ServicePointManager.SecurityProtocol |= SecurityProtocolType.Tls12;
var response = await client.PostAsXmlAsync(baseUrl + "/XMLServices", document);
if (response.IsSuccessStatusCode){
...
}else{
...
}
}
Any ideas on what I might have missed?
Thanks
The answer may lay here: Default SecurityProtocol in .NET 4.5
Assuming both servers are operating correctly, one works fine with your client code and the other gives you problems based on your 'More Info' section: "While I'm having trouble contacting this service I don't have trouble contacting a different (but similar) service"
I recommend removing or commenting out the following line and giving it a try:
//ServicePointManager.SecurityProtocol |= SecurityProtocolType.Tls12;
...or replace it with:
ServicePointManager.SecurityProtocol |= SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;

ASP.NET Core w/ EF Core API returning "Failed to authenticate HTTPS connection." From Postman Get request

As an exercise in learning EF Core with C#/ASP.NET Core, I went through this tutorial to the end: ASP.NET Core Web API with EF Core Code-First Approach.
Once I finished I was able to go and run 'dotnet watch run' from the source folder, and loading up the end point http://localhost:5000/api/employee I was able to get back a response in Chrome, from a redirect to the https://localhost:5001/api/employee endpoint.
I'm stuck because I want to get that same response in Postman, but I'm just seeing the following:
This is what I see from Powershell where I'm running the server:
PS C:\Users\foo\source\repos\EFCoreCodeFirstSample\EFCoreCodeFirstSample> dotnet watch run
watch : Started
info: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[0]
User profile is available. Using 'C:\Users\C M\AppData\Local\ASP.NET\DataProtection-Keys' as key repository and Windows DPAPI to encrypt keys at rest.
Hosting environment: Development
Content root path: C:\Users\foo\source\repos\EFCoreCodeFirstSample\EFCoreCodeFirstSample
Now listening on: http://localhost:5000
Now listening on: https://localhost:5001
Application started. Press Ctrl+C to shut down.
dbug: HttpsConnectionAdapter[1]
Failed to authenticate HTTPS connection.
System.IO.IOException: Authentication failed because the remote party has closed the transport stream.
at System.Net.Security.SslState.StartReadFrame(Byte[] buffer, Int32 readBytes, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.PartialFrameCallback(AsyncProtocolRequest asyncRequest)
--- End of stack trace from previous location where exception was thrown ---
at System.Net.Security.SslState.ThrowIfExceptional()
at System.Net.Security.SslState.InternalEndProcessAuthentication(LazyAsyncResult lazyResult)
at System.Net.Security.SslState.EndProcessAuthentication(IAsyncResult result)
at System.Net.Security.SslStream.EndAuthenticateAsServer(IAsyncResult asyncResult)
at System.Net.Security.SslStream.<>c.<AuthenticateAsServerAsync>b__51_1(IAsyncResult iar)
at System.Threading.Tasks.TaskFactory`1.FromAsyncCoreLogic(IAsyncResult iar, Func`2 endFunction, Action`1 endAction, Task`1 promise, Boolean requiresSynchronization)
--- End of stack trace from previous location where exception was thrown ---
at Microsoft.AspNetCore.Server.Kestrel.Https.Internal.HttpsConnectionAdapter.InnerOnConnectionAsync(ConnectionAdapterContext context)
Everything from
dbug: HttpsConnectionAdapter[1]
Failed to authenticate HTTPS connection
and below shows up when I run the Postman Get request. I'm guessing it has something to do with how my startup.cs is configured... but I'm not sure where to start. Searching on Stack Overflow here got me a lot of questions regarding SSL certs, and pfx files, but nothing pertaining to this issue in particular. I'm new to this and in school, so maybe I simply missed the answer because it's beyond my scope of knowledge at this point? I don't understand why it would work in chrome, but not Postman.

Microsoft Azure Service Bus Timeout Exceptions

We have an application that runs on the Microsoft Azure cloud platform. The communication between some components is made using Service Bus. Everything was working fine, until recently we started to get the following type of timeout exceptions:
When calling QueueClient x.Send(...)
Exception rethrown at [0]: at
Microsoft.ServiceBus.Common.AsyncResult.End[TAsyncResult](IAsyncResult
result) at
Microsoft.ServiceBus.Messaging.Sbmp.DuplexRequestBindingElement.DuplexRequestSessionChannel.DuplexCorrelationAsyncResult.End(IAsyncResult
result) at
Microsoft.ServiceBus.Messaging.Channels.ReconnectBindingElement.ReconnectChannelFactory `1.RequestSessionChannel.RequestAsyncResult.b__4(RequestAsyncResult
thisPtr, IAsyncResult r) at
Microsoft.ServiceBus.Messaging.IteratorAsyncResult`1.StepCallback(IAsyncResult
result)
When calling NamespaceManager x.GetQueue(...)
PROGRESS queue processing failed. System.TimeoutException: The request
has timed out after 60000 milliseconds. The successful completion of
the request cannot be determined. Additional queries should be made to
determine whether or not the operation has succeeded.
TrackingId:bdffb6bd-5367-4573-aaa3-8ea9a03f5a2b,TimeStamp:5/28/2015
8:39:46 AM ---> System.Net.WebException: The request was aborted: The
request was canceled. at
System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
at
Microsoft.ServiceBus.Messaging.ServiceBusResourceOperations.GetAsyncResult`1.b__49(GetAsyncResult`1
thisPtr, IAsyncResult r) at
Microsoft.ServiceBus.Messaging.IteratorAsyncResult`1.StepCallback(IAsyncResult
result)
When calling NamespaceManager x.SubscriptionExists(...)
Exception doing periodic work: System.TimeoutException: The request
has timed out after 00:10:00 milliseconds. The successful completion
of the request cannot be determined. Additional queries should be made
to determine whether or not the operation has succeeded. Server stack
trace: Exception rethrown at [0]: at
Microsoft.ServiceBus.Common.AsyncResult.End[TAsyncResult](IAsyncResult
result) at
Microsoft.ServiceBus.NamespaceManager.OnEndSubscriptionExists(IAsyncResult
result) at
Microsoft.ServiceBus.NamespaceManager.SubscriptionExists(String
topicPath, String name) ...
When calling QueueClient x.Receive(...)
PROGRESS queue processing failed.
Microsoft.ServiceBus.Messaging.MessagingCommunicationException: Error
during communication with Service Bus. Check the connection
information, then retry. --->
System.ServiceModel.CommunicationObjectFaultedException: Internal
Server Error: The server did not provide a meaningful reply; this
might be caused by a premature session shutdown.
TrackingId:04ba0220-0350-4806-9c65-c2bba9671054, Timestamp:28.05.2015
13:00:55 Server stack trace: Exception rethrown at [0]: at
Microsoft.ServiceBus.Common.ExceptionDispatcher.Throw(Exception
exception) at
Microsoft.ServiceBus.Common.AsyncResult.End[TAsyncResult](IAsyncResult
result) at
Microsoft.ServiceBus.Messaging.Sbmp.DuplexRequestBindingElement.DuplexRequestSessionChannel.DuplexCorrelationAsyncResult.End(IAsyncResult
result) at
Microsoft.ServiceBus.Messaging.Sbmp.DuplexRequestBindingElement.DuplexRequestSessionChannel.EndRequest(IAsyncResult
result) at
Microsoft.ServiceBus.Messaging.Channels.ReconnectBindingElement.ReconnectChannelFactory`1.RequestSessionChannel.RequestAsyncResult.b__4(RequestAsyncResult
thisPtr, IAsyncResult r) at
Microsoft.ServiceBus.Messaging.IteratorAsyncResult`1.StepCallback(IAsyncResult
result) ….
The exceptions are clearly related to ServiceBus and they are non-deterministic. The functions throwing them, e.g., Send, GetQueue, SubscriptionExists, are called no more than 100-120 times per minute. We changed nothing in the code and increasing the timeout values (even to ridiculously high values, like 10min) did not help. Also, we do not believe it is some network related problem (on our side) since the same error occur when the application is run from different places.
Has anyone else encountered recently these kind of exceptions? Is there a problem on the side of Microsoft or we are missing something?
A few weeks back we had sudden and unexplainable timing issues crop up with our Service Bus app that has been in production for many months. Ours continued to work but every few calls would take 10+ seconds when they are normally 100-200 millisconds. This went on for a couple weeks and I spent most of that trying to figure out what was going on and never did as the problem suddenly vanished.
We did learn that new Service Bus namespaces we created in the same and other data centers for testing while the problem was occurring did not exhibit the same issue. The Service Bus group offered no help and would only say response times are not guaranteed only the SLA is.
I had similar problem when my running code started to generate Timeout exception. Upon research found that firewall blocked the port used for communication. However, port 80 and 443 were still open. So adding following line of code worked for me:
ServiceBusEnvironment.SystemConnectivity.Mode = ConnectivityMode.Https;

Asp.net MVC IIS Failed to Execute URL

Hello I'm using CKFinder on CKEditor in an asp.net mvc 5 web application. The problem to be only remote server, no problem in local server. When I select add image on CKEditor and click browse server, my url is //Scripts/ckfinder/ckfinder.html?type=Images&CKEditor=Text&CKEditorFuncNum=1&langCode=tr. Because of mvc do not allow direct link that is ckfinder.html IIS give error. The error is: System.Web.HttpException: Failed to Execute URL. How to fix error?
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.HttpException: Failed to Execute URL.
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:
[HttpException (0x80004005): Failed to Execute URL.]
System.Web.Hosting.ISAPIWorkerRequestInProcForIIS6.BeginExecuteUrl(String url, String method, String childHeaders, Boolean sendHeaders, Boolean addUserIndo, IntPtr token, String name, String authType, Byte[] entity, AsyncCallback cb, Object state) +2582829
System.Web.HttpResponse.BeginExecuteUrlForEntireResponse(String pathOverride, NameValueCollection requestHeaders, AsyncCallback cb, Object state) +412
System.Web.DefaultHttpHandler.BeginProcessRequest(HttpContext context, AsyncCallback callback, Object state) +192
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +301
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155
The error 0x80004005 seems to be permissions problem. Change IIS "pipeline mode" from "classic" to "integrated"

Categories

Resources