Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

APIConnectionError: Connection error. #85

Open
TechieHank opened this issue Oct 23, 2024 · 8 comments
Open

APIConnectionError: Connection error. #85

TechieHank opened this issue Oct 23, 2024 · 8 comments

Comments

@TechieHank
Copy link

I have installed the docker image and I have tested that my via curl and my API key can talk to Anthropic. When I run the docker container, noVNC starts and I can even browse the web, but when I run a prompt for the API to work, I get this error message:

File "/home/computeruse/.pyenv/versions/3.11.6/lib/python3.11/site-packages/streamlit/runtime/scriptrunner/exec_code.py", line 88, in exec_func_with_error_handling
result = func()
^^^^^^
File "/home/computeruse/.pyenv/versions/3.11.6/lib/python3.11/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 579, in code_to_exec
exec(code, module.dict)
File "/home/computeruse/computer_use_demo/streamlit.py", line 357, in
asyncio.run(main())
File "/home/computeruse/.pyenv/versions/3.11.6/lib/python3.11/asyncio/runners.py", line 190, in run
return runner.run(main)
^^^^^^^^^^^^^^^^
File "/home/computeruse/.pyenv/versions/3.11.6/lib/python3.11/asyncio/runners.py", line 118, in run
return self._loop.run_until_complete(task)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/computeruse/.pyenv/versions/3.11.6/lib/python3.11/asyncio/base_events.py", line 653, in run_until_complete
return future.result()
^^^^^^^^^^^^^^^
File "/home/computeruse/computer_use_demo/streamlit.py", line 213, in main
st.session_state.messages = await sampling_loop(
^^^^^^^^^^^^^^^^^^^^

Thanks in advance for guidance on how to fix this issue.

@TechieHank
Copy link
Author

Screenshot 2024-10-23 at 10 52 14 AM

@rvadhavk
Copy link

I had the same error message and found more info in the logs in terminal where I started the container:
httpx.LocalProtocolError: Illegal header value b'<REDACTED> '

Turns out I had a trailing space when I pasted my API key.

@TechieHank
Copy link
Author

@rvadhavk - Thanks for the feedback. I prune all my containers from docker and re-ran bash script without any trailing spaces. Unfortunately - the same issue is happening :( - I did tried to do a sudo apt-get update inside the docker container and it started complaining about a certificate.

Screenshot 2024-10-23 at 5 48 02 PM

@x5a x5a mentioned this issue Oct 23, 2024
@x5a
Copy link
Collaborator

x5a commented Oct 23, 2024

@TechieHank are you on a network that has a firewall/proxy that re-encrypts traffic?

Regardless, I updated the latest image with a more verbose error log - can you post the traceback after doing a docker pull ghcr.io/anthropics/computer-use-demo:latest and restarting your container?

@moo1o
Copy link

moo1o commented Oct 24, 2024

Are you using an intranet?
I may have the same problem as you, but I also had a Connection Error and the problem was with the certificate. So I updated the certificate and it was fixed.

@TechieHank
Copy link
Author

@TechieHank are you on a network that has a firewall/proxy that re-encrypts traffic?

Regardless, I updated the latest image with a more verbose error log - can you post the traceback after doing a docker pull ghcr.io/anthropics/computer-use-demo:latest and restarting your container?

@x5a - Here's the Traceback after doing an update of the image:

File "/home/computeruse/.pyenv/versions/3.11.6/lib/python3.11/site-packages/httpx/_transports/default.py", line 72, in map_httpcore_exceptions
yield

File "/home/computeruse/.pyenv/versions/3.11.6/lib/python3.11/site-packages/httpx/_transports/default.py", line 236, in handle_request
resp = self._pool.handle_request(req)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/home/computeruse/.pyenv/versions/3.11.6/lib/python3.11/site-packages/httpcore/_sync/connection_pool.py", line 216, in handle_request
raise exc from None

File "/home/computeruse/.pyenv/versions/3.11.6/lib/python3.11/site-packages/httpcore/_sync/connection_pool.py", line 196, in handle_request
response = connection.handle_request(
^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/home/computeruse/.pyenv/versions/3.11.6/lib/python3.11/site-packages/httpcore/_sync/connection.py", line 99, in handle_request
raise exc

File "/home/computeruse/.pyenv/versions/3.11.6/lib/python3.11/site-packages/httpcore/_sync/connection.py", line 76, in handle_request
stream = self._connect(request)
^^^^^^^^^^^^^^^^^^^^^^

File "/home/computeruse/.pyenv/versions/3.11.6/lib/python3.11/site-packages/httpcore/_sync/connection.py", line 154, in _connect
stream = stream.start_tls(**kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/home/computeruse/.pyenv/versions/3.11.6/lib/python3.11/site-packages/httpcore/_backends/sync.py", line 152, in start_tls
with map_exceptions(exc_map):

File "/home/computeruse/.pyenv/versions/3.11.6/lib/python3.11/contextlib.py", line 155, in exit
self.gen.throw(typ, value, traceback)

File "/home/computeruse/.pyenv/versions/3.11.6/lib/python3.11/site-packages/httpcore/_exceptions.py", line 14, in map_exceptions
raise to_exc(exc) from exc

httpcore.ConnectError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1006)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):

File "/home/computeruse/.pyenv/versions/3.11.6/lib/python3.11/site-packages/anthropic/_base_client.py", line 990, in _request
response = self._client.send(
^^^^^^^^^^^^^^^^^^

File "/home/computeruse/.pyenv/versions/3.11.6/lib/python3.11/site-packages/httpx/_client.py", line 926, in send
response = self._send_handling_auth(
^^^^^^^^^^^^^^^^^^^^^^^^^

File "/home/computeruse/.pyenv/versions/3.11.6/lib/python3.11/site-packages/httpx/_client.py", line 954, in _send_handling_auth
response = self._send_handling_redirects(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/home/computeruse/.pyenv/versions/3.11.6/lib/python3.11/site-packages/httpx/_client.py", line 991, in _send_handling_redirects
response = self._send_single_request(request)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/home/computeruse/.pyenv/versions/3.11.6/lib/python3.11/site-packages/httpx/_client.py", line 1027, in _send_single_request
response = transport.handle_request(request)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/home/computeruse/.pyenv/versions/3.11.6/lib/python3.11/site-packages/httpx/_transports/default.py", line 235, in handle_request
with map_httpcore_exceptions():

File "/home/computeruse/.pyenv/versions/3.11.6/lib/python3.11/contextlib.py", line 155, in exit
self.gen.throw(typ, value, traceback)

File "/home/computeruse/.pyenv/versions/3.11.6/lib/python3.11/site-packages/httpx/_transports/default.py", line 89, in map_httpcore_exceptions
raise mapped_exc(message) from exc

httpx.ConnectError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1006)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):

File "/home/computeruse/computer_use_demo/loop.py", line 132, in sampling_loop
raw_response = client.beta.messages.with_raw_response.create(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/home/computeruse/.pyenv/versions/3.11.6/lib/python3.11/site-packages/anthropic/_legacy_response.py", line 377, in wrapped
return cast(LegacyAPIResponse[R], func(*args, **kwargs))
^^^^^^^^^^^^^^^^^^^^^

File "/home/computeruse/.pyenv/versions/3.11.6/lib/python3.11/site-packages/anthropic/_utils/_utils.py", line 274, in wrapper
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^

File "/home/computeruse/.pyenv/versions/3.11.6/lib/python3.11/site-packages/anthropic/resources/beta/messages/messages.py", line 896, in create
return self._post(
^^^^^^^^^^^

File "/home/computeruse/.pyenv/versions/3.11.6/lib/python3.11/site-packages/anthropic/_base_client.py", line 1277, in post
return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/home/computeruse/.pyenv/versions/3.11.6/lib/python3.11/site-packages/anthropic/_base_client.py", line 954, in request
return self._request(
^^^^^^^^^^^^^^

File "/home/computeruse/.pyenv/versions/3.11.6/lib/python3.11/site-packages/anthropic/_base_client.py", line 1014, in _request
return self._retry_request(
^^^^^^^^^^^^^^^^^^^^

File "/home/computeruse/.pyenv/versions/3.11.6/lib/python3.11/site-packages/anthropic/_base_client.py", line 1092, in _retry_request
return self._request(
^^^^^^^^^^^^^^

File "/home/computeruse/.pyenv/versions/3.11.6/lib/python3.11/site-packages/anthropic/_base_client.py", line 1014, in _request
return self._retry_request(
^^^^^^^^^^^^^^^^^^^^

File "/home/computeruse/.pyenv/versions/3.11.6/lib/python3.11/site-packages/anthropic/_base_client.py", line 1092, in _retry_request
return self._request(
^^^^^^^^^^^^^^

File "/home/computeruse/.pyenv/versions/3.11.6/lib/python3.11/site-packages/anthropic/_base_client.py", line 1024, in _request
raise APIConnectionError(request=request) from err

anthropic.APIConnectionError: Connection error.

@TechieHank
Copy link
Author

Are you using an intranet? I may have the same problem as you, but I also had a Connection Error and the problem was with the certificate. So I updated the certificate and it was fixed.

Thanks for the feedback @moo1o - What command did you use to update it? I assume you did the update inside the container Debian VM?

@moo1o
Copy link

moo1o commented Oct 25, 2024

@TechieHank
I succeeded by following the steps below.

  1. Access api.anthropic.com, check the valid certificate information, and extract it.
  2. Check the certificate location on your PC with pip show certifi.
  3. In the certificate location, paste the certificate information extracted in step 1 at the end of the cacerti.pem file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants