Closed jchapmanCR closed 1 year ago
Hello.
By default docker containers are not allowed to access host machine network.
You may find usefull information there to acheive what you want here https://medium.com/@TimvanBaarsen/how-to-connect-to-the-docker-host-from-inside-a-docker-container-112b4c71bc66 .
I hope this helps !
(Of course, adding supabase to the docker-compose, or fully running Quivr on the host is also an option)
@jchapmanCR Hi I am trying to achieve the same thing. Would you mind sharing your repo?
Hello.
By default docker containers are not allowed to access host machine network.
You may find usefull information there to acheive what you want here https://medium.com/@TimvanBaarsen/how-to-connect-to-the-docker-host-from-inside-a-docker-container-112b4c71bc66 .
I hope this helps !
(Of course, adding supabase to the docker-compose, or fully running Quivr on the host is also an option)
Thanks for the insights @DKFN I got past the current exception in Quivr frontend by running on an EC2 instance and pointing it back on itself with an actual IP address, but am now experiencing socket timeout exceptions when trying to create a new brain. Not sure what's happening here:
"GET /brains/ HTTP/1.1" 500 Internal Server Error backend-core | ERROR: Exception in ASGI application backend-core | Traceback (most recent call last): backend-core | File "/usr/local/lib/python3.11/site-packages/httpcore/_exceptions.py", line 10, in map_exceptions backend-core | yield backend-core | File "/usr/local/lib/python3.11/site-packages/httpcore/backends/sync.py", line 94, in connect_tcp backend-core | sock = socket.create_connection( backend-core | ^^^^^^^^^^^^^^^^^^^^^^^^^ backend-core | File "/usr/local/lib/python3.11/socket.py", line 851, in create_connection backend-core | raise exceptions[0] backend-core | File "/usr/local/lib/python3.11/socket.py", line 836, in create_connection backend-core | sock.connect(sa) backend-core | TimeoutError: timed out backend-core | backend-core | backend-core | During handling of the above exception, another exception occurred: backend-core | backend-core | backend-core | Traceback (most recent call last): backend-core | File "/usr/local/lib/python3.11/site-packages/httpx/_transports/default.py", line 60, in map_httpcore_exceptions backend-core | yield backend-core | File "/usr/local/lib/python3.11/site-packages/httpx/_transports/default.py", line 218, in handle_request backend-core | resp = self._pool.handle_request(req) backend-core | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ backend-core | File "/usr/local/lib/python3.11/site-packages/httpcore/_sync/connection_pool.py", line 253, in handle_request backend-core | raise exc backend-core | File "/usr/local/lib/python3.11/site-packages/httpcore/_sync/connection_pool.py", line 237, in handle_request backend-core | response = connection.handle_request(request) backend-core | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ backend-core | File "/usr/local/lib/python3.11/site-packages/httpcore/_sync/connection.py", line 86, in handle_request backend-core | raise exc backend-core | File "/usr/local/lib/python3.11/site-packages/httpcore/_sync/connection.py", line 63, in handle_request backend-core | stream = self._connect(request) backend-core | ^^^^^^^^^^^^^^^^^^^^^^ backend-core | File "/usr/local/lib/python3.11/site-packages/httpcore/_sync/connection.py", line 111, in _connect backend-core | stream = self._network_backend.connect_tcp(kwargs) backend-core | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ backend-core | File "/usr/local/lib/python3.11/site-packages/httpcore/backends/sync.py", line 93, in connect_tcp backend-core | with map_exceptions(exc_map): backend-core | File "/usr/local/lib/python3.11/contextlib.py", line 155, in exit backend-core | self.gen.throw(typ, value, traceback) backend-core | File "/usr/local/lib/python3.11/site-packages/httpcore/_exceptions.py", line 14, in map_exceptions backend-core | raise to_exc(exc) backend-core | httpcore.ConnectTimeout: timed out backend-core | backend-core | backend-core | The above exception was the direct cause of the following exception: backend-core | backend-core | backend-core | Traceback (most recent call last): backend-core | File "/usr/local/lib/python3.11/site-packages/uvicorn/protocols/http/h11_impl.py", line 428, in run_asgi backend-core | result = await app( # type: ignore[func-returns-value] backend-core | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ backend-core | File "/usr/local/lib/python3.11/site-packages/uvicorn/middleware/proxy_headers.py", line 78, in call backend-core | return await self.app(scope, receive, send) backend-core | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ backend-core | File "/usr/local/lib/python3.11/site-packages/fastapi/applications.py", line 276, in call backend-core | await super().call(scope, receive, send) backend-core | File "/usr/local/lib/python3.11/site-packages/starlette/applications.py", line 122, in call backend-core | await self.middleware_stack(scope, receive, send) backend-core | File "/usr/local/lib/python3.11/site-packages/starlette/middleware/errors.py", line 184, in call backend-core | raise exc backend-core | File "/usr/local/lib/python3.11/site-packages/starlette/middleware/errors.py", line 162, in call backend-core | await self.app(scope, receive, _send) backend-core | File "/usr/local/lib/python3.11/site-packages/starlette/middleware/cors.py", line 91, in call backend-core | await self.simple_response(scope, receive, send, request_headers=headers) backend-core | File "/usr/local/lib/python3.11/site-packages/starlette/middleware/cors.py", line 146, in simple_response backend-core | await self.app(scope, receive, send) backend-core | File "/usr/local/lib/python3.11/site-packages/starlette/middleware/exceptions.py", line 79, in call backend-core | raise exc backend-core | File "/usr/local/lib/python3.11/site-packages/starlette/middleware/exceptions.py", line 68, in call backend-core | await self.app(scope, receive, sender) backend-core | File "/usr/local/lib/python3.11/site-packages/fastapi/middleware/asyncexitstack.py", line 21, in call backend-core | raise e backend-core | File "/usr/local/lib/python3.11/site-packages/fastapi/middleware/asyncexitstack.py", line 18, in call backend-core | await self.app(scope, receive, send) backend-core | File "/usr/local/lib/python3.11/site-packages/starlette/routing.py", line 718, in call backend-core | await route.handle(scope, receive, send) backend-core | File "/usr/local/lib/python3.11/site-packages/starlette/routing.py", line 276, in handle backend-core | await self.app(scope, receive, send) backend-core | File "/usr/local/lib/python3.11/site-packages/starlette/routing.py", line 66, in app backend-core | response = await func(request) backend-core | ^^^^^^^^^^^^^^^^^^^ backend-core | File "/usr/local/lib/python3.11/site-packages/fastapi/routing.py", line 237, in app backend-core | raw_response = await run_endpoint_function( backend-core | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ backend-core | File "/usr/local/lib/python3.11/site-packages/fastapi/routing.py", line 163, in run_endpoint_function backend-core | return await dependant.call(values) backend-core | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ backend-core | File "/code/routes/brain_routes.py", line 34, in brain_endpoint backend-core | brains = brain.get_user_brains(current_user.id) backend-core | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ backend-core | File "/code/models/brains.py", line 85, in get_user_brains backend-core | .execute() backend-core | ^^^^^^^^^ backend-core | File "/usr/local/lib/python3.11/site-packages/postgrest/_sync/request_builder.py", line 55, in execute backend-core | r = self.session.request( backend-core | ^^^^^^^^^^^^^^^^^^^^^ backend-core | File "/usr/local/lib/python3.11/site-packages/httpx/_client.py", line 821, in request backend-core | return self.send(request, auth=auth, follow_redirects=follow_redirects) backend-core | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ backend-core | File "/usr/local/lib/python3.11/site-packages/httpx/_client.py", line 908, in send backend-core | response = self._send_handling_auth( backend-core | ^^^^^^^^^^^^^^^^^^^^^^^^^ backend-core | File "/usr/local/lib/python3.11/site-packages/httpx/_client.py", line 936, in _send_handling_auth backend-core | response = self._send_handling_redirects( backend-core | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ backend-core | File "/usr/local/lib/python3.11/site-packages/httpx/_client.py", line 973, in _send_handling_redirects backend-core | response = self._send_single_request(request) backend-core | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ backend-core | File "/usr/local/lib/python3.11/site-packages/httpx/_client.py", line 1009, in _send_single_request backend-core | response = transport.handle_request(request) backend-core | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ backend-core | File "/usr/local/lib/python3.11/site-packages/httpx/_transports/default.py", line 217, in handle_request backend-core | with map_httpcore_exceptions(): backend-core | File "/usr/local/lib/python3.11/contextlib.py", line 155, in exit backend-core | self.gen.throw(typ, value, traceback) backend-core | File "/usr/local/lib/python3.11/site-packages/httpx/_transports/default.py", line 77, in map_httpcore_exceptions backend-core | raise mapped_exc(message) from exc backend-core | httpx.ConnectTimeout: timed out I increased the timeouts in backend/core models/settings.py to 60 seconds:
options=ClientOptions(storage_client_timeout=60, postgrest_client_timeout=60)
This just makes the eventual timeout take 60 seconds instead of 5. Not sure why I cannot create a brain.
I finally got it working, but the networking was non-intuitive for self-hosting Supabase & Quivr on the same box.
@jchapmanCR > I finally got it working, but the networking was non-intuitive for self-hosting Supabase & Quivr on the same box.
please sir how do you solve this problem? i am getting an "error occurred while creating a brain" when i want to create a brain
I am running a local self-hosted Supabase instance on my local machine along with a self-hosted dockerized Quiver instance. I have run the table initialization scripts in Supabase and have added a user for auth to my Supabase auth table. I am able to login successfully to my self-hosted Quiver with that user; however, whenever the page loads a GET request is made to /brains/default triggers a 500 return from the backend-core container (Traceback below). Any request in the system regarding brains will result in a 500 on the server. The bottom line issue is :
httpx.ConnectError: [Errno 99] Cannot assign requested address
frontend/.env:
NEXT_PUBLIC_ENV=local NEXT_PUBLIC_BACKEND_URL=http://localhost:5050 NEXT_PUBLIC_SUPABASE_URL=http://localhost:8000/ NEXT_PUBLIC_SUPABASE_ANON_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyAgCiAgICAicm9sZSI6ICJhbm9uIiwKICAgICJpc3MiOiAic3VwYWJhc2UtZGVtbyIsCiAgICAiaWF0IjogMTY0MTc2OTIwMCwKICAgICJleHAiOiAxNzk5NTM1NjAwCn0.dc_X5iR_VP_qT0zsiyj_I_OZ2T9FtRU2BBNWN8Bu4GE NEXT_PUBLIC_JUNE_API_KEY=null
backend/core/.env: `SUPABASE_URL=http://localhost:8000/ SUPABASE_SERVICE_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyAgCiAgICAicm9sZSI6ICJhbm9uIiwKICAgICJpc3MiOiAic3VwYWJhc2UtZGVtbyIsCiAgICAiaWF0IjogMTY0MTc2OTIwMCwKICAgICJleHAiOiAxNzk5NTM1NjAwCn0.dc_X5iR_VP_qT0zsiyj_I_OZ2T9FtRU2BBNWN8Bu4GE OPENAI_API_KEY=null ANTHROPIC_API_KEY=null JWT_SECRET_KEY=your-super-secret-jwt-token-with-at-least-32-characters-long AUTHENTICATE=true GOOGLE_APPLICATION_CREDENTIALS=null GOOGLE_CLOUD_PROJECT=null MAX_BRAIN_SIZE=52428800 MAX_REQUESTS_NUMBER=200 MAX_BRAIN_PER_USER=5
Private LLM Variables
PRIVATE=False MODEL_PATH=./local_models/ggml-gpt4all-j-v1.3-groovy.bin
RESEND
RESEND_API_KEY=null RESEND_EMAIL_ADDRESS=onboarding@resend.dev`
Trace:
backend-core | INFO: 172.25.0.1:47486 - "GET /brains/default/ HTTP/1.1" 500 Internal Server Error backend-core | ERROR: Exception in ASGI application backend-core | Traceback (most recent call last): backend-core | File "/usr/local/lib/python3.11/site-packages/httpcore/_exceptions.py", line 10, in map_exceptions backend-core | yield backend-core | File "/usr/local/lib/python3.11/site-packages/httpcore/backends/sync.py", line 94, in connect_tcp backend-core | sock = socket.create_connection( backend-core | ^^^^^^^^^^^^^^^^^^^^^^^^^ backend-core | File "/usr/local/lib/python3.11/socket.py", line 851, in create_connection backend-core | raise exceptions[0] backend-core | File "/usr/local/lib/python3.11/socket.py", line 836, in create_connection backend-core | sock.connect(sa) backend-core | OSError: [Errno 99] Cannot assign requested address backend-core | backend-core | During handling of the above exception, another exception occurred: backend-core | backend-core | Traceback (most recent call last): backend-core | File "/usr/local/lib/python3.11/site-packages/httpx/_transports/default.py", line 60, in map_httpcore_exceptions backend-core | yield backend-core | File "/usr/local/lib/python3.11/site-packages/httpx/_transports/default.py", line 218, in handle_request backend-core | resp = self._pool.handle_request(req) backend-core | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ backend-core | File "/usr/local/lib/python3.11/site-packages/httpcore/_sync/connection_pool.py", line 253, in handle_request backend-core | raise exc backend-core | File "/usr/local/lib/python3.11/site-packages/httpcore/_sync/connection_pool.py", line 237, in handle_request backend-core | response = connection.handle_request(request) backend-core | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ backend-core | File "/usr/local/lib/python3.11/site-packages/httpcore/_sync/connection.py", line 86, in handle_request backend-core | raise exc backend-core | File "/usr/local/lib/python3.11/site-packages/httpcore/_sync/connection.py", line 63, in handle_request backend-core | stream = self._connect(request) backend-core | ^^^^^^^^^^^^^^^^^^^^^^ backend-core | File "/usr/local/lib/python3.11/site-packages/httpcore/_sync/connection.py", line 111, in _connect backend-core | stream = self._network_backend.connect_tcp(kwargs) backend-core | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ backend-core | File "/usr/local/lib/python3.11/site-packages/httpcore/backends/sync.py", line 93, in connect_tcp backend-core | with map_exceptions(exc_map): backend-core | File "/usr/local/lib/python3.11/contextlib.py", line 155, in exit backend-core | self.gen.throw(typ, value, traceback) backend-core | File "/usr/local/lib/python3.11/site-packages/httpcore/_exceptions.py", line 14, in map_exceptions backend-core | raise to_exc(exc) backend-core | httpcore.ConnectError: [Errno 99] Cannot assign requested address backend-core | backend-core | The above exception was the direct cause of the following exception: backend-core | backend-core | Traceback (most recent call last): backend-core | File "/usr/local/lib/python3.11/site-packages/uvicorn/protocols/http/h11_impl.py", line 428, in run_asgi backend-core | result = await app( # type: ignore[func-returns-value] backend-core | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ backend-core | File "/usr/local/lib/python3.11/site-packages/uvicorn/middleware/proxy_headers.py", line 78, in call backend-core | return await self.app(scope, receive, send) backend-core | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ backend-core | File "/usr/local/lib/python3.11/site-packages/fastapi/applications.py", line 276, in call backend-core | await super().call(scope, receive, send) backend-core | File "/usr/local/lib/python3.11/site-packages/starlette/applications.py", line 122, in call backend-core | await self.middleware_stack(scope, receive, send) backend-core | File "/usr/local/lib/python3.11/site-packages/starlette/middleware/errors.py", line 184, in call backend-core | raise exc backend-core | File "/usr/local/lib/python3.11/site-packages/starlette/middleware/errors.py", line 162, in call backend-core | await self.app(scope, receive, _send) backend-core | File "/usr/local/lib/python3.11/site-packages/starlette/middleware/cors.py", line 91, in call backend-core | await self.simple_response(scope, receive, send, request_headers=headers) backend-core | File "/usr/local/lib/python3.11/site-packages/starlette/middleware/cors.py", line 146, in simple_response backend-core | await self.app(scope, receive, send) backend-core | File "/usr/local/lib/python3.11/site-packages/starlette/middleware/exceptions.py", line 79, in call backend-core | raise exc backend-core | File "/usr/local/lib/python3.11/site-packages/starlette/middleware/exceptions.py", line 68, in call backend-core | await self.app(scope, receive, sender) backend-core | File "/usr/local/lib/python3.11/site-packages/fastapi/middleware/asyncexitstack.py", line 21, in call backend-core | raise e backend-core | File "/usr/local/lib/python3.11/site-packages/fastapi/middleware/asyncexitstack.py", line 18, in call backend-core | await self.app(scope, receive, send) backend-core | File "/usr/local/lib/python3.11/site-packages/starlette/routing.py", line 718, in call backend-core | await route.handle(scope, receive, send) backend-core | File "/usr/local/lib/python3.11/site-packages/starlette/routing.py", line 276, in handle backend-core | await self.app(scope, receive, send) backend-core | File "/usr/local/lib/python3.11/site-packages/starlette/routing.py", line 66, in app backend-core | response = await func(request) backend-core | ^^^^^^^^^^^^^^^^^^^ backend-core | File "/usr/local/lib/python3.11/site-packages/fastapi/routing.py", line 237, in app backend-core | raw_response = await run_endpoint_function( backend-core | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ backend-core | File "/usr/local/lib/python3.11/site-packages/fastapi/routing.py", line 163, in run_endpoint_function backend-core | return await dependant.call(values) backend-core | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ backend-core | File "/code/routes/brain_routes.py", line 53, in get_default_brain_endpoint backend-core | brain = get_default_user_brain_or_create_new(current_user) backend-core | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ backend-core | File "/code/models/brains.py", line 306, in get_default_user_brain_or_create_new backend-core | default_brain = get_default_user_brain(user) backend-core | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ backend-core | File "/code/models/brains.py", line 286, in get_default_user_brain backend-core | .execute() backend-core | ^^^^^^^^^ backend-core | File "/usr/local/lib/python3.11/site-packages/postgrest/_sync/request_builder.py", line 55, in execute backend-core | r = self.session.request( backend-core | ^^^^^^^^^^^^^^^^^^^^^ backend-core | File "/usr/local/lib/python3.11/site-packages/httpx/_client.py", line 821, in request backend-core | return self.send(request, auth=auth, follow_redirects=follow_redirects) backend-core | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ backend-core | File "/usr/local/lib/python3.11/site-packages/httpx/_client.py", line 908, in send backend-core | response = self._send_handling_auth( backend-core | ^^^^^^^^^^^^^^^^^^^^^^^^^ backend-core | File "/usr/local/lib/python3.11/site-packages/httpx/_client.py", line 936, in _send_handling_auth backend-core | response = self._send_handling_redirects( backend-core | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ backend-core | File "/usr/local/lib/python3.11/site-packages/httpx/_client.py", line 973, in _send_handling_redirects backend-core | response = self._send_single_request(request) backend-core | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ backend-core | File "/usr/local/lib/python3.11/site-packages/httpx/_client.py", line 1009, in _send_single_request backend-core | response = transport.handle_request(request) backend-core | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ backend-core | File "/usr/local/lib/python3.11/site-packages/httpx/_transports/default.py", line 217, in handle_request backend-core | with map_httpcore_exceptions(): backend-core | File "/usr/local/lib/python3.11/contextlib.py", line 155, in exit backend-core | self.gen.throw(typ, value, traceback) backend-core | File "/usr/local/lib/python3.11/site-packages/httpx/_transports/default.py", line 77, in map_httpcore_exceptions backend-core | raise mapped_exc(message) from exc backend-core | httpx.ConnectError: [Errno 99] Cannot assign requested address
Please help me to resolve this issue. Running a self-hosted instance would be epic!