Connection aborted error 104

I'm having this nasty error: Traceback (most recent call last): File "/home/ubuntu/.local/lib/python3.5/site-packages/urllib3/connectionpool.py", line 600, in urlopen chunked=chunked) File "/

I’m having this nasty error:

Traceback (most recent call last):
  File "/home/ubuntu/.local/lib/python3.5/site-packages/urllib3/connectionpool.py", line 600, in urlopen
    chunked=chunked)
  File "/home/ubuntu/.local/lib/python3.5/site-packages/urllib3/connectionpool.py", line 384, in _make_request
    six.raise_from(e, None)
  File "<string>", line 2, in raise_from
  File "/home/ubuntu/.local/lib/python3.5/site-packages/urllib3/connectionpool.py", line 380, in _make_request
    httplib_response = conn.getresponse()
  File "/usr/lib/python3.5/http/client.py", line 1197, in getresponse
    response.begin()
  File "/usr/lib/python3.5/http/client.py", line 297, in begin
    version, status, reason = self._read_status()
  File "/usr/lib/python3.5/http/client.py", line 258, in _read_status
    line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
  File "/usr/lib/python3.5/socket.py", line 575, in readinto
    return self._sock.recv_into(b)
ConnectionResetError: [Errno 104] Connection reset by peer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/ubuntu/.local/lib/python3.5/site-packages/requests/adapters.py", line 445, in send
    timeout=timeout
  File "/home/ubuntu/.local/lib/python3.5/site-packages/urllib3/connectionpool.py", line 638, in urlopen
    _stacktrace=sys.exc_info()[2])
  File "/home/ubuntu/.local/lib/python3.5/site-packages/urllib3/util/retry.py", line 367, in increment
    raise six.reraise(type(error), error, _stacktrace)
  File "/home/ubuntu/.local/lib/python3.5/site-packages/urllib3/packages/six.py", line 685, in reraise
    raise value.with_traceback(tb)
  File "/home/ubuntu/.local/lib/python3.5/site-packages/urllib3/connectionpool.py", line 600, in urlopen
    chunked=chunked)
  File "/home/ubuntu/.local/lib/python3.5/site-packages/urllib3/connectionpool.py", line 384, in _make_request
    six.raise_from(e, None)
  File "<string>", line 2, in raise_from
  File "/home/ubuntu/.local/lib/python3.5/site-packages/urllib3/connectionpool.py", line 380, in _make_request
    httplib_response = conn.getresponse()
  File "/usr/lib/python3.5/http/client.py", line 1197, in getresponse
    response.begin()
  File "/usr/lib/python3.5/http/client.py", line 297, in begin
    version, status, reason = self._read_status()
  File "/usr/lib/python3.5/http/client.py", line 258, in _read_status
    line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
  File "/usr/lib/python3.5/socket.py", line 575, in readinto
    return self._sock.recv_into(b)
urllib3.exceptions.ProtocolError: ('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/ubuntu/script.py", line 44, in <module>
    response_service_k = service_k_lib.service_kData(data, access_token, apifolder)
  File "/home/ubuntu/script_lib.py", line 238, in service_kData
    datarALL.extend(data.result())
  File "/usr/lib/python3.5/concurrent/futures/_base.py", line 398, in result
    return self.__get_result()
  File "/usr/lib/python3.5/concurrent/futures/_base.py", line 357, in __get_result
    raise self._exception
  File "/usr/lib/python3.5/concurrent/futures/thread.py", line 55, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/ubuntu/script_lib.py", line 129, in getdata3
    responsedata = requests.get(url, data=data, headers=hed, verify=False)
  File "/home/ubuntu/.local/lib/python3.5/site-packages/requests/api.py", line 72, in get
    return request('get', url, params=params, **kwargs)
  File "/home/ubuntu/.local/lib/python3.5/site-packages/requests/api.py", line 58, in request
    return session.request(method=method, url=url, **kwargs)
  File "/home/ubuntu/.local/lib/python3.5/site-packages/requests/sessions.py", line 512, in request
    resp = self.send(prep, **send_kwargs)
  File "/home/ubuntu/.local/lib/python3.5/site-packages/requests/sessions.py", line 622, in send
    r = adapter.send(request, **kwargs)
  File "/home/ubuntu/.local/lib/python3.5/site-packages/requests/adapters.py", line 495, in send
    raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer'))

According to this answer the solution for my issue is to place :
time.sleep(0.01) strategically in my code. I get the idea of it but I’m not sure I know where the correct spot for it in my code:

This is the relevant code part from script.py :

result= []
with ThreadPoolExecutor(max_workers=num_of_pages) as executor:
    futh = [(executor.submit(self.getdata3, page, hed, data, apifolder,additional)) for page in pages]
    for data in as_completed(futh):
        result.extend(data.result())
print ("Finished generateing data.")
return result

This is the relevant code part from getdata3 function :

        def getdata3(...)
            datarALL = []
            responsedata = requests.get(url, data=data, headers=hed, verify=False)
            if responsedata.status_code == 200:  # 200 for successful call
                responsedata = responsedata.text
                jsondata = json.loads(responsedata)
                if "results" in jsondata:
                    if jsondata["results"]:
                        datarALL.extend(jsondata["results"])
            print ("{1} page {0} finished".format(page,str(datetime.now())))
            return datarALL

Some info:

My code generates pages.

Create thread per page executing getdata3 (which makes GET request to API)

each thread return the result of a single page.

«merging» results.

My question:

Where to put the time.sleep(0.01) in order to avoid this error?

I’ve noticed a pattern of receiving requests.exceptions.ConnectionError: ('Connection aborted.', OSError("(104, 'ECONNRESET')",)) when just beyond 5 minutes since request initiated and I’ve verified that the server I’m talking to (IIS 8.5) has server side connection timeout set to 5 minutes. I have not been able to convince admin of this server to increase the IIS server’s connection timeout from 5 to 10 or 15 minutes despite one of their REST APIs can return quite a large payload back which sometimes goes beyond the timeout threshold and when it does, I get this error. Here is full stack trace. Any ideas how I can resolve this in my case? Let me know if this seems different enough from this issue’s thread and I’ll open another issue:

Traceback (most recent call last):
  File "/home/jdfagan/.miniconda/apollo/lib/python3.6/site-packages/urllib3/connectionpool.py", line 601, in urlopen
    chunked=chunked)
  File "/home/jdfagan/.miniconda/apollo/lib/python3.6/site-packages/urllib3/connectionpool.py", line 387, in _make_request
    six.raise_from(e, None)
  File "<string>", line 2, in raise_from
  File "/home/jdfagan/.miniconda/apollo/lib/python3.6/site-packages/urllib3/connectionpool.py", line 383, in _make_request
    httplib_response = conn.getresponse()
  File "/home/jdfagan/.miniconda/apollo/lib/python3.6/http/client.py", line 1331, in getresponse
    response.begin()
  File "/home/jdfagan/.miniconda/apollo/lib/python3.6/http/client.py", line 297, in begin
    version, status, reason = self._read_status()
  File "/home/jdfagan/.miniconda/apollo/lib/python3.6/http/client.py", line 258, in _read_status
    line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
  File "/home/jdfagan/.miniconda/apollo/lib/python3.6/socket.py", line 586, in readinto
    return self._sock.recv_into(b)
  File "/home/jdfagan/.miniconda/apollo/lib/python3.6/site-packages/urllib3/contrib/pyopenssl.py", line 285, in recv_into
    raise SocketError(str(e))
OSError: (104, 'ECONNRESET')

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/jdfagan/.miniconda/apollo/lib/python3.6/site-packages/requests/adapters.py", line 440, in send
    timeout=timeout
  File "/home/jdfagan/.miniconda/apollo/lib/python3.6/site-packages/urllib3/connectionpool.py", line 639, in urlopen
    _stacktrace=sys.exc_info()[2])
  File "/home/jdfagan/.miniconda/apollo/lib/python3.6/site-packages/urllib3/util/retry.py", line 357, in increment
    raise six.reraise(type(error), error, _stacktrace)
  File "/home/jdfagan/.miniconda/apollo/lib/python3.6/site-packages/urllib3/packages/six.py", line 685, in reraise
    raise value.with_traceback(tb)
  File "/home/jdfagan/.miniconda/apollo/lib/python3.6/site-packages/urllib3/connectionpool.py", line 601, in urlopen
    chunked=chunked)
  File "/home/jdfagan/.miniconda/apollo/lib/python3.6/site-packages/urllib3/connectionpool.py", line 387, in _make_request
    six.raise_from(e, None)
  File "<string>", line 2, in raise_from
  File "/home/jdfagan/.miniconda/apollo/lib/python3.6/site-packages/urllib3/connectionpool.py", line 383, in _make_request
    httplib_response = conn.getresponse()
  File "/home/jdfagan/.miniconda/apollo/lib/python3.6/http/client.py", line 1331, in getresponse
    response.begin()
  File "/home/jdfagan/.miniconda/apollo/lib/python3.6/http/client.py", line 297, in begin
    version, status, reason = self._read_status()
  File "/home/jdfagan/.miniconda/apollo/lib/python3.6/http/client.py", line 258, in _read_status
    line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
  File "/home/jdfagan/.miniconda/apollo/lib/python3.6/socket.py", line 586, in readinto
    return self._sock.recv_into(b)
  File "/home/jdfagan/.miniconda/apollo/lib/python3.6/site-packages/urllib3/contrib/pyopenssl.py", line 285, in recv_into
    raise SocketError(str(e))
urllib3.exceptions.ProtocolError: ('Connection aborted.', OSError("(104, 'ECONNRESET')",))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "apollo/waypoint/etl/mri/cli.py", line 150, in <module>
    cli()
  File "/home/jdfagan/.miniconda/apollo/lib/python3.6/site-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/home/jdfagan/.miniconda/apollo/lib/python3.6/site-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/home/jdfagan/.miniconda/apollo/lib/python3.6/site-packages/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/jdfagan/.miniconda/apollo/lib/python3.6/site-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/jdfagan/.miniconda/apollo/lib/python3.6/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "apollo/waypoint/etl/mri/cli.py", line 54, in etl
    etl.etl(route_set=route_set, routes=route, routes_params=route_params)
  File "/home/jdfagan/Repositories/Waypoint/apollo/apollo/waypoint/etl/mri/api_etl.py", line 95, in etl
    self.extract(route_set=route_set, routes=routes, routes_params=routes_params)
  File "/home/jdfagan/Repositories/Waypoint/apollo/apollo/waypoint/etl/mri/api_etl.py", line 171, in extract
    responses[extractor.name] = extractor.extract(params=params)
  File "/home/jdfagan/Repositories/Waypoint/apollo/apollo/waypoint/etl/mri/api_extractor.py", line 113, in extract
    responses = self.route.get_all(params=params)
  File "/home/jdfagan/Repositories/Waypoint/apollo/apollo/accounting/__init__.py", line 15, in wrapper
    result = f(self, *arg, **kw)
  File "/home/jdfagan/Repositories/Waypoint/apollo/apollo/accounting/mri/mri_api.py", line 432, in get_all
    response = self.get(params=params, stream=stream)
  File "/home/jdfagan/Repositories/Waypoint/apollo/apollo/accounting/__init__.py", line 15, in wrapper
    result = f(self, *arg, **kw)
  File "/home/jdfagan/Repositories/Waypoint/apollo/apollo/accounting/mri/mri_api.py", line 480, in get
    response = self.session.get(self.url, params=params, headers=self.headers, stream=stream)
  File "/home/jdfagan/.miniconda/apollo/lib/python3.6/site-packages/requests/sessions.py", line 521, in get
    return self.request('GET', url, **kwargs)
  File "/home/jdfagan/.miniconda/apollo/lib/python3.6/site-packages/requests/sessions.py", line 508, in request
    resp = self.send(prep, **send_kwargs)
  File "/home/jdfagan/.miniconda/apollo/lib/python3.6/site-packages/requests/sessions.py", line 618, in send
    r = adapter.send(request, **kwargs)
  File "/home/jdfagan/.miniconda/apollo/lib/python3.6/site-packages/requests/adapters.py", line 490, in send
    raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', OSError("(104, 'ECONNRESET')",))
View previous topic :: View next topic  
Author Message
oga
n00b
n00b

Joined: 31 May 2018
Posts: 3

PostPosted: Thu May 31, 2018 3:23 pm    Post subject: ‘Connection aborted.’, error(104, ‘Connection reset by peer’ Reply with quote

Good afternoon,

I have a LINUX machine with the OpenNao distro (based on GENTOO). This machine has Python 2.7.3. I do not have root permissions.

You can download an executable image in Virtualbox (OpenNAO OS VirtualBox 2.1.2) from the following link (you will probably have to create an account):

https://community.ald.softbankrobotics.com/en/resources/software/language/en-gb?sort_by=weight&sort_order=ASC&page=1

My problem is that I am trying to make a call request to an AZURE server that has TLS 1.2, with the following code:

Code:
    import requests

   url = «www.example.com» # it is not a real url

   querystring = {«key»:»value»,}

   headers = {‘token’: «1234567891234»,’Username’: «user»,’Password’:»password»}

   #response = requests.request(«GET», url, headers=headers, params=querystring)

   response = requests.get(url, headers=headers, params=querystring, timeout=30)

and I get the following error:

Code:
       /var/persistent/home/nao/.local/lib/python2.7/site-packages/urllib3/util/ssl_.py:339: SNIMissingWarning: An HTTPS request has been made, but the SNI (Subject Name Indication) extension to TLS is not available on this platform. This may cause the server to present an incorrect TLS certificate, which can cause validation failures. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings

     SNIMissingWarning

   /var/persistent/home/nao/.local/lib/python2.7/site-packages/urllib3/util/ssl_.py:137: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings

     InsecurePlatformWarning

   Traceback (most recent call last):

     File «heathrowFI-3.py», line 33, in <module>

       response = requests.get(url, headers=headers, params=querystring, timeout=30)

     File «/var/persistent/home/nao/.local/lib/python2.7/site-packages/requests/api.py», line 72, in get

       return request(‘get’, url, params=params, **kwargs)

     File «/var/persistent/home/nao/.local/lib/python2.7/site-packages/requests/api.py», line 58, in request

       return session.request(method=method, url=url, **kwargs)

     File «/var/persistent/home/nao/.local/lib/python2.7/site-packages/requests/sessions.py»,

 line 508, in request

       resp = self.send(prep, **send_kwargs)

     File «/var/persistent/home/nao/.local/lib/python2.7/site-packages/requests/sessions.py»,

 line 618, in send

       r = adapter.send(request, **kwargs)

     File «/var/persistent/home/nao/.local/lib/python2.7/site-packages/requests/adapters.py»,

 line 490, in send

       raise ConnectionError(err, request=request)

   requests.exceptions.ConnectionError: (‘Connection aborted.’, error(104, ‘Connection reset by peer’))

I have tried to make the request on other machines (Windows, Ubuntu) with TLS 1.2 and the result is OK.

To get the TLS version of each machine I used the following command

Code:
    python -c «import json, urllib2; print json.load (urllib2.urlopen (‘https://www.howsmyssl.com/a/check’)) [‘tls_version’]»

WINDOWS machine with python 2.7 and TLS 1.2 : The result of the request was OK.

UBUNTU machine with python 2.7 and TLS 1.2 : The result of the request was OK.

I think the error is caused by the TLS 1.0 version of the SSL used by NaoQi. The server to which I make the request is Azure and only supports TLS 1.2.

I have checked its TLS in the browser:

[TLS FROM THE SERVER][1]

I have no possibility to update Python (I do not have root permissions).

Please, do you know how I can make the request work to the server? Should I update the TLS 1.0 to TLS 1.2 on the NAOQI machine? Do you know how to update it ?.

Any help or suggestion would be welcome.

Thanks in advance, regards.

PD.

[1]: https://i.stack.imgur.com/zYhhN.png

[Moderator edit: added [code] tags to preserve output layout; broke long whitespace-free lines in code tags to fix thread layout. -Hu]

Last edited by oga on Fri Jun 01, 2018 8:41 am; edited 3 times in total

Back to top

View user's profile Send private message

John R. Graham
Administrator
Administrator

Joined: 08 Mar 2005
Posts: 10519
Location: Somewhere over Atlanta, Georgia

PostPosted: Thu May 31, 2018 4:22 pm    Post subject: Reply with quote

Moved from Networking & Security to Unsupported Software. Not about Gentoo (derivative distributions don’t qualify) so it fits better here.

— John
_________________
I can confirm that I have received between 0 and 499 National Security Letters.

Back to top

View user's profile Send private message

Hu
Moderator
Moderator

Joined: 06 Mar 2007
Posts: 19787

PostPosted: Fri Jun 01, 2018 2:01 am    Post subject: Re: ‘Connection aborted.’, error(104, ‘Connection reset by p Reply with quote

oga wrote:
I have a LINUX machine with the OpenNao distro (based on GENTOO). This machine has Python 2.7.3. I do not have root permissions.

You can download an executable image in Virtualbox (OpenNAO OS VirtualBox 2.1.2) from the following link (you will probably have to create an account):

This sounds wrong / broken. If they give you a virtual machine, you have total control over it, including the root account.

oga wrote:
My **problem** is that

Gentoo forums do not use Markdown. Instead, use BBCode to markup your posts.

oga wrote:
Code:
   url = «www.example-url.com» # it is not a real url

Among other domains, www.example.com is reserved to use for placeholders like this.

oga wrote:
Code:
       /var/persistent/home/nao/.local/lib/python2.7/site-packages/urllib3/util/ssl_.py:339

This path looks suspicious. It looks like your vendor botched the Python install rather badly.

oga wrote:
Code:
   Traceback (most recent call last):

     File «heathrowFI-3.py», line 33, in <module>

       response = requests.get(url, headers=headers, params=querystring, timeout=30)

     File «/var/persistent/home/nao/.local/lib/python2.7/site-packages/requests/api.py», line 72, in get

       return request(‘get’, url, params=params, **kwargs)

     File «/var/persistent/home/nao/.local/lib/python2.7/site-packages/requests/api.py», line 58, in request

       return session.request(method=method, url=url, **kwargs)

     File «/var/persistent/home/nao/.local/lib/python2.7/site-packages/requests/sessions.py»,

 line 508, in request

       resp = self.send(prep, **send_kwargs)

     File «/var/persistent/home/nao/.local/lib/python2.7/site-packages/requests/sessions.py»,

 line 618, in send

       r = adapter.send(request, **kwargs)

     File «/var/persistent/home/nao/.local/lib/python2.7/site-packages/requests/adapters.py»,

 line 490, in send

       raise ConnectionError(err, request=request)

   requests.exceptions.ConnectionError: (‘Connection aborted.’, error(104, ‘Connection reset by peer’))

This is not a TLS error. It is a TCP error. Check that you can connect to the server on port 443.

Back to top

View user's profile Send private message

oga
n00b
n00b

Joined: 31 May 2018
Posts: 3

PostPosted: Fri Jun 01, 2018 9:11 am    Post subject: Re: ‘Connection aborted.’, error(104, ‘Connection reset by p Reply with quote

Thanks for the tips of BBCode styles to use, and for moving the subject to the appropriate section.

The virtual machine is really a SDK (Software Development Kit) tool provided where to do tests. In fact, this machine including root account. This machine is the same installed on a robot (Pepper Aldebaran), where there really is no root account credentials.

Both with the virtual machine and with the robot I get the same error when trying to make the request to the remote server.

In Windows 10 and Ubuntu, I get a OK response from the server.

The original installation of python is in the following directory

/usr/lib/python2.7

If you want to overwrite a library, it must be done at the user level in the following directory

/var/persistent/home/nao/.local/lib/python2.7/site-packages

I tried to install in the virtual machine nmap or telnet to check the port, but I have not succeeded.

Please, could you tell me how I can check if the virtual machine connect to port 443 of the remote Azure host?.

Are you sure it’s not a TLS error?

As I read on the following link TLS 1.0 is not supported for Azure servers:

https://social.msdn.microsoft.com/Forums/en-US/9dace9cb-a1a8-4f77-af26-324bc2b6740e/tls-plans-for-azure-app-service?forum=windowsazurewebsitespreview

Any question or suggestion is welcome, I’m really quite lost.

Thank you very much for your help!

Back to top

View user's profile Send private message

Hu
Moderator
Moderator

Joined: 06 Mar 2007
Posts: 19787

PostPosted: Sat Jun 02, 2018 1:22 am    Post subject: Reply with quote

If they built bash with USE=net, you could abuse its redirection facility. Try > /dev/tcp/host/port to ask Bash to make a network connection.

You could also try to debug why you cannot install those other tools.

«Connection reset by peer» is a standard error message for TCP. Some other layer could have reused that message, but that is unlikely.

Back to top

View user's profile Send private message

oga
n00b
n00b

Joined: 31 May 2018
Posts: 3

PostPosted: Mon Jun 04, 2018 11:09 am    Post subject: work-around with java Reply with quote

Hu,

Thanks for the tips.

I could not execute the instruction to check the network connection.

I would not know how to debug the causes of the error.

Regarding the causes of the error, I am convinced that it is due to the incompatibility of the TLS version used by the Python library, when making the request to the AZURE server.

I made a «work-around» by executing the request from a script programmed in JAVA. In this way I can successfully perform the request to the server.

After which I will embed this JAVA script in the PYTHON program. I know it’s not the best option, but at least it works.

If you consider it appropriate we can close the thread, and unless someone comes up with how to solve the PYTHON problem.

Either way, I am very grateful for the treatment received. You are a great community!

Thanks!

Back to top

View user's profile Send private message

Hu
Moderator
Moderator

Joined: 06 Mar 2007
Posts: 19787

PostPosted: Tue Jun 05, 2018 1:50 am    Post subject: Reply with quote

Threads are only closed when they violate forum rules. Otherwise, they are marked solved and people cease posting to them because there is nothing more to say.
Back to top

View user's profile Send private message

Display posts from previous:   

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

Понравилась статья? Поделить с друзьями:

Читайте также:

  • Dateizugriff verweigert omsi 2 как исправить
  • Connecting cs go network как исправить
  • Date timezone error a valid timezone that matches mysql and the system
  • Configure error library crypto not found install openssl
  • Copy partition error code 40

  • 0 0 голоса
    Рейтинг статьи
    Подписаться
    Уведомить о
    guest

    0 комментариев
    Старые
    Новые Популярные
    Межтекстовые Отзывы
    Посмотреть все комментарии