crewAI icon indicating copy to clipboard operation
crewAI copied to clipboard

Connection Timeout Error with telemetry.crewai.com

Open leeeex opened this issue 1 year ago • 18 comments

Hello , I hope this message finds you well. I am reaching out to report an issue that I encountered while using your project. Description: I encountered a ConnectTimeout error when attempting to connect to telemetry.crewai.com on port 4318. The error message is as follows:

requests.exceptions.ConnectTimeout: HTTPConnectionPool(host='telemetry.crewai.com', port=4318): Max retries exceeded with url: /v1/traces (Caused by ConnectTimeoutError(<urllib3.connection.HTTPConnection object at 0x7f34caf38280>, 'Connection to telemetry.crewai.com timed out. (connect timeout=10)')

leeeex avatar Feb 18 '24 03:02 leeeex

Follow, same error:

raise MaxRetryError(_pool, url, reason) from reason # type: ignore[arg-type].

WARN urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='telemetry.crewai.com', port=4318): Max retries exceeded with url: /v1/traces (Caused by ConnectTimeoutError(<urllib3.connection.HTTPConnection object at 0x1378487c0>, 'Connection to telemetry.crewai.com timed out. (connect timeout=10)')).

Mirgiacomo avatar Feb 20 '24 09:02 Mirgiacomo

Related, but I am not able to run CrewAI due to the fact that it hits telemetry.crewai.com which I can't access through my company's proxy. It would be nice if the user could choose to optionally disable telemetry.

ansunsujoe avatar Feb 21 '24 14:02 ansunsujoe

Please fix this. I'm in the same situation as telemetry.crewai.com is blocked for my company as well.

lm150 avatar Feb 23 '24 00:02 lm150

I cant even hit it in my local environment with telnet.

% telnet telemetry.crewai.com 4318
Trying 10.0.0.1...
telnet: connect to address 10.0.0.1: Connection refused
Trying fd6e:6c73:b178:1::1...
telnet: connect to address fd6e:6c73:b178:1::1: Connection refused
telnet: Unable to connect to remote host

I also get this about a hundred times during runtime:

