microsoft / azure-container-apps

Roadmap and issues for Azure Container Apps
MIT License
372 stars 29 forks source link

Dapr sidecar cannot start with nextjs application #1182

Open Garwakizashi opened 6 months ago

Garwakizashi commented 6 months ago

This issue is a: (mark with an x)

Issue description

Not sure if this can be classed as a bug, as it is very likely I'm missing on my end to get this working; but I'd like to get some guidance with this issue I'm having.

I'm trying to enable dapr on an ACA that runs a nextjs application.

The application itself is running on port 3000, and that is also what I've set the app-port of dapr to be as well. However, the the container just keeps crashing, looking at the logs of daprd, it just shows the debug message several times:

level=debug msg="api error: code = Internal desc = dapr is not ready"

before eventually:

level=info msg="Received signal 'terminated'; beginning shutdown" 

I did notice that it said it is waiting on the port, but the application never gets discovered. Could this be why it is failing? Is there a requirement on my side to set up in nextjs to allow dapr to discover it? The ACA ingress port is also set to 3000, and is working as expected. I have several ACA's that are working fine with dapr enabled, so not sure why this particular app would fail. Unsure if this helps, but I've been able to run dapr locally and the application gets discovered fine.

Steps to reproduce

  1. Deploy a nextjs application on ACA
  2. Enable Dapr

Expected behavior Daprd container to work. Actual behavior Daprd container keeps restarting due to the described error above.

Additional context

Sample logs from log stream (removed instance name):

2024-05-29T22:14:14.61413  Connecting to the container 'daprd'...
2024-05-29T22:14:14.63342  Successfully Connected to container: 'daprd'
2024-05-29T22:11:33.722306026Z time="2024-05-29T22:11:33.722256786Z" level=info msg="Enabled gRPC tracing middleware" app_id=test scope=dapr.runtime.grpc.internal type=log ver=1.12.5
2024-05-29T22:11:33.722310735Z time="2024-05-29T22:11:33.722267235Z" level=info msg="Enabled gRPC metrics middleware" app_id=test scope=dapr.runtime.grpc.internal type=log ver=1.12.5
2024-05-29T22:11:33.722351340Z time="2024-05-29T22:11:33.722302922Z" level=info msg="Internal gRPC server is running on port 50002" app_id=test scope=dapr.runtime type=log ver=1.12.5
2024-05-29T22:11:33.722363443Z time="2024-05-29T22:11:33.722328089Z" level=info msg="application protocol: http. waiting on port 3000.  This will block until the app is listening on that port." app_id=test scope=dapr.runtime type=log ver=1.12.5
2024-05-29T22:11:36.882162928Z time="2024-05-29T22:11:36.881484614Z" level=debug msg="api error: code = Internal desc = dapr is not ready" app_id=test scope=dapr.runtime.http type=log ver=1.12.5
2024-05-29T22:11:36.882186211Z time="2024-05-29T22:11:36.881724551Z" level=debug msg="api error: code = Internal desc = dapr is not ready" app_id=test  scope=dapr.runtime.http type=log ver=1.12.5
2024-05-29T22:11:42.881653629Z time="2024-05-29T22:11:42.881480949Z" level=debug msg="api error: code = Internal desc = dapr is not ready" app_id=test  scope=dapr.runtime.http type=log ver=1.12.5
2024-05-29T22:11:42.881991531Z time="2024-05-29T22:11:42.881895281Z" level=debug msg="api error: code = Internal desc = dapr is not ready" app_id=test  scope=dapr.runtime.http type=log ver=1.12.5
2024-05-29T22:11:48.882059272Z time="2024-05-29T22:11:48.881965535Z" level=debug msg="api error: code = Internal desc = dapr is not ready" app_id=test scope=dapr.runtime.http type=log ver=1.12.5
2024-05-29T22:11:48.882360073Z time="2024-05-29T22:11:48.88213447Z" level=debug msg="api error: code = Internal desc = dapr is not ready" app_id=test scope=dapr.runtime.http type=log ver=1.12.5
2024-05-29T22:11:48.883884885Z time="2024-05-29T22:11:48.883683019Z" level=debug msg="api error: code = Internal desc = dapr is not ready" app_id=test  scope=dapr.runtime.http type=log ver=1.12.5
2024-05-29T22:11:48.891698249Z time="2024-05-29T22:11:48.891019754Z" level=info msg="Received signal 'terminated'; beginning shutdown" app_id=test  scope=dapr.signals type=log ver=1.12.5
2024-05-29T22:11:48.891709700Z time="2024-05-29T22:11:48.891051904Z" level=debug msg="stopping workload cert expiry watcher" app_id=test scope=dapr.runtime.security type=log ver=1.12.5
2024-05-29T22:11:48.891714890Z time="2024-05-29T22:11:48.891163221Z" level=debug msg="Graceful shutdown timeout: 5s" app_id=test scope=dapr.concurrency.closer type=log ver=1.12.5
2024-05-29T22:11:48.891719438Z time="2024-05-29T22:11:48.891202174Z" level=info msg="Dapr is shutting down" app_id=test  scope=dapr.runtime type=log ver=1.12.5
2024-05-29T22:11:48.891724207Z time="2024-05-29T22:11:48.891228814Z" level=info msg="Dapr runtime stopped" app_id=test scope=dapr.runtime type=log ver=1.12.5
2024-05-29T22:11:48.891730378Z time="2024-05-29T22:11:48.89124825Z" level=info msg="Shutting down workflow engine" app_id=test scope=dapr.runtime type=log ver=1.12.5
2024-05-29T22:11:48.891734857Z time="2024-05-29T22:11:48.891355159Z" level=info msg="Closing HTTP server :3501…" app_id=test scope=dapr.runtime.http type=log ver=1.12.5
2024-05-29T22:11:48.891739065Z time="2024-05-29T22:11:48.891432924Z" level=info msg="Closing HTTP server [::1]:3500…" app_id=test  scope=dapr.runtime.http type=log ver=1.12.5
2024-05-29T22:11:48.891743823Z time="2024-05-29T22:11:48.891477347Z" level=info msg="Closing HTTP server 127.0.0.1:3500…" app_id=test scope=dapr.runtime.http type=log ver=1.12.5
BlackRider97 commented 5 months ago

@Garwakizashi There is no known issue with Dapr integration with ACA. We have variety of Apps running in ACA and could not see any reason why it won't work for you. Can you please raise a support ticket with more details about your App Env and other details to debug this better? Please link this GitHub issue to be aware of the context.

Garwakizashi commented 5 months ago

@Garwakizashi There is no known issue with Dapr integration with ACA. We have variety of Apps running in ACA and could not see any reason why it won't work for you. Can you please raise a support ticket with more details about your App Env and other details to debug this better? Please link this GitHub issue to be aware of the context.

Thanks for the reply. I wasn't able to figure why it wouldn't work, but I managed to get around it by running the nextjs app behind nginx. Once it was behind nginx, the dapr sidecar started successfully.

bfigueir commented 1 month ago

+1

Also facing this issue with ACA. Locally I can run de Nextjs app with Dapr without issues. When deploying to ACA, Dapr gives the same error has stated by @Garwakizashi