Timeout issue with InfluxDB Cloud

I’m using the influxdb cloud python client to ingest IoT data via a Google Cloud function, and encountering some timeout issues. The Traceback is below, but it appears the requests to my cloud function endpoint are timing out past the default timeout duration of 10.0 seconds. Is there anyway to adjust the timeout period while using the Influxdb cloud service? I’m using this server: us-central1-1.gcp.cloud2.influxdata.com

Or will I need to run a private instance on a separate server to adjust the timeout duration? I set the cloud function timeout to 540 seconds, so that isn’t the limiting factor.

Traceback (most recent call last):
File “/layers/google.python.pip/pip/lib/python3.10/site-packages/flask/app.py”, line 2077, in wsgi_app
response = self.full_dispatch_request()
File “/layers/google.python.pip/pip/lib/python3.10/site-packages/flask/app.py”, line 1525, in full_dispatch_request
rv = self.handle_user_exception(e)
File “/layers/google.python.pip/pip/lib/python3.10/site-packages/flask/app.py”, line 1523, in full_dispatch_request
rv = self.dispatch_request()
File “/layers/google.python.pip/pip/lib/python3.10/site-packages/flask/app.py”, line 1509, in dispatch_request
return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)
File “/layers/google.python.pip/pip/lib/python3.10/site-packages/functions_framework/init.py”, line 99, in view_func
return function(request._get_current_object())
File “/workspace/main.py”, line 349, in main
write_api.write(bucket,org,influx_records,WritePrecision.S)
File “/layers/google.python.pip/pip/lib/python3.10/site-packages/influxdb_client/client/write_api.py”, line 371, in write
results = list(map(write_payload, payloads.items()))
File “/layers/google.python.pip/pip/lib/python3.10/site-packages/influxdb_client/client/write_api.py”, line 369, in write_payload
return self._post_write(_async_req, bucket, org, final_string, payload[0])
File “/layers/google.python.pip/pip/lib/python3.10/site-packages/influxdb_client/client/write_api.py”, line 517, in _post_write
return self._write_service.post_write(org=org, bucket=bucket, body=body, precision=precision,
File “/layers/google.python.pip/pip/lib/python3.10/site-packages/influxdb_client/service/write_service.py”, line 63, in post_write
(data) = self.post_write_with_http_info(org, bucket, body, **kwargs) # noqa: E501
File “/layers/google.python.pip/pip/lib/python3.10/site-packages/influxdb_client/service/write_service.py”, line 168, in post_write_with_http_info
return self.api_client.call_api(
File “/layers/google.python.pip/pip/lib/python3.10/site-packages/influxdb_client/api_client.py”, line 341, in call_api
return self.__call_api(resource_path, method,
File “/layers/google.python.pip/pip/lib/python3.10/site-packages/influxdb_client/api_client.py”, line 171, in __call_api
response_data = self.request(
File “/layers/google.python.pip/pip/lib/python3.10/site-packages/influxdb_client/api_client.py”, line 386, in request
return self.rest_client.POST(url,
File “/layers/google.python.pip/pip/lib/python3.10/site-packages/influxdb_client/rest.py”, line 304, in POST
return self.request(“POST”, url,
File “/layers/google.python.pip/pip/lib/python3.10/site-packages/influxdb_client/rest.py”, line 217, in request
r = self.pool_manager.request(
File “/layers/google.python.pip/pip/lib/python3.10/site-packages/urllib3/_request_methods.py”, line 118, in request
return self.request_encode_body(
File “/layers/google.python.pip/pip/lib/python3.10/site-packages/urllib3/_request_methods.py”, line 217, in request_encode_body
return self.urlopen(method, url, **extra_kw)
File “/layers/google.python.pip/pip/lib/python3.10/site-packages/urllib3/poolmanager.py”, line 443, in urlopen
response = conn.urlopen(method, u.request_uri, **kw)
File “/layers/google.python.pip/pip/lib/python3.10/site-packages/urllib3/connectionpool.py”, line 844, in urlopen
retries = retries.increment(
File “/layers/google.python.pip/pip/lib/python3.10/site-packages/urllib3/util/retry.py”, line 445, in increment
raise reraise(type(error), error, _stacktrace)
File “/layers/google.python.pip/pip/lib/python3.10/site-packages/urllib3/util/util.py”, line 39, in reraise
raise value
File “/layers/google.python.pip/pip/lib/python3.10/site-packages/urllib3/connectionpool.py”, line 790, in urlopen
response = self._make_request(
File “/layers/google.python.pip/pip/lib/python3.10/site-packages/urllib3/connectionpool.py”, line 491, in _make_request
raise new_e
File “/layers/google.python.pip/pip/lib/python3.10/site-packages/urllib3/connectionpool.py”, line 467, in _make_request
self._validate_conn(conn)
File “/layers/google.python.pip/pip/lib/python3.10/site-packages/urllib3/connectionpool.py”, line 1092, in _validate_conn
conn.connect()
File “/layers/google.python.pip/pip/lib/python3.10/site-packages/urllib3/connection.py”, line 604, in connect
self.sock = sock = self._new_conn()
File “/layers/google.python.pip/pip/lib/python3.10/site-packages/urllib3/connection.py”, line 209, in _new_conn
raise ConnectTimeoutError(
urllib3.exceptions.ConnectTimeoutError: (<urllib3.connection.HTTPSConnection object at 0x3e2afe917580>, ‘Connection to us-central1-1.gcp.cloud2.influxdata.com timed out. (connect timeout=10.0)’)

Hello @Mason_Lanphear,
What version of the influxdb python client library did you use? Can you share the link to the client that you used?
That sounds to me like the instantiation of your client is wrong. I also get that error when that’s the case or my credentials are wrong.
Do you mind sharing your script?
Thank you

Hi @Anaisdg,

I set the timeout duration in my client instantiation to 30 seconds and haven’t seen the error in 5 days. I will let you know if the issue persists, but it seems to have fixed the issue.

url="https://us-central1-1.gcp.cloud2.influxdata.com"
client = influxdb_client.InfluxDBClient(url=url,token=token,org=org,timeout=30_000)
write_api = client.write_api(write_options=SYNCHRONOUS)

Thanks!

Hi @Anaisdg,

I noticed this error occurred again today. Are there any potential risks associated with incrementing the timeout duration by 10 seconds? Increasing from 10 to 30 seconds did reduce the frequency of timeout errors.

Thanks,