Pip install fails with "Connection broken"

raspberrypi3

#1

I am having issues with using pip in a resin based image. My Dockerfile is the following:

FROM resin/raspberrypi3-python:3.6
MAINTAINER Andrew Kail <andrew.a.kail@gmail.com>

RUN [ "cross-build-start" ]

RUN apt-get update  
RUN pip install Django

RUN [ "cross-build-end" ]

When it hits the ‘pip install’ I get the following error.

Collecting Django
  Downloading Django-2.0.2-py3-none-any.whl (7.1MB)
Exception:
Traceback (most recent call last):                                                                                                                                                           
  File "/usr/local/lib/python3.6/site-packages/pip/_vendor/requests/packages/urllib3/response.py", line 232, in _error_catcher                                                               
    yield                                                                                                                                                                                    
  File "/usr/local/lib/python3.6/site-packages/pip/_vendor/requests/packages/urllib3/response.py", line 314, in read                                                                         
    data = self._fp.read(amt)                                                                                                                                                                
  File "/usr/local/lib/python3.6/site-packages/pip/_vendor/cachecontrol/filewrapper.py", line 60, in read                                                                                    
    data = self.__fp.read(amt)                                                                                                                                                               
  File "/usr/local/lib/python3.6/http/client.py", line 449, in read                                                                                                                          
    n = self.readinto(b)                                                                                                                                                                     
  File "/usr/local/lib/python3.6/http/client.py", line 493, in readinto                                                                                                                      
    n = self.fp.readinto(b)                                                                                                                                                                  
  File "/usr/local/lib/python3.6/socket.py", line 586, in readinto                                                                                                                           
    return self._sock.recv_into(b)                                                                                                                                                           
  File "/usr/local/lib/python3.6/ssl.py", line 1009, in recv_into                                                                                                                            
    return self.read(nbytes, buffer)                                                                                                                                                         
  File "/usr/local/lib/python3.6/ssl.py", line 871, in read                                                                                                                                  
    return self._sslobj.read(len, buffer)                                                                                                                                                    
  File "/usr/local/lib/python3.6/ssl.py", line 631, in read                                                                                                                                  
    v = self._sslobj.read(len, buffer)                                                                                                                                                       
ConnectionResetError: [Errno 104] Connection reset by peer                                                                                                                                   

During handling of the above exception, another exception occurred:                                                                                                                          

Traceback (most recent call last):                                                                                                                                                           
  File "/usr/local/lib/python3.6/site-packages/pip/basecommand.py", line 215, in main                                                                                                        
    status = self.run(options, args)                                                                                                                                                         
  File "/usr/local/lib/python3.6/site-packages/pip/commands/install.py", line 324, in run                                                                                                    
    requirement_set.prepare_files(finder)                                                                                                                                                    
  File "/usr/local/lib/python3.6/site-packages/pip/req/req_set.py", line 380, in prepare_files                                                                                               
    ignore_dependencies=self.ignore_dependencies))                                                                                                                                           
  File "/usr/local/lib/python3.6/site-packages/pip/req/req_set.py", line 620, in _prepare_file                                                                                               
    session=self.session, hashes=hashes)                                                                                                                                                     
  File "/usr/local/lib/python3.6/site-packages/pip/download.py", line 821, in unpack_url                                                                                                     
    hashes=hashes                                                                                                                                                                            
  File "/usr/local/lib/python3.6/site-packages/pip/download.py", line 659, in unpack_http_url                                                                                                
    hashes)                                                                                                                                                                                  
  File "/usr/local/lib/python3.6/site-packages/pip/download.py", line 882, in _download_http_url                                                                                             
    _download_url(resp, link, content_file, hashes)                                                                                                                                          
  File "/usr/local/lib/python3.6/site-packages/pip/download.py", line 603, in _download_url                                                                                                  
    hashes.check_against_chunks(downloaded_chunks)                                                                                                                                           
  File "/usr/local/lib/python3.6/site-packages/pip/utils/hashes.py", line 46, in check_against_chunks                                                                                        
    for chunk in chunks:                                                                                                                                                                     
  File "/usr/local/lib/python3.6/site-packages/pip/download.py", line 571, in written_chunks                                                                                                 
    for chunk in chunks:                                                                                                                                                                     
  File "/usr/local/lib/python3.6/site-packages/pip/utils/ui.py", line 139, in iter                                                                                                           
    for x in it:                                                                                                                                                                             
  File "/usr/local/lib/python3.6/site-packages/pip/download.py", line 560, in resp_read                                                                                                      
    decode_content=False):                                                                                                                                                                   
  File "/usr/local/lib/python3.6/site-packages/pip/_vendor/requests/packages/urllib3/response.py", line 357, in stream                                                                       
    data = self.read(amt=amt, decode_content=decode_content)                                                                                                                                 
  File "/usr/local/lib/python3.6/site-packages/pip/_vendor/requests/packages/urllib3/response.py", line 324, in read                                                                         
    flush_decoder = True                                                                                                                                                                     
  File "/usr/local/lib/python3.6/contextlib.py", line 99, in __exit__                                                                                                                        
    self.gen.throw(type, value, traceback)                                                                                                                                                   
  File "/usr/local/lib/python3.6/site-packages/pip/_vendor/requests/packages/urllib3/response.py", line 250, in _error_catcher                                                               
    raise ProtocolError('Connection broken: %r' % e, e)                                                                                                                                      
pip._vendor.requests.packages.urllib3.exceptions.ProtocolError: ("Connection broken: ConnectionResetError(104, 'Connection reset by peer')", ConnectionResetError(104, 'Connection reset by peer'))   

I am building on Manjaro Linux with docker version 18.01.0-ce and kernel 4.14.16-1.

Some google searching has shown issues in Travis CI that are the same, but the fix did not work for me.

Also, I am able to do these builds without issue using x86 based images doing the exact same docker commands.

Has anyone experienced this before and worked around it? I’m at a loss.

Thanks,


#4

Hello,

This looks like a temporary network failure. I just pushed a project that downloads Django and it built correctly.
Could you please try again?


#5

I agree. Everything I have found points to that being the issue. I am not currently pushing anything to resin, just starting to get started with building rpi3 images on my personal device.

Its a little strange that apt-get update (and upgrade) are working fine. Same build works fine with alpine and debian x86 images.

Next I may try another resin arm image and then do a tcpdump to see what the network traffic over the docker interface looks like.


#6

Tcpdump with wireshark. ZeroWindow Error

157 1.798524 172.17.0.2 151.101.0.223 TCP 54 [TCP ZeroWindow] 41582 → 443 [ACK] Seq=1798 Ack=852072 Win=0 Len=0

Also:
Build fails identically with resin/armv7hf-debian image as well.