ConnectTimeoutError

809 views
Skip to first unread message

Nick

unread,
Jul 14, 2022, 2:16:33 PM7/14/22
to Firebase Google Group
I had been connecting fine for months, but all of sudden I have been frequently, but intermittently getting the below timeout error.

1. Does anyone know why it's happening?
2. It seems to block every thread on my server. Thoughts as to a solution?
3. How can I reduce the timeout?

Thanks

WARNING:urllib3.connectionpool:Retrying (Retry(total=9, connect=0, read=1, redirect=None, status=4)) after connection broken by 'ConnectTimeoutError(<urllib3.connection.HTTPSConnection object at 0x400ecf3b20>, 'Connection to medaica-99345-default-rtdb.firebaseio.com timed out. (connect timeout=120)')': /liveExams.json
| ERROR:root:Timed out while making an API call: HTTPSConnectionPool(host='medaica-99345-default-rtdb.firebaseio.com', port=443): Max retries exceeded with url: /liveExams.json (Caused by ConnectTimeoutError(<urllib3.connection.HTTPSConnection object at 0x40176a4df0>, 'Connection to medaica-99345-default-rtdb.firebaseio.com timed out. (connect timeout=120)'))
| Traceback (most recent call last):
|   File "/usr/local/lib/python3.8/site-packages/starlette/middleware/base.py", line 41, in call_next
|     message = await recv_stream.receive()
|   File "/usr/local/lib/python3.8/site-packages/anyio/streams/memory.py", line 94, in receive
|     return self.receive_nowait()
|   File "/usr/local/lib/python3.8/site-packages/anyio/streams/memory.py", line 87, in receive_nowait
|     raise EndOfStream
| anyio.EndOfStream
|
| During handling of the above exception, another exception occurred:
|
| Traceback (most recent call last):
|   File "/opt/project/app/errors.py", line 43, in catch_exceptions_middleware
|     return await call_next(request)
|   File "/usr/local/lib/python3.8/site-packages/starlette/middleware/base.py", line 44, in call_next
|     raise app_exc
|   File "/usr/local/lib/python3.8/site-packages/starlette/middleware/base.py", line 34, in coro
|     await self.app(scope, request.receive, send_stream.send)
|   File "/usr/local/lib/python3.8/site-packages/starlette/exceptions.py", line 90, in __call__
|     raise exc
|   File "/usr/local/lib/python3.8/site-packages/starlette/exceptions.py", line 79, in __call__
|     await self.app(scope, receive, sender)
|   File "/usr/local/lib/python3.8/site-packages/fastapi/middleware/asyncexitstack.py", line 21, in __call__
|     raise e
|   File "/usr/local/lib/python3.8/site-packages/fastapi/middleware/asyncexitstack.py", line 18, in __call__
|     await self.app(scope, receive, send)
|   File "/usr/local/lib/python3.8/site-packages/starlette/routing.py", line 666, in __call__
|     await route.handle(scope, receive, send)
|   File "/usr/local/lib/python3.8/site-packages/starlette/routing.py", line 266, in handle
|     await self.app(scope, receive, send)
|   File "/usr/local/lib/python3.8/site-packages/starlette/routing.py", line 65, in app
|     response = await func(request)
|   File "/usr/local/lib/python3.8/site-packages/fastapi/routing.py", line 227, in app
|     raw_response = await run_endpoint_function(
|   File "/usr/local/lib/python3.8/site-packages/fastapi/routing.py", line 160, in run_endpoint_function
|     return await dependant.call(**values)
|   File "/opt/project/app/live_exam/routes.py", line 56, in create_live_exam
|     return firebase_service.create_live_exam(live_exam_data)
|   File "/opt/project/app/live_exam/firebase_service.py", line 83, in create_live_exam
|     live_exams_ref = firebaseDb.reference("/liveExams").push(new_live_exam_data)
|   File "/usr/local/lib/python3.8/site-packages/firebase_admin/db.py", line 323, in push
|     output = self._client.body('post', self._add_suffix(), json=value)
|   File "/usr/local/lib/python3.8/site-packages/firebase_admin/_http_client.py", line 131, in body
|     resp = self.request(method, url, **kwargs)
|   File "/usr/local/lib/python3.8/site-packages/firebase_admin/db.py", line 931, in request
|     raise _Client.handle_rtdb_error(error)
| firebase_admin.exceptions.DeadlineExceededError: Timed out while making an API call: HTTPSConnectionPool(host='medaica-99345-default-rtdb.firebaseio.com', port=443): Max retries exceeded with url: /liveExams.json (Caused by ConnectTimeoutError(<urllib3.connection.HTTPSConnection object at 0x40176a4df0>, 'Connection to medaica-99345-default-rtdb.firebaseio.com timed out. (connect timeout=120)'))

Bristlepath S

unread,
Jul 14, 2022, 11:52:45 PM7/14/22
to Firebase Google Group
I think there is something going on with Google cloud servers.  It has taken a lot longer to do anything with cloud or firestore.  In some cases, 30 minutes longer. I'm on Android so don't have the connection failure but some of my saves to the firestore have not been successful plus other things. And when I deploy my cloud functions it can take up to 10 or 15 minutes instead of the more normal 2-5 minutes.

For timeout conditions, I usually increase my wait time for all 3 of them: connects, reads, and writes. You may even have to change your code to retry in X minutes or hours if you get a failure.
Reply all
Reply to author
Forward
0 new messages