Grpc server not listening to port 5001 when run as a Windows service

1

I created the GrpcGreeter and GrpcGreeterClient projects in Visual Studio 2019 from the following page:

[https://docs.microsoft.com/en-us/aspnet/core/tutorials/grpc/grpc-start?view=aspnetcore-5.0&tabs=visual-studio][1]

The only change I made to these examples was that in order for the GrpcGreeter app to run as a Windows service, I added ".UseWindowsService()" to IHostBuilder CreateHostBuilder. I published both to local folders while in VS, and selected Self Contained for the Deployment Mode.

Server and client work fine using https://localhost:5001 when run from the either the VS environment or when running the published GrpcGreeter.exe and GrpcGreeterClient.exe directly.

I then used "Sc create" to successfully create a Windows service with GrpcGreeter.exe. Then on the Services window I started the service.

The problem is that when run as a Windows service the GrpcGreeter.exe does not listen on port 5001, as shown with netstat -anb (it does listen to port 5354, apparently). And of course when I then run GrpcGreeterClient.exe it does not connect. When GrpcGreeter.exe is run not as a Windows service netstat shows that it is listening to 5001, and GrpcGreeterClient.exe talks to it just fine.

A look at Event Viewer shows 3 errors happening immediately whenever I start the service on the Services window. I'm abbreviating them below.


1st: Faulting application name: GrpcGreeter.exe, version: 1.0.0.0, time stamp: 0x5f6b3846 Faulting module name: ntdll.dll, version: 10.0.19041.546, time stamp: 0xd49544eb Exception code: 0xc0000374 Fault offset: 0x000e6763 ...

2nd: Fault bucket , type 0 Event Name: FaultTolerantHeap Response: Not available Cab Id: 0

Problem signature: P1: GrpcGreeter.exe ...

3rd: Fault bucket 2242750238749681031, type 1 Event Name: APPCRASH Response: Not available Cab Id: 0

Problem signature: P1: GrpcGreeter.exe ...


Please help. Thank you.

service
grpc
asked on Stack Overflow Nov 11, 2020 by TomV

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0