question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Read timed out. (read timeout=None)

See original GitHub issue

python-arango: 6.1.0 ArangoDB: 3.7.6 Community Edition

When I Execute the next query:

db = ArangoConnection.db()
periodo_cursor = db.aql.execute('''
            FOR t in Periodo
                RETURN t
            ''')

Sometimes I have the next error:

Traceback (most recent call last): File “/Users/isaacfi/Code/eneounam.sip/backend/venv/lib/python3.7/site-packages/flask/app.py”, line 1832, in full_dispatch_request rv = self.dispatch_request() File “/Users/isaacfi/Code/eneounam.sip/backend/venv/lib/python3.7/site-packages/flask/app.py”, line 1818, in dispatch_request return self.view_functionsrule.endpoint File “/Users/isaacfi/Code/eneounam.sip/backend/venv/lib/python3.7/site-packages/flasgger/utils.py”, line 255, in wrapper return function(*args, **kwargs) File “/Users/isaacfi/Code/eneounam.sip/backend/controllers/catalogs_controller.py”, line 115, in get_periodos lastUpdateDate) File “/Users/isaacfi/Code/eneounam.sip/backend/business/catalogs/periodo_business.py”, line 41, in get_periodos ‘’', bind_vars=bind_vars) File “/Users/isaacfi/Code/eneounam.sip/backend/venv/lib/python3.7/site-packages/arango/aql.py”, line 293, in execute return self._execute(request, response_handler) File “/Users/isaacfi/Code/eneounam.sip/backend/venv/lib/python3.7/site-packages/arango/api.py”, line 66, in _execute return self._executor.execute(request, response_handler) File “/Users/isaacfi/Code/eneounam.sip/backend/venv/lib/python3.7/site-packages/arango/executor.py”, line 81, in execute resp = self._conn.send_request(request) File “/Users/isaacfi/Code/eneounam.sip/backend/venv/lib/python3.7/site-packages/arango/connection.py”, line 250, in send_request auth=self._auth File “/Users/isaacfi/Code/eneounam.sip/backend/venv/lib/python3.7/site-packages/arango/http.py”, line 109, in send_request auth=auth File “/Users/isaacfi/Code/eneounam.sip/backend/venv/lib/python3.7/site-packages/requests/sessions.py”, line 533, in request resp = self.send(prep, **send_kwargs) File “/Users/isaacfi/Code/eneounam.sip/backend/venv/lib/python3.7/site-packages/requests/sessions.py”, line 646, in send r = adapter.send(request, **kwargs) File “/Users/isaacfi/Code/eneounam.sip/backend/venv/lib/python3.7/site-packages/requests/adapters.py”, line 529, in send raise ReadTimeout(e, request=request) requests.exceptions.ReadTimeout: HTTPConnectionPool(host=‘132.247.114.25’, port=8529): Read timed out. (read timeout=None)

This usually happends when the server is useless for a while (2 mins approx).

This is how I create the arango client:

from arango import ArangoClient
from arango.database import StandardDatabase
from settings import ARANGO_DB, ARANGO_HOSTS, ARANGO_PASSWORD, ARANGO_USER


class ArangoConnection:

    _db: StandardDatabase = None

    @staticmethod
    def db() -> StandardDatabase:
        """Connection to SIP

        :return: Arango database connection to SIP
        :rtype: StandardDatabase
        """
        if ArangoConnection._db is None:
            arango_client = ArangoClient(hosts=ARANGO_HOSTS)
            ArangoConnection._db = arango_client.db(
                ARANGO_DB, ARANGO_USER, ARANGO_PASSWORD)
        return ArangoConnection._db

BR.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
isaacficommented, Feb 5, 2021

I was able to solve the issue setting up the session and requests as follow:

import logging
from typing import Text, Union

from arango.http import HTTPClient
from arango.response import Response
from requests import Session
from requests.adapters import HTTPAdapter
from settings import (ARANGO_CONNECT_TIMEOUT, ARANGO_HOSTS, ARANGO_MAX_TRIES,
                      ARANGO_READ_TIMEOUT)


class ArangoHttpClient(HTTPClient):

    def create_session(self, host):
        session = Session()

        adapter = HTTPAdapter(max_retries=int(ARANGO_MAX_TRIES))
        if ARANGO_HOSTS.startswith('http://'):
            session.mount('http://', adapter)
        if ARANGO_HOSTS.startswith('https://'):
            session.mount('https://', adapter)
        return session

    def send_request(self,
                     session: Session,
                     method: str,
                     url: Union[str, bytes, Text],
                     params=None,
                     data=None,
                     headers=None,
                     auth=None):
        response = session.request(
            method=method,
            url=url,
            params=params,
            data=data,
            headers=headers,
            auth=auth,
            timeout=(float(ARANGO_CONNECT_TIMEOUT), float(ARANGO_READ_TIMEOUT))
        )

        return Response(
            method=response.request.method,
            url=response.url,
            headers=response.headers,
            status_code=response.status_code,
            status_text=response.reason,
            raw_body=response.text,
        )

Where the setting values are:

ARANGO_HOSTS=http://localhost… ARANGO_CONNECT_TIMEOUT=30 ARANGO_READ_TIMEOUT=60 ARANGO_MAX_TRIES=5

BR.

0reactions
isaacficommented, Feb 5, 2021

Hi @joowani

The issue still appears only in development mode when I run my flask application. But you gave me an idea to manage the sessions with the custom http client and I may fix the problem.

Thank you

Read more comments on GitHub >

github_iconTop Results From Across the Web

HTTPSConnectionPool(host='', port=443): Read timed out ...
The response from the server takes longer than the specified timeout. So to solve it you need to set a higher timeout. ·...
Read more >
Connection Timeout vs. Read Timeout for Java Sockets
From the client side, the “read timed out” error happens if the server is taking longer to respond and send information. This could...
Read more >
Setting connection and read timeouts — oci 2.90.0 ...
The SDK uses the Requests definition for connection and read timeouts. By default, calls made to services have the following timeouts associated with...
Read more >
Set read timeout - Alpaca Community Forum
where the read timeout is None. I'm curious why my app is still getting timed out? What is Alpaca's internally set timeout, if...
Read more >
Read Timed out - Kite Connect developer forum
Getting Read Timed out error. Message : HTTPSConnectionPool(host='api.kite.trade', port=443): Read timed out. (read timeout=7)
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found