I have an ASP.Net MVC application that I have added SignalR to. After following the "Getting Started" tutorial (with modifications of course since it's going in my application) I got it working on localhost. However once it's in the production environment, I get the following error:
WebSocket connection to 'ws://xxxxx/signalr/connect?transport=webSockets&clientProtocol=1.5&connectionToken=xxxxx' failed: Connection closed before receiving a handshake response.
I can access /signalr/hubs (I get a js file). Any ideas as to why this would happen?
This may be due to the fact that your web server doesn't support WebSockets (IIS 7.5, for instance. It may also be due to the fact that you are using a "proxy" server like ARR and it just cannot "route" WebSocket requests.
The first thing I would try to do is to disable WebSockets on SignalR, just as a debug tool. Here's how: SignalR - How do I disable WebSockets
If your problem persists, it's a general SignalR problem but at least you will have a more specific error. If the problem stops, now you know it is a server issue.
Related
I have created a WebSocket server in NodeJs and hosted it on GCP. The URL for the server is wss://scramblegram.bluemsoftware.com
I created a WebSocket client using ClientWebSocket C# core 5.0.
Here is my issue
If I connect to wss://scramblegram.bluemsoftware.com using my client ClientWebSocket I get "Unable to connect to the remote server"
If I connect to wss://scramblegram.bluemsoftware.com using https://www.websocket.org/echo.html it works perfectly.
If I connect to wss://echo.websocket.org using my client ClientWebSocket it works perfectly.
can someone explain what is going on and how I can debug and solve this? It makes no sense
[Edit]
Code
https://github.com/endel/NativeWebSocket/blob/master/NativeWebSocket/Assets/WebSocket/WebSocket.cs
WebSocket ws = new WebSocket("wss://scramblegram.bluemsoftware.com");
await ws.Connect();
Kindly post the code to your Custom C# Web Socket client...
We cannot try to help without seeing your code.
Ok so many things might be wrong. It might be that the remote host is behind a firewall that's blocking your web socket client machine...
Or TLS version issues. So many things can be wrong. So it's hard to tell.
I will also suggest if you check message and it's not informative enough, try checking the Github page of that Web socket client that you are using for issues related.
But most likely, the remote firewall is blocking requests from your local machine.
That's my thought.
I created a gRPC service and client in C# .NET Core 3.1. When I deploy the service to localhost, I can connect to it without a problem. But when I publish the service to a IIS via WebDeploy and start it there I cannot connect to it.
For a local deployment, the channel is initialized as follows:
var channel = GrpcChannel.ForAddress("https://localhost:5001");
For the remote deployment I change it to the following value, since it starts as a HTTP service on http://localhost:5000 on the remote machine (which I also failed to find out how to change - I would prefer it to start as a HTTPS service):
AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true);
var channel = GrpcChannel.ForAddress("http://1.2.3.4:5000");
1.2.3.4 is the IP of the remote machine, which I am able to ping. I also created a firewall rule to allow all inbound traffic on inbound port 5000.
The client application fails on the first remote call with the error message
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
I fail to understand which measures I have to take to create a connection to the remote service. All example gRPC code I have found so far uses localhost as a deploy point and did not help me figure out the root cause of my problem.
Any help or pointers towards what I must have missed are appreciated.
From Tutorial: Create a gRPC client and server in ASP.NET Core, a warning almost at the end of the article, says
ASP.NET Core gRPC is not currently supported on Azure App Service or IIS. The HTTP/2 implementation of Http.Sys does not support HTTP response trailing headers which gRPC relies on...
Please refer to gRPC in production for ways to run your gRPC service in production.
I have a web app made in C# using asp.net core 2.0.
This app is hosted in IIS, as this is the recommended way to expose it to the internet.
I am now making some services hosted in the same local lan as the webapp, which need to connect to the above webappp. I can connect to the public iis server which of course works. However, would it also be possible to directly connect to the Kestrel server managed by IIS? So instead of connecting to public_ip/somewhere, connect to kestrel-local-ip:port/somewhere. The advantages would be:
avoid an extra hop
the kestrel app is still hosted and managed by IIS, so no worrying about self-hosting/management.
Reading the documentation here: https://learn.microsoft.com/en-us/aspnet/core/fundamentals/servers/aspnet-core-module?view=aspnetcore-2.1 it states: "Additional checks are performed, and requests that don't originate from the module are rejected.". Reading the Github repro, this seems to be an HTTP header called "MS-ASPNETCORE-TOKEN".
So is this scenario possible somehow? To connect directly to IIS but ALSO to kestrel directly?
If it is possible, should I do this? The performance gains seem immense as I have a lot of small requests which Kestrel can handle really well.
I have test this scenario。
when APP kestrel behind iis,
you can use netstat command get the kestrel process "port".
and then curl the "localhost:port" , you will get the 400 bad request, also you can get a error log indicate the MS-ASPNETCORE-TOKEN token .
you can curl the "localhost:port"again with the MS-ASPNETCORE-TOKEN request header.
I downloaded the SignalR Getting Started solution and it works well. However if I add Azure Service Bus backplane then the client can't connect any more.
First it tries to connect to WebSocket
SCRIPT12030: WebSocket Error: Network Error 12030, The connection with the server was terminated abnormally
Then falls back to long polling and it doesn't work either.
SCRIPT7002: XMLHttpRequest: Network Error 0x2eff, Could not complete the operation due to error 00002eff.
Running it locally, debugging and there is no exception thrown on the server side.
The only difference between the working and non-working status is in the Startup.cs if I comment out the UseServiceBus part then it works:
//GlobalHost.DependencyResolver.UseServiceBus(connectionString, "Blabla");
app.MapSignalR();
Obviously I can't leave it like this for Azure deployment.
I tried upgrading / downgrading packages, both SignalR and WindowsAzure.ServiceBus, all the same.
Any ideas?
I have the same error, i have seen that the response for https://localhost/signalr/connect?transport=webSockets.... is 400 the problem is that my service bus Pricing plan is basic but only Standard tire to support Topics. So you have to go to azure portal and under the "Pricing tire" section of service bus you have to specifically go to the settings and scaled it up from Basic to Standard.
I'm trying to configure IIS 7.5 so that it can serve large (400mb) files via HTTP. The client is a C# client using WebClient.DownloadFile() (basically wrapping an HTTP GET request).
However when downloading, I occasionally get the error from the client:
An established connection was aborted by the software in your host machine
Anything I can do in either the client or IIS to prevent this error?
After much digging around, it looks like a dodgy internet connection on my side. All clients on my site disconnect at the same time, but clients on another site stay connected. Unfortunately the internet router that I have here doesnt have any connectivity logs (its a top-of-the-range linksys.. go figure) so it wasnt easy to see what the problem was.