Hi, I'm trying to deploy my app to google cloud ru...
# ask-ai
a
Hi, I'm trying to deploy my app to google cloud run when trying to run the frontend and backend in 2 services, each one of them was built with docker. To connect between the frontend and the backend, i put in the frontend service env vars : NEXT_PUBLIC_AGENT_SERVER_URL AGENT_SERVER_URL they both got the backend service url. My code uses react and python. The backend has agent that can join a conversation if button is getting pressed. the conversations are in rooms. The problem: It's working well locally. And, when running the services in google cloud, the frontend url is working well, but when clicking on the 'add agent' button (inside a room), it gives error : Error adding agent to room: Failed to fetch TypeError: Failed to fetch. However, When i open the URL of the deployed backend , it return "OK". But, i did an endpoint /health that returns 200 status to show that the backend server is alive. But, on production, when trying to access it, it returns 404. locally its working. I don't know if the backend service deployed and running well, or maybe the services aren't connected well to each other. Or maybe there is another problem I'm missing. On the logs of the backend service there is a loop, but maybe it happens because the agent didn't need to join a call:
Copy code
DEFAULT 2025-10-04T18:58:47.447493Z initializing process
DEFAULT 2025-10-04T18:58:57.747503Z 2025-10-04 18:58:57,748 - livekit.agents - INFO - killing process
DEFAULT 2025-10-04T18:58:57.747622Z killing process
DEFAULT 2025-10-04T18:58:58.647543Z 2025-10-04 18:58:57,749 - livekit.agents - ERROR - error initializing process
ERROR 2025-10-04T18:58:58.647595Z Traceback (most recent call last): File "/usr/local/lib/python3.11/asyncio/tasks.py", line 500, in wait_for return fut.result() ^^^^^^^^^^^^ File "/app/.venv/lib/python3.11/site-packages/livekit/agents/ipc/channel.py", line 47, in arecv_message return _read_message(await dplx.recv_bytes(), messages) ^^^^^^^^^^^^^^^^^^^^^^^ File "/app/.venv/lib/python3.11/site-packages/livekit/agents/utils/aio/duplex_unix.py", line 35, in recv_bytes len_bytes = await self._reader.readexactly(4) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/asyncio/streams.py", line 750, in readexactly await self._wait_for_data('readexactly') File "/usr/local/lib/python3.11/asyncio/streams.py", line 543, in _wait_for_data await self._waiter
DEFAULT 2025-10-04T18:58:58.647598Z asyncio.exceptions.CancelledError
DEFAULT 2025-10-04T18:58:58.647602Z The above exception was the direct cause of the following exception:
ERROR 2025-10-04T18:58:58.647615Z Traceback (most recent call last): File "/app/.venv/lib/python3.11/site-packages/livekit/agents/ipc/proc_pool.py", line 167, in _proc_spawn_task await proc.initialize() File "/app/.venv/lib/python3.11/site-packages/livekit/agents/ipc/supervised_proc.py", line 169, in initialize init_res = await asyncio.wait_for( ^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/asyncio/tasks.py", line 502, in wait_for raise exceptions.TimeoutError() from exc
DEFAULT 2025-10-04T18:58:58.647618Z TimeoutError
DEFAULT 2025-10-04T18:58:58.848165Z error initializing process
t
Thanks for reaching out, Ron. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Thanks so much for reaching out! To get a better understanding and help you smoothly troubleshoot this, could you please share a bit more info? • Are your frontend and backend services set up within the same Google Cloud project and region? • Could you tell me the exact URL format you're using for the backend service in your frontend environment variables? • Have you set up any authentication or firewall rules that might be affecting communication between the services? • Are there any specific logs or error messages from the frontend service when you click the 'add agent' button? With these details, we’ll be in a great spot to pinpoint any configuration or connectivity hiccups and get things running smoothly for you! Sources: Diagnosing Connection Errors with Connection Test Utility | README.md
a
the frontend and backend are on the same project and region. the url format: frontend-{number}.{region}.run.app didnt set auth rules no logs on frontend when click the 'add agent' button
t
It looks like the 404 error you're seeing for the
/health
endpoint, while the root URL works just fine, might be happening for a few reasons: • The
/health
endpoint may not be registered in your backend application. Sometimes, services use different paths like
/healthz
or just
/
for health checks. • It’s possible that the endpoint is only exposed under certain configurations. For instance, some features or flags might need to be turned on for the
/health
endpoint to become available. • The application inside the container might not be routing requests to
/health
correctly, even though the container itself is up and reachable. To help you troubleshoot this, here are a few friendly steps you can try: 1. Check if alternative paths like
/healthz
,
/
, or
/status
respond when accessed. 2. Take a look at your backend application code to make sure the
/health
route is properly registered and implemented. 3. Verify that your backend service is listening on the right port and is binding to
0.0.0.0
rather than
localhost
. 4. Have a peek at the backend service logs in Google Cloud Run to spot any errors during startup or route registration. 5. If you can, try running the container locally with Docker to see if the behavior is the same before deploying to Cloud Run. Please don’t hesitate to reach out if you’d like a hand with any of these steps—I’m here to help! Sources: tools/server/server.cpp | Deploy to a VM | LiveKit Docs | livekit-agents/livekit/agents/worker.py | pkg/service/service.go | main.go
a
5 i ran the backend container locally and it worked . i already sent you the errors of the backend service logs. is there anything I'm missing in the deployment? is there another way to check it? if the backend URL shows OK what does it mean?
t
It’s great that the backend URL shows "OK" at the root endpoint—that tells us the service is up and reachable! Now, the 404 error on specific endpoints like
/health
suggests that the application might not have a route defined for that path. This could happen because: • The
/health
endpoint hasn’t been implemented in the backend application yet. • The endpoint might be available under a different path, such as
/healthz
or just
/
. • Some features or configurations needed to expose
/health
might not be enabled. Here’s how you can check and hopefully resolve this: 1. Take a look at the backend application code or documentation to confirm the exact health endpoint path. 2. Make sure any necessary features (like the WHIP proxy) are turned on if they’re needed to expose
/health
. 3. If
/health
isn’t set up, try using the root
/
endpoint for your health checks. 4. Also, reviewing the backend service logs can be really helpful to spot any errors during startup or when routes are being registered. If you’d like, I’m here to help you walk through these steps or discuss any other details about your backend setup. Just let me know! Sources: Self-hosting the Ingress Service | LiveKit Docs | livekit-agents/livekit/agents/worker.py | tools/server/server.cpp
a
the main problem is that when running the services in google cloud, the frontend url is working well, but when clicking on the 'add agent' button (inside a room), it gives error : Error adding agent to room: Failed to fetch TypeError: Failed to fetch.
t
Let's work together to get to the bottom of the 'Failed to fetch' error. Could you please share a bit more about your setup? • Are your frontend and backend services communicating over HTTP or HTTPS? • Have you double-checked that the backend service URL is correctly set in your frontend environment variables? • Do you have any CORS (Cross-Origin Resource Sharing) policies on the backend that might be affecting requests from the frontend? • Does this error pop up all the time, or just in certain situations? With these details, I’ll be better equipped to help you find a solution. Looking forward to your reply!
a
https it always has this error
t
I'm sorry to hear you're encountering the 'Failed to fetch' error when using HTTPS between your frontend and backend in Google Cloud Run. Let's work through this together! Here are some friendly steps to help you investigate and hopefully resolve the issue: 1. Verify Backend URL: Double-check that the backend service URL is correctly set in your frontend environment variables and exactly matches the deployed backend's HTTPS URL. Sometimes a small mismatch can cause issues. 2. Check CORS Configuration: If your backend isn't allowing cross-origin requests from your frontend's domain, the browser might block the request. You can update the backend to include the right CORS headers to allow requests from your frontend. 3. SSL/TLS Configuration: Make sure your backend service is set up properly to handle HTTPS requests and that the SSL certificate is valid. This helps ensure secure communication. 4. Network Connectivity: It’s a good idea to confirm that your frontend can actually reach the backend service. You can try using tools like
curl
or
Postman
to test the backend endpoint directly from your frontend environment. 5. Inspect Browser Console: Take a peek at your browser’s developer tools for any detailed error messages or blocked requests. These can often give you more clues about what’s going on. Please feel free to reach out if you'd like me to walk you through any of these steps or if you have more details about the error. I'm here to help!