New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Nginx hosting issue #8300
Comments
unfortunately the problem is still present... |
Ok, after first investigation it seems to be an issue when I use cloudflare (client<—>cloudflare<—>nginx<—>kestrel). |
@bencoskater When you say you see a crash, how is that observed other than these logs? Does the process unexpectedly exit? Is a connection unexpectedly closed by the server? Also, what version of ASP.NET Core/Kestrel you are using? If you are using 2.1, did you select Kestrel's libuv transport? |
Hi @halter73, It’s the runtime 2.1.3. I will provide you other informations tonight. Thanks for your help |
Is there any way to get detailed logs? |
Trace is our most verbose log level. Here are the docs for changing this. |
By the way the error 502 happens on the call of rest API. |
Do you get a 502 for all subsequent requests until you restart the server? Or is it a transient issue? |
It’s transient. Since I disabled cloudflare proxy I got less problem. |
Here is my configuration: .Net: .NET Core SDKs installed: .NET Core runtimes installed: libuv is not installed as I am using the runtime, apparantly not required regarding the documentation. Here is the nginx host configuration:
nginx.config:
|
here is the logs from nginx:
logs from journalctl -fu of my Kestrel service:
Unfortunately I did not get time to implement logs in my application. regarding nginx logs, it seems to be a header problem. |
I implemented this in the Program class for the moment and compiled in debug to see if there will be more details:
|
Hi, My yesterday’s modification provides nothing more :( I will continue to investigate tonight. In the meantime if you have any ideas that would be helpful :) |
@bencoskater Do you have any additional trace/info level logs? I'm pretty sure the ConnectionAbortedException originated due to an exception thrown from Socket.SendAsync(). Details about these kind of SocketExceptions are usually logged at the informational level in 2.1.3. For 2.2.0-preview2, I've made some changes to the socket transport in the KestrelHttpServer repository to better report these kind of errors so you don't need that kind of verbose tracing to get details about SocketExceptions thrown from SendAsync if it prematurely ends. Unfortunately, this hasn't even been picked up by our daily builds yet. I would try upping the logging verbosity first, but if that by itself doesn't work, you could also try cloning the aspnet/KestrelHttpServer repo, checking out the release/2.2 branch, running build.sh, and referencing the repo's artifacts/build/ directory in your NuGet.config. |
I am using VS on windows. The Linux is used as web server. |
You don't have to compile Kestrel on your Linux VM. You can compile the Kestrel NuGet packages on Windows, reference them from your NuGet.config, and publish your app from Windows to Linux. You might be able to save yourself some effort by continuing to use version 2.1.3 of Kestrel with more verbose logging. I expect that will also give us details about originating exception. I only suggesting compiling Kestrel yourself as a last ditch effort. |
Hi Stephen,
I Cannot connect to the host, here is the exception logged:
Apparently the method "OnConnection" is missing in this version. I do not know if it is related to my issue. |
I had to upgrade all packages to 2.2 preview. I created a self-contained package for testing. I cannot reproduce the exception for the moment. |
Hi, got the error this morning with this version. I don't have any more details using systemctl status nor journalctl -xe. the only logs I have is:
|
Are you still seeing 502's with the new packages? Is it possible your systemd journal has a very small buffer size? I'm surprised there aren't any logs about the connection opening or closing. Those should always be there if you have your log level set to "Trace" even for non-error scenarios. If you set the log level to "Information" (which I believe is the default), you won't get these connection logs since that setting is not verbose enough. The logs I'm referring to should look something like the following for a successful request.
|
Hi Stephen, yes still getting errors. Now I changed to Trace and I have more details. |
This is probably one of the best tutorial's so far. I will say though, after following all of the steps, I just get an NGNIX splash page. As in I get the NGINX splash page. Is anyone else running their web server headless? |
Hi Stephen, I installed Debian on a new VM to see if I got the porblem. Now the first server has only Nginx, and the other the 2.1 runtime and I deployed the package in seld-contained and ran the batch without dotnet command (it was a mistake of my previous test). I also taken advantage to redirect everything in a log file. the result is the same even in local network it has failed. Here is a part of the log:
|
I am trying on windows and apparently there is no problem. |
I resolved my issue...kind of. The "Location" attribute was incorrect. When I removed it, it worked. |
@se-augustus, hi, please make another ticket next time you are faced to a problem to do not make people confused about the original reported issue. Thanks |
Hi @halter73, Thanks |
Unfortunately, the logs you posted aren't very revealing. That said, the improved reporting I mentioned in a pervious post should not finally be available on the https://dotnet.myget.org/F/dotnet-core/api/v3/index.json NuGet feed. If you could update to the 2.2.0-preview3-35208 version of Microsoft.AspNetCore.Server.Kestrel, that should get us better logs. Thank you for your patience. |
Hi, |
The 2.2.0-preview2 packages were uploaded to NuGet today. Those should also include the new logging. |
Hi Stephen, Thanks for your feedback. I am going to update all my solution and let you know. |
Hi sorry nothing related to https, I removed my previous post in consequence. I am in HTTP so the warning is shown because there is no https binding on my application.
|
@bencoskater So you're still seeing 502s with the 2.2.0-preview2 packages? The logs look perfectly normal. If you are still seeing 502s, you might try adding our connection logging middleware which will log every byte of each request and response. If that's too verbose, you could try adding middleware like the following to at least make sure nginx is using http1.1 and/or is setting the "Connection: keep-alive" header as configured. public class Startup
{
public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory)
{
var logger = loggerFactory.CreateLogger("MyApp");
app.Use(next =>
{
return context =>
{
logger.LogDebug("Http Version: {HttpVersion}, Connection: {KeepAliveValue}",
context.Request.Protocol, context.Request.Headers["Connection"]);
return next(context);
};
});
// ... It might also help to add timestamps to the log to see if Kestrel is closing the connection due to a keep-alive timeout. You can either use a third-party logging provider like serilog for this or you can decorate the default console logger. |
Hi @halter73, I will do that when I have time this week otherwise it will be this week-end. Thanks |
Hello, I am also having problems connecting to my sit via dotnetcore on ubuntu via cloudflare. If I go to the IP or if I use a vanilla domain and point it to the IP I have no issue but Cloudflare shows 502 Errors. |
Closing for lack of on-going discussion. Thus far, I don't have anything actionable for a doc update. We may have something later ... we can re-open this if there's more to discuss that leads to a doc enhancement opportunity. |
Hi,
Please update your documentation. I tried what you wrote (good tuto by the way). Unfortunately my web application crashed after some REST API calls. Apparently due to the localhost binding and target ip in nginx. Following urls http://*:8080 and http://127.0.0.1:8080 + server 127.0.0.1:8080 in nginx make the application crash with aborted connection.
So to make it works, I had to replace the binding with the network IP and the same in nginx.
This happened in production mode.
Document Details
⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
The text was updated successfully, but these errors were encountered: