cern-sis / issues-scoap3

0 stars 0 forks source link

Opensearch connection error #170

Open ErnestaP opened 1 year ago

ErnestaP commented 1 year ago

The following code snippet gives an error on GitHub actions:

   def test_get_article(self, user, api_client):
        user_token =  Token.objects.create(user=user)
        response = api_client.get(
            "/search/article", content_type="application/json", follow=True
        )
        assert response.status_code == status.HTTP_200_OK

Error:

self = <http.client.HTTPResponse object at 0x7f703124df90>

    def _read_status(self):
        line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
        if len(line) > _MAXLINE:
            raise LineTooLong("status line")
        if self.debuglevel > 0:
            print("reply:", repr(line))
        if not line:
            # Presumably, the server closed the connection before
            # sending a valid response.
>           raise RemoteDisconnected("Remote end closed connection without"
                                     " response")
E           http.client.RemoteDisconnected: Remote end closed connection without response

/usr/local/lib/python3.11/http/client.py:287: RemoteDisconnected

During handling of the above exception, another exception occurred:

self = <Urllib3HttpConnection: http://127.0.0.1:9200/>, method = 'POST'
url = '/scoap3-backend-local-articles/_count', params = {}
body = b'{"query":{"match_all":{}}}', timeout = None, ignore = (), headers = {}

    def perform_request(
        self, method, url, params=None, body=None, timeout=None, ignore=(), headers=None
    ):
        url = self.url_prefix + url
        if params:
            url = "%s?%s" % (url, urlencode(params))

        full_url = self.host + url
        start = time.time()
        orig_body = body
        try:
            kw = {}
            if timeout:
                kw["timeout"] = timeout

            # in python2 we need to make sure the url and method are not
            # unicode. Otherwise the body will be decoded into unicode too and
            # that will fail (#133, #201).
            if not isinstance(url, str):
                url = url.encode("utf-8")
            if not isinstance(method, str):
                method = method.encode("utf-8")

            request_headers = self.headers.copy()
            request_headers.update(headers or ())

            if self.http_compress and body:
                body = self._gzip_compress(body)
                request_headers["content-encoding"] = "gzip"

>           response = self.pool.urlopen(
                method, url, body, retries=Retry(False), headers=request_headers, **kw
            )

/usr/local/lib/python3.11/site-packages/opensearchpy/connection/http_urllib3.py:240: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _