My .NET Core Web API (Version 2.2 )project Can't able to successfully make connection with Azure SignalR service (free tier). its showing some error is like "Failed to connect to the service, will retry after the back off period. Error detail: Unable to connect to the remote server. The remote certificate is invalid according to the validation procedure.."
my .net core is containerized by local docker installed in my machine and deployed it on the local kubernates clusters. When i deployed the same thing i local iis its working perfectly.
My client application is based on Angular 7.
Tried some of the SSL certificate workarounds like importing azure ssl certificate to browser but issue has not yet resolved.
public void ConfigureServices(IServiceCollection services) {
services.AddCors();
services.AddSingleton < IUserIdProvider, CustomUserIdProvider > ();
services.AddSignalR().AddAzureSignalR(connection => {
connection.ConnectionString = "my_connectionstring";
});
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
}
Expected : Azure signalr Connection need to start and able to send message to clients.
Actual : Failed to connect to the service, will retry after the back off period. Error detail: Unable to connect to the remote server. The remote certificate is invalid according to the validation procedure..
Related
I upgraded my WebApi project from NET6 to NET7. I use EF Core 7 in my project.
I knew that there was a breaking change involving SQL Server and certificates. So I changed my connection string in the project's appsettings.json to:
"ConnectionStrings": {
"DB": "data source=myserver;initial catalog=mydb;MultipleActiveResultSets=True;App=MyApp;Trusted_Connection=True;TrustServerCertificate=Yes;Encrypt=false;"
}
I added Trusted_Connection, TrustServerCertificate and Encrypt to test if the connection will work.
The website was published to IIS (where the ASP.NET Core Runtime 7.0.0 is installed).
However I'm getting the following exception on a GET request:
SqlException: A connection was successfully established with the server, but then an error occurred during the login process. (provider: SSL Provider, error: 0 - The certificate chain was issued by an authority that is not trusted.)
And the following on another GET request:
{"type":"https://tools.ietf.org/html/rfc7231#section-6.6.1","title":"An error occurred while processing your request.","status":500,"traceId":"00-f7ac7c853fbfe3ef43a3d8b567fadbdb-a30b994f51839fcb-00"}
The above changes to the above connection string should have fixed this problem. But the problem persists and I don't know that else I can change to get the website to work again.
The SQL Server either has a self-signed certificate or no certificate at all. All I need is to get the code to work with the current setup.
What am I missing?
Update:
Just tried the official example https://github.com/aspnet/AspNetCore.Docs/tree/master/aspnetcore/fundamentals/servers/httpsys/samples/3.x/SampleApp and it doesn't work.
Brower message:
This site can’t provide a secure connection
localhost sent an invalid response.
Output:
info: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[0]
User profile is available. Using 'C:\Users\xxx\AppData\Local\ASP.NET\DataProtection-Keys' as key repository and Windows DPAPI to encrypt keys at rest.
warn: Microsoft.AspNetCore.Server.HttpSys.MessagePump[0]
Overriding address(es) 'https://localhost:5001, http://localhost:5000'. Binding to endpoints added to UrlPrefixes instead.
info: Microsoft.AspNetCore.Server.HttpSys.HttpSysListener[0]
Start
info: Microsoft.AspNetCore.Server.HttpSys.HttpSysListener[0]
Listening on prefix: http://localhost:5005/
info: Microsoft.Hosting.Lifetime[0]
Now listening on: http://localhost:5005/
info: Microsoft.Hosting.Lifetime[0]
Application started. Press Ctrl+C to shut down.
info: Microsoft.Hosting.Lifetime[0]
Hosting environment: Development
info: Microsoft.Hosting.Lifetime[0]
Content root path: C:\Users\xxx\Downloads\AspNetCore.Docs-master\AspNetCore.Docs-master\aspnetcore\fundamentals\servers\httpsys\samples\3.x\SampleApp
I created a new Blazor application with Windows Authentication. (Visual Studio 2019 V16.4.0, .Net Core 3.1).
Now Windows Authentication works (the top right corner of the web page shows "Hello Domain\Username!") when running with IIS Express in Visual Studio. But Windows Authentication is not working when running as Kestrel application.
I followed the steps in the following link to make Windows Authentication work with Http.Sys. (BTW, I tried [Kestrel/Negotiate][1] but no luck)
https://learn.microsoft.com/en-us/aspnet/core/fundamentals/servers/httpsys?view=aspnetcore-3.1
Basically, it just adds the call of webBuilder.UseHttpSys() in CreateHostBuilder() in Program.cs.
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseHttpSys(options =>
{
options.AllowSynchronousIO = true;
options.Authentication.Schemes = AuthenticationSchemes.None;
options.Authentication.AllowAnonymous = true;
options.MaxConnections = null;
options.MaxRequestBodySize = 30000000;
// options.UrlPrefixes.Add("http://*:5005");
});
webBuilder.UseStartup<Startup>();
});
However, running the application will get an error page with message of
This site can’t be reached
The connection was reset.
or
This site can’t provide a secure connection
localhost sent an invalid response.
Edge's error messages are:
There was a temporary DNS error. Try refreshing the page.
Error Code: INET_E_RESOURCE_NOT_FOUND
IE error message:
Can’t connect securely to this page
This might be because the site uses outdated or unsafe TLS security settings. If this keeps happening, try contacting the website’s owner.
The solution is to relocate your certs, and do a bunch of manual configuration that doesn't seem like it should be necessary: I was following the Configure Windows Server section of the http.sys example fairly closely, but ran into issues with the netsh http sslcert commands. The problem is with where dotnet dev-certs https --trust installs the certificate! In What is the default location for certificates created using "dotnet dev-certs https" it's pointed out that that tool installs certificates in the current user's certificate store, not the local computer store. I had to add both certificate stores to mmc and copy the localhost cert over into Certificates (Local Computer)\Personal\Certificates, at which point the sslcert command completed, and when I ran the test application, it was successfully able to connect with TLS.
I have created an empty Azure SQL database.
I have added my IP to the firewall setting on the server.
I want EF Core to create the database for me with the command dotnet ef database update.
I can successfully connect to and query the Azure database via the mssql ext for Visual Studio Code.
I am have tried to connect the app to the database with connection strings as well as placing the connection string directly into the Startup.cs file.
appsettings.json
{
"Logging": {
"IncludeScopes": false,
"LogLevel": {
"Default": "Warning"
}
},
"ConnectionStrings": {
"Development": "Server=tcp:appName.database.windows.net,1433;Initial Catalog=AppName;Persist Security Info=False;User ID=User;Password=Password;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;"
}
}
Startup.cs
public void ConfigureServices(IServiceCollection services)
{
// Add framework services.
services.AddMvc();
// Add database services.
services.AddDbContext<ApplicationContext>(options =>
options.UseSqlServer(Configuration.GetConnectionString("Development")));
}
I run dotnet restore then dotnet ef database update
Finally, I get the following error:
A network-related or instance-specific error occurred while
establishing a connection to SQL Server. The server was not found or
was not accessible. Verify that the instance name is correct and that
SQL Server is configured to allow remote connections. (provider: TCP
Provider, error: 35 - An internal exception was caught)
Am I missing something? What else can I try?
EDIT : I have even tried from a different location (different IP address). I added it to the firewall settings in Azure and got the same results. I can connect via the mssql extension in VSCode but not when I run the dotnet ef database update command.
You can try a couple of things:
Make sure firewall on your machine allows outbound connections to 1433
Are you sure you used correct IP address in Azure Firewall rules? As a test, you can create a rule with ip range from 1.1.1.1 to 255.255.255.255 and see if it works. If it does, it means that you provided incorrect IP in Azure firewall
Running dotnet ef database update --verbose revealed that the app was trying to connect to the default blogging.db database. I found that it was still listed in the OnConfiguring overridden function inside ApplicationContext.cs.
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
optionsBuilder.UseSqlServer("Data Source=blogging.db");
}
After setting the proper database here everything started working.
I have been trying to connect to the Windows Service created in this tutorial:
http://www.asp.net/signalr/overview/deployment/tutorial-signalr-self-host
The thing is that I do can connect to it using its own client. However, I've tried to connect to it from a console application and haven't had success. Moreover, if I host the SignalR Hub in a console application I can connect to it successfully.
The errors that I got say that my client version isn't compatible with the server and that the connection was refused.
This is how my attempt to connect looks like:
IHubProxy _hub;
string url = #"http://localhost:8080/";
var connection = new HubConnection(url);
_hub = connection.CreateHubProxy("MyHub");
_hub.On("addMessage", x => ShowMessage(x));
connection.Start().Wait();
UPDATE:
-Errors Messages:
1.
Exception:Caught: "You are using a version of the client that isn't compatible with the server. Client version 1.4, server version 1.3." (System.InvalidOperationException)
A System.InvalidOperationException was caught: "You are using a version of the client that isn't compatible with the server. Client version 1.4, server version 1.3."
Time: 2/20/2015 12:03:36 PM
Thread:Worker Thread[5924]
2.
Exception:Thrown: "No connection could be made because the target machine actively refused it" (System.Net.Sockets.SocketException)
A System.Net.Sockets.SocketException was thrown: "No connection could be made because the target machine actively refused it"
Time: 2/20/2015 12:03:36 PM
Thread:Worker Thread[3320]
As pointed by Christophe, this question is a duplicate of SignalR Java client only supports exactly 1.3 and, in my case, was solved by uninstalling and re-installing all the SignalR/Owin packages.
I installed kafka_2.10-0.8.1.1 on a Ubuntu 12.04 (Linux ubuntu 3.8.0-44-generic) hosted by vmware player 6.0.3 build-1895310. On the host machine (Windows 8) I am using the C# client from https://github.com/Jroland/kafka-net. The ip of the kafka machine is correctly configured in C# code, the topic "test" is accordingly created in kafka etc. I get the following messages:
No connection to:http://:9092/. Attempting to re-connect...
Type a message and press enter...
Awaiting message from: http://:9092/
BrokerRouter: Refreshing metadata for topics: test
Failed re-connection to:http://:9092/. Will retry in:1000
Failed re-connection to:http://:9092/. Will retry in:2000
Failed re-connection to:http://:9092/. Will retry in:4000
The same client connects to a physical linux machine with kafka.
I would like to be able to develop with kafka running as a virtual machine. How could I solve the communication issue?
Thanks
I never used the c# version, but is your producer configure correctly?
From the error message, it seems that it doesn't have the IP/DNS configured...
No connection to:http://:9092/