Closed sg30000 closed 1 month ago
The AxiosError: Network Error
you're encountering could be due to several reasons such as CORS configuration issues, incorrect base URL, network connectivity problems, the server not running, or a mismatch between HTTP and HTTPS protocols. Here are steps to troubleshoot and potentially resolve the issue:
Check CORS Configuration: Make sure the server accepts requests from your Next.js app's domain by configuring the Access-Control-Allow-Origin
header appropriately.
Verify Base URL: Ensure the URL returned by getAgentaApiUrl()
is correct and reachable. This function sets the baseURL
for Axios requests, so its accuracy is crucial.
Network Connectivity: Confirm that there's a stable network connection for both the client and server.
Server Status: Verify that the server you're trying to reach is operational.
Protocol Consistency: Ensure both your app and the server use the same protocol (HTTP or HTTPS) to avoid mixed content issues.
For Axios error handling, consider refining the error handling in your Axios interceptor for clearer feedback or debugging insights. The getAgentaApiUrl()
function is crucial as it determines the base URL for Axios requests, so its output should be a string representing the server's base URL.
If you have further questions or need more assistance, feel free to ask.
Hi @sg30000 can you please provide more context on the error? When is it happening? Does it happen in cloud or when self-hosting? What are the logs in the network. Please check https://docs.agenta.ai/developer_guides/contributing/file-issue
thx all for your reply , I will try again It happened when self-hosting
Hi need help for this issue Thx
@sg30000 @R-beep-AI
docker logs $(docker ps -q --latest --filter "ancestor=agenta-backend")
Would also be nice to go through the link that Mahmoud shared above so that we can better assist you!
@sg30000 @R-beep-AI
1. Can you specify which OS are you using ? 2. Can you paste in a comment the output of this command :
docker logs $(docker ps -q --latest --filter "ancestor=agenta-backend")
Would also be nice to go through the link that Mahmoud shared above so that we can better assist you!
hello , same problem.
steps here in an ubuntu 22.04 server:
cd /home
git clone https://github.com/Agenta-AI/agenta/
cd agenta
docker compose -f "docker-compose.yml" up -d --build
open the http://0.0.0.0:80 page will be fault by cors,
docker logs $(docker ps -q --latest --filter "ancestor=agenta-backend")
INFO: Will watch for changes in these directories: ['/app']
INFO: Uvicorn running on http://0.0.0.0:8000 (Press CTRL+C to quit)
INFO: Started reloader process [1] using StatReload
INFO: Started server process [8]
INFO: Waiting for application startup.
ERROR: Traceback (most recent call last):
File "/usr/local/lib/python3.9/site-packages/httpcore/_backends/anyio.py", line 114, in connect_tcp
stream: anyio.abc.ByteStream = await anyio.connect_tcp(
File "/usr/local/lib/python3.9/site-packages/anyio/_core/_sockets.py", line 221, in connect_tcp
await event.wait()
File "/usr/local/lib/python3.9/site-packages/anyio/_backends/_asyncio.py", line 597, in __aexit__
raise exceptions[0]
File "/usr/local/lib/python3.9/site-packages/anyio/_core/_sockets.py", line 167, in try_connect
stream = await asynclib.connect_tcp(remote_host, remote_port, local_address)
File "/usr/local/lib/python3.9/site-packages/anyio/_backends/_asyncio.py", line 1627, in connect_tcp
await get_running_loop().create_connection(
File "/usr/local/lib/python3.9/asyncio/base_events.py", line 1050, in create_connection
sock = await self._connect_sock(
File "/usr/local/lib/python3.9/asyncio/base_events.py", line 961, in _connect_sock
await self.sock_connect(sock, address)
File "/usr/local/lib/python3.9/asyncio/selector_events.py", line 500, in sock_connect
return await fut
asyncio.exceptions.CancelledError
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.9/site-packages/httpcore/_exceptions.py", line 10, in map_exceptions
yield
File "/usr/local/lib/python3.9/site-packages/httpcore/_backends/anyio.py", line 121, in connect_tcp
stream._raw_socket.setsockopt(*option) # type: ignore[attr-defined] # pragma: no cover
File "/usr/local/lib/python3.9/site-packages/anyio/_core/_tasks.py", line 119, in __exit__
raise TimeoutError
TimeoutError
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/local/lib/python3.9/site-packages/httpx/_transports/default.py", line 60, in map_httpcore_exceptions
yield
File "/usr/local/lib/python3.9/site-packages/httpx/_transports/default.py", line 353, in handle_async_request
resp = await self._pool.handle_async_request(req)
File "/usr/local/lib/python3.9/site-packages/httpcore/_async/connection_pool.py", line 262, in handle_async_request
raise exc
File "/usr/local/lib/python3.9/site-packages/httpcore/_async/connection_pool.py", line 245, in handle_async_request
response = await connection.handle_async_request(request)
File "/usr/local/lib/python3.9/site-packages/httpcore/_async/connection.py", line 92, in handle_async_request
raise exc
File "/usr/local/lib/python3.9/site-packages/httpcore/_async/connection.py", line 69, in handle_async_request
stream = await self._connect(request)
File "/usr/local/lib/python3.9/site-packages/httpcore/_async/connection.py", line 117, in _connect
stream = await self._network_backend.connect_tcp(**kwargs)
File "/usr/local/lib/python3.9/site-packages/httpcore/_backends/auto.py", line 31, in connect_tcp
return await self._backend.connect_tcp(
File "/usr/local/lib/python3.9/site-packages/httpcore/_backends/anyio.py", line 121, in connect_tcp
stream._raw_socket.setsockopt(*option) # type: ignore[attr-defined] # pragma: no cover
File "/usr/local/lib/python3.9/contextlib.py", line 137, in __exit__
self.gen.throw(typ, value, traceback)
File "/usr/local/lib/python3.9/site-packages/httpcore/_exceptions.py", line 14, in map_exceptions
raise to_exc(exc) from exc
httpcore.ConnectTimeout
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/local/lib/python3.9/site-packages/starlette/routing.py", line 734, in lifespan
async with self.lifespan_context(app) as maybe_state:
File "/usr/local/lib/python3.9/contextlib.py", line 181, in __aenter__
return await self.gen.__anext__()
File "/app/agenta_backend/main.py", line 56, in lifespan
await templates_manager.update_and_sync_templates(cache=cache)
File "/app/agenta_backend/services/templates_manager.py", line 32, in update_and_sync_templates
templates = await retrieve_templates_from_dockerhub_cached(cache)
File "/app/agenta_backend/services/templates_manager.py", line 86, in retrieve_templates_from_dockerhub_cached
response = await retrieve_templates_from_dockerhub(
File "/usr/local/lib/python3.9/site-packages/backoff/_async.py", line 151, in retry
ret = await target(*args, **kwargs)
File "/app/agenta_backend/services/templates_manager.py", line 143, in retrieve_templates_from_dockerhub
response = await client.get(f"{url}/{repo_name}/tags", timeout=10)
File "/usr/local/lib/python3.9/site-packages/httpx/_client.py", line 1757, in get
return await self.request(
File "/usr/local/lib/python3.9/site-packages/httpx/_client.py", line 1530, in request
return await self.send(request, auth=auth, follow_redirects=follow_redirects)
File "/usr/local/lib/python3.9/site-packages/httpx/_client.py", line 1617, in send
response = await self._send_handling_auth(
File "/usr/local/lib/python3.9/site-packages/httpx/_client.py", line 1645, in _send_handling_auth
response = await self._send_handling_redirects(
File "/usr/local/lib/python3.9/site-packages/httpx/_client.py", line 1682, in _send_handling_redirects
response = await self._send_single_request(request)
File "/usr/local/lib/python3.9/site-packages/httpx/_client.py", line 1719, in _send_single_request
response = await transport.handle_async_request(request)
File "/usr/local/lib/python3.9/site-packages/httpx/_transports/default.py", line 353, in handle_async_request
resp = await self._pool.handle_async_request(req)
File "/usr/local/lib/python3.9/contextlib.py", line 137, in __exit__
self.gen.throw(typ, value, traceback)
File "/usr/local/lib/python3.9/site-packages/httpx/_transports/default.py", line 77, in map_httpcore_exceptions
raise mapped_exc(message) from exc
httpx.ConnectTimeout
ERROR: Application startup failed. Exiting.
Thanks a lot @timiil for the logs!
The issue is that our backend is attempting to download the images for the templates from docker hub yet the connection is timing out. I guess where you are, the connection to docker hub is not very stable.
I have increased the timeout from 10 seconds to 90 seconds in the new release (should be online one hour or so after this commment is published). Please try pulling the latest image for agenta and deploy again, hopefully, if you have access to docker hub, then the problem would be resolved.
I published the new release which should fix the problem @timiil @sg30000 @R-beep-AI can you please run:
docker compose -f docker-compose.gh.yml up -d --pull always
To pull the latest versions and deploy again. Can you please let me know if that resolves the issue. Thank you!
I published the new release which should fix the problem @timiil @sg30000 @R-beep-AI can you please run:
docker compose -f docker-compose.gh.yml up -d --pull always
To pull the latest versions and deploy again. Can you please let me know if that resolves the issue. Thank you!
thanks for your kindly reply, but, seems the new version get a 502 bad gateway error on the startup page
@timiil I think you are using an old version of the docker-compose.gh.yml
Can you please download the latest version and try again:
curl -L https://raw.githubusercontent.com/agenta-ai/agenta/main/docker-compose.gh.yml -o docker-compose.gh.yml
@timiil I think you are using an old version of the docker-compose.gh.yml
Can you please download the latest version and try again:
curl -L https://raw.githubusercontent.com/agenta-ai/agenta/main/docker-compose.gh.yml -o docker-compose.gh.yml
i had rm -rf source code folder and git clone again, failed like this:
@timiil We were not able to reproduce the issue. I see that you are using 192.168.1.246 and not running this on localhost. What set up are you using there?
AxiosError: Network Error
what's the problem, thx