-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
When I install the ASP Core as windows service I can't connect to my gRPC service #43547
Comments
I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label. |
Tagging subscribers to this area: @dotnet/ncl Issue DetailsWell, I have a gRPC service that is hosted in a ASP Core .NET 6 application. When I debug the ASP project or run the .exe directly, I can connect with the gRPC service, but if I install the ASP Core as a windows service, i get a error: connection refused. SocketException: connection refused. DebugException: System.Net.Http.HttpRequest exception. This error is when I have disabled the firewall in the server, because if I have enabled it, I get a timeout error, that it is the expected result because I don't have created the rules in the firewall. I am using certificates, but I am not sure if this is the possible cause, because if I run the application when it is not a service, it works as expected. The code of my ASP Core application is this:
Thanks.
|
@ComptonAlvaro Can you enable logging for the server and see if anything appears there? |
Hi @ComptonAlvaro. We have added the "Needs: Author Feedback" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time. |
@ComptonAlvaro Well, really it is what I was trying, to enalbe logging to can write in a text file to see what is happening, but I don't know how to write to a file the log of ASP. I can't see the log of ASP when it is running as the same way than when I run it directly. When I have the log, I will share. |
Check the event log. |
Then system event log show this:
|
@davidfowl In the application section I don't have any event related with the application. Just I have a system event with the error 1067. I have try to write in a text file in the first line of program.cs, and it doesn't start, so I guess it is a problem about the way I create the service, the code, perhaps UseWindwService() or perhaps that I have to implement something related with some interface of services. |
I oculd solve it if in the first line of my pogram.cs I set the CurrentDirectory of the enviroment: Environment.CurrentDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); It is because the user that run the service, System, doesn't have permissions to write in c:\windows\system32, that is the default directory of the services. |
@ComptonAlvaro Glad you were able to figure this out. We've improved this behavior in 7, and there's a comment about this in the docs here: https://docs.microsoft.com/en-us/aspnet/core/host-and-deploy/windows-service?view=aspnetcore-6.0&tabs=visual-studio#current-directory-and-content-root-1 |
Closing this as resolved, @ComptonAlvaro feel free to re-open if you have further issues here. |
Well, I have a gRPC service that is hosted in a ASP Core .NET 6 application.
When I debug the ASP project or run the .exe directly, I can connect with the gRPC service, but if I install the ASP Core as a windows service, i get a error: connection refused. SocketException: connection refused. DebugException: System.Net.Http.HttpRequest exception.
This error is when I have disabled the firewall in the server, because if I have enabled it, I get a timeout error, that it is the expected result because I don't have created the rules in the firewall.
I am using certificates, but I am not sure if this is the possible cause, because if I run the application when it is not a service, it works as expected.
The code of my ASP Core application is this:
Thanks.
The text was updated successfully, but these errors were encountered: