dotnet core IIS website restart on error (for example sql server reboot) - iis

I'm currently facing the following problem when hosting a dotnet core application with IIS.
When the webserver boots before the database server, the dotnet-application throws an error that it is unable to connect to the database. So for so good offcourse.
But the problem is that when it faces this error on startup, it will never again try to connect to the database. The dotnet core application seems to be giving up when facing a startup error.
Is there some general re-try mechanism available to handle these kind of errors? So for example when the application detects a problem, to restart every 5 minutes?

I seem to have found the answer myself. It was during my startup-logic that I already was connecting to the sql database. I could simply force IIS to try to restart the process, until initialization worked out by explicitly shutting down the application using Environment.Exit(-1); whenever an error occured

Related

Umbraco 9 on Linux Server (Kestrel Service)- Site Dies After Deploying Code Changes

I've gotten an Umbraco 9.0.1 instance up and running on a Linux server (Ubuntu 20.04). I'm using what appears to be the recommended approach of using Nginx as a reverse proxy to a Kestrel service
https://learn.microsoft.com/en-us/aspnet/core/host-and-deploy/linux-nginx?view=aspnetcore-5.0
The issue I'm having is that any time I do a code update and deploy it to my Linux server, followed by a restart of the kestrel service, the site dies. I get a 502 bad gateway error. Reloading the daemon does nothing. The only thing I've found that seems to work is if I navigate to place in the filesystem where I've deployed the published application and run the command:
dotnet Umbraco.Nine.Linux.dll (Umbraco.Nine.Linux being the name of my project and the corresponding dll the result of the publish)
that command just hangs so I hit ctrl + C to stop it, but that brings the site back up.
Has anyone else experienced anything like this? If not, how are you handling Umbraco code deployments to a Linux server? I should add that if I use the default .net core website from Visual Studio, I don't have this issue. I deploy my code and restart the kestrel service and everything is beautiful, no site outage, changes show up. So maybe there is some Umbraco startup process that's making things die?
I've checked the logs for the kestrel service and they just indicate the service stops/restarts as expected. The logs in Nginx confuse me. They say something like
2021/09/27 15:35:08 [error] 81048#81048: *1 connect() failed (111: Connection refused) while connecting to upstream, client: 184.67.248.194, server: <mysite.com>, request: "GET /umbraco/api/test/another HTTP/1.1", upstream: "http://127.0.0.1:2003/umbraco/api/test/another", ..."
EDIT:
I thought I should post some additional details, just in case it helps. For the publishing of the project, I am using Visual Studio built in publishing and choosing File System.
(Note I've tried the single file publish but I haven't even gotten that to run. I get an error indicating some library the project depends upon will not run in single file publish. Again, this seems Umbraco specific as I can get a default asp.net core site to publish just fine like this. I'm only adding this note in case it's relevant to something just being wrong with Umbraco 9 as we're still very early in the release.)
After that I just zip it up, upload it to the server, unzip it with commands like:
unzip -o website.zip -d <path/to/my/web/app/>
Then
sudo systemctl restart <my.kestrel.service>
That's when browsing the site yields the 502 Bad Gateway I described above. Any help on what I'm doing wrong would be greatly appreciated.
So, I solved this, sort of. I've abandoned the whole kestrel thing and I'm using a docker container to run the asp.net core application. I'm still hosting using nginx as a reverse proxy. The only difference is instead of having a systemd kestrel service listening on the specified port, it's a docker container doing it.
I posted details here: https://our.umbraco.com/forum/umbraco-9/107189-umbraco-nine-on-linux-server-site-dies-after-deploying-code-changes
Hopefully it helps someone else out!
I'm pretty excited because the whole thing is 'script'-able so I managed to automate it in an AWS CodePipeline.

IIS - Service Unavailable

Recently we are facing "Service Unavailable" while opening our web reports url in internet explorer.
Restarting the IIS service resolves the issue but didn't found any logs/errors in event viewer to track what is causing IIS to fail.
Is there any other way to troubleshoot this?
Many thanks...
To actually help you out SO need more information but following is more common cause.
There is no enough memory for application to run when it try to start. If there are multiple application in your IIS then it cause such issue as other application took priority so memory consume by them.
Your application has some un-handle exception that cause your application to shutdown and sometime it cause worker process to stop.
If your application is .NET based ( This is not the case with you because after IIS restart it runs successfully ) then .NET Runtime Version conflict also create such problem.

Unable to start Message Engine in Websphere

I am facing a problem while starting the websphere message engine for one of the application deployed on websphere. This application is getting deployed automatically as a part of the installation of Websphere Lombardi 7.2 express edition. It's using websphere 7 internally to deploy it. When I try to start the message engine from the administrative console of websphere I am getting following error:
The messaging engine ProcessCenter01.twperfsvr-twperfsvr_bus cannot be started as there is no runtime initialized for it yet, retry the operation once it has initialized. For the runtime to successfully initialize the hosting server must be started, have its 'SIB service' already enabled, and dynamic configuration reload enabled. If this is a newly configured messaging engine and it is the first messaging engine to be hosted on this server, then it is most likely the 'SIB service' was not previously enabled and thus the server will need to be restarted. The messaging engine runtime might not be initializing because of an error while trying to start, examine the SystemOut.log of the hosting server to check for error messages indicating the problem.
After restarting the server, the same error shows. Can anyone help me to to find what gets loaded as a part of "initialization of runtime"? Are there any config files etc. that I need to check to solve this issue? I am suspecting some missing configuration causing error to load the runtime for this particular application.
I too faced this issue today had to delete all the files under the message store
check the directory-file path mentioned in
Application servers > server1 > Messaging engines > XXX.server1-primaryBus > File store
Just Enable the SIB Services For the particular Server.
Example:Server-->Application Server-->click on Server Name-->right hand side we can see SIB services-->Check box the Enable services.
This will solve your problem
Recently I have faced the same issue when I rebuilt the jvms in UAT envt. After searching on web I found that because of the old messages saved in the message store(flat files in my envt) the messaging engines was not getting initiated. After deleting the old messaging store and restarting the servers it got initialized.
I have struggled with this problem too.
In our situation the problem was that the file message store location was used that was already created for a different (or old) message-engine.
If you add a busmember to the service-bus and use a file store implementation, then you need to supply the path for the store and log folder. Make sure these locations don't exist yet, other wise you will run in the problem above. The message-engine for this member will use these folders.
If you have a script for creating the message-bus infrastructure, make sure that when you delete the bus or remove message-engines, that you remove the file store/log folders for these, before you re-run your script.
Another possibility is that you are using a external database as a data store, and the user that is used for the connection is not allowed to create a database. You might find a ffdc entry like this:
DB2 SQL Error: SQLCODE=-552, SQLSTATE=42502, SQLERRMC=DB2ADMIN;CREATE
SCHEMA, DRIVER=3.61.65
Then you have to go to your database administration tool and give DB2ADMIN the proper privileges. Then restart the server or cluster.
Finally this issue is been resolved. I did not create the schema in SQL Server with same name as that of the username I gave to connect SQL Server during the installation of WLE 7.2
Please find details about this at below link:
http://www.ibm.com/developerworks/forums/message.jspa?messageID=14795282

A problem with a Windows service using SubSonic 3

I'm trying to implement a C# Windows service, which utilizes SubSonic 3 to query and update a MSSQL database. The problem is that when I start the service, Windows Service manager says "The MyService on Local Computer started and stopped. Some services stop automatically if they are not in use by other services or programs". Application event log says that "Service cannot be started. System.Data.SqlClient.SqlException (0x80131904): Incorrect syntax near the keyword 'Update'." followed by a stack trace.
I'm installing and starting the service as an admin. The error occurs only when the service is trying to run a query to the database. What I'm doing wrong? Any help is appreciated!
The service is developed using Visual Studio 2010 and running it as normal application works fine.
Best regards,
Aki
The query is causing an unhandled exception, which causes your service to stop. You will need to determine what the query is that is causing the issue and try to fix that. Judging from the error message, it looks like SubSonic might be generating some invalid SQL for your query.

Unable to start debugging on the web server. The underlying connection was closed. The connection was closed unexpectedly

All of the sudden I'm getting the following error on my local web server (Win7 64bit, IIS 7.5). I've uninstalled & reinstalled IIS locally and it didn't fix it. IIS is set to start up automatically and I can see that the service has been successfully started. Upon a fresh reboot if I go into IIS and click on start website I get the following error:
The process cannot access the file because it is being used by another process. (Exception from HRESULT: 0x80070020
If I try to start debugging on my local website project I get the following error:
Unable to start debugging on the web server. The underlying connection was closed. The connection was closed unexpectedly.
Any ideas on what I can try? I've been doing research on the issue and Microsoft suggest making sure no other service is listening on the same ports. I've verified that this isn't the issue.
Try changing the web site to use a port other than 80 (suggest 8080 for example) and see it if will start. If so that's a sure sign of another service using port 80 (Skype is a common culprit for this).
Application pool's identity password changed?
I know this is an old post, but I can't believe how many times I've been bitten by this. Some shops use integrated security for SQL, and often then on your local IIS needs your network login for the application pool. When your password expires, and you forget to change your password here, start banging your head on the wall... DOH!
Open IIS. Select Application Pools. Select the application pool used by your app. Click Advanced Settings... Select Identity, and the little "..." button to update your user/password.

Resources