requests.exceptions.ConnectTimeout: HTTPConnectionPool(host='telemetry.crewai.com', port=4318): Max retries exceeded with url: /v1/traces (Caused by ConnectTimeoutError(<urllib3.connection.HTTPConnection object at 0x7f34caf38280>, 'Connection to telemetry.crewai.com timed out. (connect timeout=10)')

slaughters85j avatar Feb 27 '24 21:02 slaughters85j

I agree to the previous speaker. Their must be a setting to turn those requests off. You can leave them on by default but allow disabling them for good. In best case it'd be a env var so that we do not need to do it over and over again.

chrissonntag avatar Feb 27 '24 21:02 chrissonntag

I want to add to this.

eleqtrizit avatar Feb 28 '24 17:02 eleqtrizit

it's not pretty, but a tiny bit of monkey patching might get ya there. Mind the typo on crewai.telemtry at the moment (have a PR to fix that one: https://github.com/joaomdmoura/crewAI/pull/295 ).

from crewai.telemtry import Telemetry

def noop(*args, **kwargs):
    # with open("./logfile.txt", "a") as f:
    #     f.write("Telemetry method called and noop'd\n")
    pass


for attr in dir(Telemetry):
    if callable(getattr(Telemetry, attr)) and not attr.startswith("__"):
        setattr(Telemetry, attr, noop)

heyfixit avatar Mar 01 '24 11:03 heyfixit

Bump, still is happening on my side, has a fix been pushed to pip ?

psikosen avatar Mar 12 '24 18:03 psikosen

I am also facing the same issue even after this.

vipulnath avatar Mar 13 '24 05:03 vipulnath

Issue #241 has been closed without any comments. We can assume at this point that there is no interest what so ever to implement a flag to turn of the telemetry calls.

chrissonntag avatar Mar 19 '24 07:03 chrissonntag

Yup np, I notice the issue doesn't happen while using Ollama, only while using lmstudio. So it's fine to close.

psikosen avatar Mar 19 '24 18:03 psikosen

It's not fine to close. It happens when the telemetry url is being blocked by a firewall. What you're using has nothing to do with the whether it is OK or not.

It does look like there is a new flag, 'telemetry' for the crew to disable.

eleqtrizit avatar Mar 19 '24 18:03 eleqtrizit

Hey i have a fix for this you can just disable the telemetry calls on the tool usage class and in the crew class

Like below C:/User/.../your-env/site-packages/crewai/crew.py C:/User/.../your-env/site-packages/crewai/tools/tool_usage.py

You can comment all the telemetry related stuff and should work fine again

pudimKBM avatar Mar 26 '24 14:03 pudimKBM

bumped, this is an issue still and needs to be resolved. Add an opt out completely option.

mabry1985 avatar Mar 30 '24 19:03 mabry1985

I just published a pypi package from my opt-out branch: https://pypi.org/project/crewai-clean/

You need to set CREWAI_TELEMETRY_OPT_OUT=True in your environment.

Please test it out and leave a comment on https://github.com/joaomdmoura/crewAI/pull/402

gardner avatar Mar 30 '24 22:03 gardner

I just hit the same problem. I disabled telemetry with one line change to the file "<python_lib_dir>/site-packages/crewai/telemetry/telemetry.py" shown as diff below:

- self.ready = True
+ self.ready = False

Indeed, crewai should probably provide an option to allow clients to opt out of telemetry. In my case, the company's security policy wouldn't allow this without legal process and approval.

alexjst avatar May 14 '24 06:05 alexjst

I faced the same issue as above. Please help me in resolving this:

requests.exceptions.ConnectTimeout: HTTPConnectionPool(host='telemetry.crewai.com', port=4318): Max retries exceeded with url: /v1/traces (Caused by ConnectTimeoutError(<urllib3.connection.HTTPConnection object at 0x000002311B65F310>, 'Connection to telemetry.crewai.com timed out. (connect timeout=10)'))

Yamijalaa avatar May 16 '24 09:05 Yamijalaa

@Yamijalaa

Set the env var OTEL_SDK_DISABLED=true

import os
from crewai import Agent, Task, Crew, Process
from crewai_tools import SerperDevTool

os.environ["OTEL_SDK_DISABLED"] = "true"

gardner avatar May 16 '24 11:05 gardner

@gardner , I did this as well, just slightly differently:

OTEL_SDK_DISABLED = "true"

I get the following message over and over, but the failures were making the output completely unreadable.

2024-05-22 21:49:28,225 - 8099684480 - __init__.py-__init__:1198 - WARNING: SDK is disabled.

johnisanerd avatar May 23 '24 01:05 johnisanerd

@johnisanerd that warning looks like it come from the Open Telemetry Python SDK here.

If you add this to your /etc/hosts file:

127.0.0.1	telemetry.crewai.com

You will not see connection errors.

To test if OTEL_SDK_DISABLED has an effect:

If you then run without OTEL_SDK_DISABLED being set, you will see the connection errors. This indicates the underlying OpenTelemetry SDK is succesfully disabled when setting OTEL_SDK_DISABLED = "true"

gardner avatar May 25 '24 19:05 gardner

I solved the issue by faking the response from the telemetry url:

.../lib/python3.11/site-packages/opentelemetry/exporter/otlp/proto/http/trace_exporter/init.py

from requests.models import Response
    ...

    def _export(self, serialized_data: bytes):
        data = serialized_data
        if self._compression == Compression.Gzip:
            gzip_data = BytesIO()
            with gzip.GzipFile(fileobj=gzip_data, mode="w") as gzip_stream:
                gzip_stream.write(serialized_data)
            data = gzip_data.getvalue()
        elif self._compression == Compression.Deflate:
            data = zlib.compress(serialized_data)

        # return self._session.post(
        #     url=self._endpoint,
        #     data=data,
        #     verify=self._certificate_file,
        #     timeout=self._timeout,
        # )
        # Create a fake response object
        fake_response = Response()
        fake_response.status_code = 200  # Set status code to 200 OK
        fake_response._content = b'{"status": "ok"}'  # Optional: fake response content

        return fake_response  

For now it works like a charm

AJNOURI avatar Jun 19 '24 12:06 AJNOURI

I am still facing this issue but with my personal project. r = adapter.send(request, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\ ... \crewai_env\Lib\site-packages\requests\adapters.py", line 688, in send raise ConnectTimeout(e, request=request) requests.exceptions.ConnectTimeout: HTTPSConnectionPool(host='telemetry.crewai.com', port=4319): Max retries exceeded with url: /v1/traces (Caused by ConnectTimeoutError(<urllib3.connection.HTTPSConnection object at 0x000001C2A5AD4170>, 'Connection to telemetry.crewai.com timed out. (connect timeout=30)'))

but when i try to clone this repo: https://github.com/rajib76/multi_agent/blob/main/08_how_to_do_memory_in_crew_01.py and used it but never faced any timeout. They are using same conda environment, and not faced the timeout no matter how many tokens I use

beeapu avatar Jun 26 '24 11:06 beeapu

Telemetry went down recently because the crewai.com server itself was experiencing issues, and made it incredibly difficult to develop: https://github.com/crewAIInc/crewAI/issues/1164

slimshreydy avatar Aug 13 '24 22:08 slimshreydy