requests 2.18.4 with proxies throw SSLError: ("bad handshake: SysCallError(-1, 'Unexpected EOF')",)

Hi,
When I use requests 2.18.4 with proxies, it throw SSLError: ("bad handshake: SysCallError(-1, 'Unexpected EOF')",)

MacOS Sierra
Python 3.6.2
OpenSSL 1.0.2l

pip3 list:

asn1crypto (0.22.0)
certifi (2017.7.27.1)
cffi (1.10.0)
chardet (3.0.4)
cryptography (2.0.3)
idna (2.6)
pycparser (2.18)
pyOpenSSL (17.2.0)
PySocks (1.6.7)
requests (2.18.4)
setuptools (28.8.0)
six (1.10.0)
tqdm (4.15.0)
urllib3 (1.22)

My code:

    import requests
    proxies={'http':'socks5://127.0.0.1:1080', 'https': 'socks5://127.0.0.1:1080'}
    r=requests.get('https://www.instagram.com/',proxies=proxies)
Error message:

        Traceback (most recent call last):
          File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/urllib3-1.22-py3.6.egg/urllib3/contrib/pyopenssl.py", line 441, in wrap_socket
            cnx.do_handshake()
          File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/OpenSSL/SSL.py", line 1716, in do_handshake
            self._raise_ssl_error(self._ssl, result)
          File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/OpenSSL/SSL.py", line 1449, in _raise_ssl_error
            raise SysCallError(-1, "Unexpected EOF")
        OpenSSL.SSL.SysCallError: (-1, 'Unexpected EOF')

        During handling of the above exception, another exception occurred:

        Traceback (most recent call last):
          File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/urllib3-1.22-py3.6.egg/urllib3/connectionpool.py", line 601, in urlopen
            chunked=chunked)
          File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/urllib3-1.22-py3.6.egg/urllib3/connectionpool.py", line 346, in _make_request
            self._validate_conn(conn)
          File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/urllib3-1.22-py3.6.egg/urllib3/connectionpool.py", line 850, in _validate_conn
            conn.connect()
          File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/urllib3-1.22-py3.6.egg/urllib3/connection.py", line 326, in connect
            ssl_context=context)
          File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/urllib3-1.22-py3.6.egg/urllib3/util/ssl_.py", line 329, in ssl_wrap_socket
            return context.wrap_socket(sock, server_hostname=server_hostname)
          File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/urllib3-1.22-py3.6.egg/urllib3/contrib/pyopenssl.py", line 448, in wrap_socket
            raise ssl.SSLError('bad handshake: %r' % e)
        ssl.SSLError: ("bad handshake: SysCallError(-1, 'Unexpected EOF')",)

        During handling of the above exception, another exception occurred:

        Traceback (most recent call last):
          File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/requests-2.18.4-py3.6.egg/requests/adapters.py", line 440, in send
            timeout=timeout
          File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/urllib3-1.22-py3.6.egg/urllib3/connectionpool.py", line 639, in urlopen
            _stacktrace=sys.exc_info()[2])
          File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/urllib3-1.22-py3.6.egg/urllib3/util/retry.py", line 388, in increment
            raise MaxRetryError(_pool, url, error or ResponseError(cause))
        urllib3.exceptions.MaxRetryError: SOCKSHTTPSConnectionPool(host='www.instagram.com', port=443): Max retries exceeded with url: / (Caused by SSLError(SSLError("bad handshake: SysCallError(-1, 'Unexpected EOF')",),))

        During handling of the above exception, another exception occurred:

        Traceback (most recent call last):
          File "/Library/Frameworks/Python.framework/Versions/3.6/bin/instagram-scraper", line 11, in <module>
            load_entry_point('instagram-scraper', 'console_scripts', 'instagram-scraper')()
          File "/Users/wangwei/xingxing/scrape_instagram/instagram-scraper/instagram_scraper/app.py", line 763, in main
            scraper.scrape()
          File "/Users/wangwei/xingxing/scrape_instagram/instagram-scraper/instagram_scraper/app.py", line 346, in scrape
            self.login()
          File "/Users/wangwei/xingxing/scrape_instagram/instagram-scraper/instagram_scraper/app.py", line 97, in login
            req = self.session.get('https://www.instagram.com/',proxies =proxies)
          File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/requests-2.18.4-py3.6.egg/requests/sessions.py", line 521, in get
            return self.request('GET', url, **kwargs)
          File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/requests-2.18.4-py3.6.egg/requests/sessions.py", line 508, in request
            resp = self.send(prep, **send_kwargs)
          File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/requests-2.18.4-py3.6.egg/requests/sessions.py", line 618, in send
            r = adapter.send(request, **kwargs)
          File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/requests-2.18.4-py3.6.egg/requests/adapters.py", line 506, in send
            raise SSLError(e, request=request)
        requests.exceptions.SSLError: SOCKSHTTPSConnectionPool(host='www.instagram.com', port=443): Max retries exceeded with url: / (Caused by SSLError(SSLError("bad handshake: SysCallError(-1, 'Unexpected EOF')",),))
        
I check all issues about 'SSLError: ("bad handshake: SysCallError(-1, 'Unexpected EOF')",)' including [issue#4193](https://github.com/requests/requests/issues/4193),but i do not find the solution. I want to know what the reason is, help me~~ thanks

Did you *try* the solution from #4193?

Ah, wait, you're using SOCKS. This may change some stuff around. Is your SOCKS proxy messing with the connection in any way?

Ah, yes i tried #4193 ，what is the meaning of ‘messing with the connection in any way’，mybe i make a mistake .. I use Shadowsocks proxy.

can you suggest me something about it. do you need some more infomations ? eg:wireshark data..
thanks~~

I think seeing the wireshark data between the client and the proxy would be helpful.

    No.     Time           Source                Destination           Protocol Length Info
          5 0.024293       192.168.199.154       47.90.120.149         TCP      78     49689 → 30612 [SYN] Seq=0 Win=65535 Len=0 MSS=1460 WS=32 TSval=174674336 TSecr=0 SACK_PERM=1

    Frame 5: 78 bytes on wire (624 bits), 78 bytes captured (624 bits) on interface 0
        Interface id: 0 (en0)
            Interface name: en0
        Encapsulation type: Ethernet (1)
        Arrival Time: Sep  2, 2017 00:22:43.459267000 CST
        [Time shift for this packet: 0.000000000 seconds]
        Epoch Time: 1504282963.459267000 seconds
        [Time delta from previous captured frame: 0.000420000 seconds]
        [Time delta from previous displayed frame: 0.000000000 seconds]
        [Time since reference or first frame: 0.024293000 seconds]
        Frame Number: 5
        Frame Length: 78 bytes (624 bits)
        Capture Length: 78 bytes (624 bits)
        [Frame is marked: False]
        [Frame is ignored: False]
        [Protocols in frame: eth:ethertype:ip:tcp]
        [Coloring Rule Name: TCP SYN/FIN]
        [Coloring Rule String: tcp.flags & 0x02 || tcp.flags.fin == 1]
    Ethernet II, Src: Apple_cd:f9:12 (34:36:3b:cd:f9:12), Dst: Hiwifi_34:31:98 (d4:ee:07:34:31:98)
        Destination: Hiwifi_34:31:98 (d4:ee:07:34:31:98)
            Address: Hiwifi_34:31:98 (d4:ee:07:34:31:98)
            .... ..0. .... .... .... .... = LG bit: Globally unique address (factory default)
            .... ...0 .... .... .... .... = IG bit: Individual address (unicast)
        Source: Apple_cd:f9:12 (34:36:3b:cd:f9:12)
            Address: Apple_cd:f9:12 (34:36:3b:cd:f9:12)
            .... ..0. .... .... .... .... = LG bit: Globally unique address (factory default)
            .... ...0 .... .... .... .... = IG bit: Individual address (unicast)
        Type: IPv4 (0x0800)
    Internet Protocol Version 4, Src: 192.168.199.154, Dst: 47.90.120.149
        0100 .... = Version: 4
        .... 0101 = Header Length: 20 bytes (5)
        Differentiated Services Field: 0x00 (DSCP: CS0, ECN: Not-ECT)
            0000 00.. = Differentiated Services Codepoint: Default (0)
            .... ..00 = Explicit Congestion Notification: Not ECN-Capable Transport (0)
        Total Length: 64
        Identification: 0x3fc6 (16326)
        Flags: 0x02 (Don't Fragment)
            0... .... = Reserved bit: Not set
            .1.. .... = Don't fragment: Set
            ..0. .... = More fragments: Not set
        Fragment offset: 0
        Time to live: 64
        Protocol: TCP (6)
        Header checksum: 0xcabf [validation disabled]
        [Header checksum status: Unverified]
        Source: 192.168.199.154
        Destination: 47.90.120.149
        [Source GeoIP: Unknown]
        [Destination GeoIP: Unknown]
    Transmission Control Protocol, Src Port: 49689, Dst Port: 30612, Seq: 0, Len: 0
        Source Port: 49689
        Destination Port: 30612
        [Stream index: 0]
        [TCP Segment Len: 0]
        Sequence number: 0    (relative sequence number)
        Acknowledgment number: 0
        1011 .... = Header Length: 44 bytes (11)
        Flags: 0x002 (SYN)
            000. .... .... = Reserved: Not set
            ...0 .... .... = Nonce: Not set
            .... 0... .... = Congestion Window Reduced (CWR): Not set
            .... .0.. .... = ECN-Echo: Not set
            .... ..0. .... = Urgent: Not set
            .... ...0 .... = Acknowledgment: Not set
            .... .... 0... = Push: Not set
            .... .... .0.. = Reset: Not set
            .... .... ..1. = Syn: Set
                [Expert Info (Chat/Sequence): Connection establish request (SYN): server port 30612]
                    [Connection establish request (SYN): server port 30612]
                    [Severity level: Chat]
                    [Group: Sequence]
            .... .... ...0 = Fin: Not set
            [TCP Flags: ··········S·]
        Window size value: 65535
        [Calculated window size: 65535]
        Checksum: 0x0c60 [unverified]
        [Checksum Status: Unverified]
        Urgent pointer: 0
        Options: (24 bytes), Maximum segment size, No-Operation (NOP), Window scale, No-Operation (NOP), No-Operation (NOP), Timestamps, SACK permitted, End of Option List (EOL)
            TCP Option - Maximum segment size: 1460 bytes
                Kind: Maximum Segment Size (2)
                Length: 4
                MSS Value: 1460
            TCP Option - No-Operation (NOP)
                Kind: No-Operation (1)
            TCP Option - Window scale: 5 (multiply by 32)
                Kind: Window Scale (3)
                Length: 3
                Shift count: 5
                [Multiplier: 32]
            TCP Option - No-Operation (NOP)
                Kind: No-Operation (1)
            TCP Option - No-Operation (NOP)
                Kind: No-Operation (1)
            TCP Option - Timestamps: TSval 174674336, TSecr 0
                Kind: Time Stamp Option (8)
                Length: 10
                Timestamp value: 174674336
                Timestamp echo reply: 0
            TCP Option - SACK permitted
                Kind: SACK Permitted (4)
                Length: 2
            TCP Option - End of Option List (EOL)
                Kind: End of Option List (0)

    No.     Time           Source                Destination           Protocol Length Info
          6 0.073556       47.90.120.149         192.168.199.154       TCP      74     30612 → 49689 [SYN, ACK] Seq=0 Ack=1 Win=14480 Len=0 MSS=1412 SACK_PERM=1 TSval=1813150359 TSecr=174674336 WS=64

    Frame 6: 74 bytes on wire (592 bits), 74 bytes captured (592 bits) on interface 0
        Interface id: 0 (en0)
            Interface name: en0
        Encapsulation type: Ethernet (1)
        Arrival Time: Sep  2, 2017 00:22:43.508530000 CST
        [Time shift for this packet: 0.000000000 seconds]
        Epoch Time: 1504282963.508530000 seconds
        [Time delta from previous captured frame: 0.049263000 seconds]
        [Time delta from previous displayed frame: 0.049263000 seconds]
        [Time since reference or first frame: 0.073556000 seconds]
        Frame Number: 6
        Frame Length: 74 bytes (592 bits)
        Capture Length: 74 bytes (592 bits)
        [Frame is marked: False]
        [Frame is ignored: False]
        [Protocols in frame: eth:ethertype:ip:tcp]
        [Coloring Rule Name: TCP SYN/FIN]
        [Coloring Rule String: tcp.flags & 0x02 || tcp.flags.fin == 1]
    Ethernet II, Src: Hiwifi_34:31:98 (d4:ee:07:34:31:98), Dst: Apple_cd:f9:12 (34:36:3b:cd:f9:12)
        Destination: Apple_cd:f9:12 (34:36:3b:cd:f9:12)
            Address: Apple_cd:f9:12 (34:36:3b:cd:f9:12)
            .... ..0. .... .... .... .... = LG bit: Globally unique address (factory default)
            .... ...0 .... .... .... .... = IG bit: Individual address (unicast)
        Source: Hiwifi_34:31:98 (d4:ee:07:34:31:98)
            Address: Hiwifi_34:31:98 (d4:ee:07:34:31:98)
            .... ..0. .... .... .... .... = LG bit: Globally unique address (factory default)
            .... ...0 .... .... .... .... = IG bit: Individual address (unicast)
        Type: IPv4 (0x0800)
    Internet Protocol Version 4, Src: 47.90.120.149, Dst: 192.168.199.154
        0100 .... = Version: 4
        .... 0101 = Header Length: 20 bytes (5)
        Differentiated Services Field: 0x00 (DSCP: CS0, ECN: Not-ECT)
            0000 00.. = Differentiated Services Codepoint: Default (0)
            .... ..00 = Explicit Congestion Notification: Not ECN-Capable Transport (0)
        Total Length: 60
        Identification: 0x0000 (0)
        Flags: 0x02 (Don't Fragment)
            0... .... = Reserved bit: Not set
            .1.. .... = Don't fragment: Set
            ..0. .... = More fragments: Not set
        Fragment offset: 0
        Time to live: 47
        Protocol: TCP (6)
        Header checksum: 0x1b8a [validation disabled]
        [Header checksum status: Unverified]
        Source: 47.90.120.149
        Destination: 192.168.199.154
        [Source GeoIP: Unknown]
        [Destination GeoIP: Unknown]
    Transmission Control Protocol, Src Port: 30612, Dst Port: 49689, Seq: 0, Ack: 1, Len: 0
        Source Port: 30612
        Destination Port: 49689
        [Stream index: 0]
        [TCP Segment Len: 0]
        Sequence number: 0    (relative sequence number)
        Acknowledgment number: 1    (relative ack number)
        1010 .... = Header Length: 40 bytes (10)
        Flags: 0x012 (SYN, ACK)
            000. .... .... = Reserved: Not set
            ...0 .... .... = Nonce: Not set
            .... 0... .... = Congestion Window Reduced (CWR): Not set
            .... .0.. .... = ECN-Echo: Not set
            .... ..0. .... = Urgent: Not set
            .... ...1 .... = Acknowledgment: Set
            .... .... 0... = Push: Not set
            .... .... .0.. = Reset: Not set
            .... .... ..1. = Syn: Set
                [Expert Info (Chat/Sequence): Connection establish acknowledge (SYN+ACK): server port 30612]
                    [Connection establish acknowledge (SYN+ACK): server port 30612]
                    [Severity level: Chat]
                    [Group: Sequence]
            .... .... ...0 = Fin: Not set
            [TCP Flags: ·······A··S·]
        Window size value: 14480
        [Calculated window size: 14480]
        Checksum: 0x51f5 [unverified]
        [Checksum Status: Unverified]
        Urgent pointer: 0
        Options: (20 bytes), Maximum segment size, SACK permitted, Timestamps, No-Operation (NOP), Window scale
            TCP Option - Maximum segment size: 1412 bytes
                Kind: Maximum Segment Size (2)
                Length: 4
                MSS Value: 1412
            TCP Option - SACK permitted
                Kind: SACK Permitted (4)
                Length: 2
            TCP Option - Timestamps: TSval 1813150359, TSecr 174674336
                Kind: Time Stamp Option (8)
                Length: 10
                Timestamp value: 1813150359
                Timestamp echo reply: 174674336
            TCP Option - No-Operation (NOP)
                Kind: No-Operation (1)
            TCP Option - Window scale: 6 (multiply by 64)
                Kind: Window Scale (3)
                Length: 3
                Shift count: 6
                [Multiplier: 64]
        [SEQ/ACK analysis]
            [This is an ACK to the segment in frame: 5]
            [The RTT to ACK the segment was: 0.049263000 seconds]
            [iRTT: 0.049355000 seconds]

    No.     Time           Source                Destination           Protocol Length Info
          7 0.073648       192.168.199.154       47.90.120.149         TCP      66     49689 → 30612 [ACK] Seq=1 Ack=1 Win=131584 Len=0 TSval=174674385 TSecr=1813150359

    Frame 7: 66 bytes on wire (528 bits), 66 bytes captured (528 bits) on interface 0
        Interface id: 0 (en0)
            Interface name: en0
        Encapsulation type: Ethernet (1)
        Arrival Time: Sep  2, 2017 00:22:43.508622000 CST
        [Time shift for this packet: 0.000000000 seconds]
        Epoch Time: 1504282963.508622000 seconds
        [Time delta from previous captured frame: 0.000092000 seconds]
        [Time delta from previous displayed frame: 0.000092000 seconds]
        [Time since reference or first frame: 0.073648000 seconds]
        Frame Number: 7
        Frame Length: 66 bytes (528 bits)
        Capture Length: 66 bytes (528 bits)
        [Frame is marked: False]
        [Frame is ignored: False]
        [Protocols in frame: eth:ethertype:ip:tcp]
        [Coloring Rule Name: TCP]
        [Coloring Rule String: tcp]
    Ethernet II, Src: Apple_cd:f9:12 (34:36:3b:cd:f9:12), Dst: Hiwifi_34:31:98 (d4:ee:07:34:31:98)
        Destination: Hiwifi_34:31:98 (d4:ee:07:34:31:98)
            Address: Hiwifi_34:31:98 (d4:ee:07:34:31:98)
            .... ..0. .... .... .... .... = LG bit: Globally unique address (factory default)
            .... ...0 .... .... .... .... = IG bit: Individual address (unicast)
        Source: Apple_cd:f9:12 (34:36:3b:cd:f9:12)
            Address: Apple_cd:f9:12 (34:36:3b:cd:f9:12)
            .... ..0. .... .... .... .... = LG bit: Globally unique address (factory default)
            .... ...0 .... .... .... .... = IG bit: Individual address (unicast)
        Type: IPv4 (0x0800)
    Internet Protocol Version 4, Src: 192.168.199.154, Dst: 47.90.120.149
        0100 .... = Version: 4
        .... 0101 = Header Length: 20 bytes (5)
        Differentiated Services Field: 0x00 (DSCP: CS0, ECN: Not-ECT)
            0000 00.. = Differentiated Services Codepoint: Default (0)
            .... ..00 = Explicit Congestion Notification: Not ECN-Capable Transport (0)
        Total Length: 52
        Identification: 0x7715 (30485)
        Flags: 0x02 (Don't Fragment)
            0... .... = Reserved bit: Not set
            .1.. .... = Don't fragment: Set
            ..0. .... = More fragments: Not set
        Fragment offset: 0
        Time to live: 64
        Protocol: TCP (6)
        Header checksum: 0x937c [validation disabled]
        [Header checksum status: Unverified]
        Source: 192.168.199.154
        Destination: 47.90.120.149
        [Source GeoIP: Unknown]
        [Destination GeoIP: Unknown]
    Transmission Control Protocol, Src Port: 49689, Dst Port: 30612, Seq: 1, Ack: 1, Len: 0
        Source Port: 49689
        Destination Port: 30612
        [Stream index: 0]
        [TCP Segment Len: 0]
        Sequence number: 1    (relative sequence number)
        Acknowledgment number: 1    (relative ack number)
        1000 .... = Header Length: 32 bytes (8)
        Flags: 0x010 (ACK)
            000. .... .... = Reserved: Not set
            ...0 .... .... = Nonce: Not set
            .... 0... .... = Congestion Window Reduced (CWR): Not set
            .... .0.. .... = ECN-Echo: Not set
            .... ..0. .... = Urgent: Not set
            .... ...1 .... = Acknowledgment: Set
            .... .... 0... = Push: Not set
            .... .... .0.. = Reset: Not set
            .... .... ..0. = Syn: Not set
            .... .... ...0 = Fin: Not set
            [TCP Flags: ·······A····]
        Window size value: 4112
        [Calculated window size: 131584]
        [Window size scaling factor: 32]
        Checksum: 0xa8df [unverified]
        [Checksum Status: Unverified]
        Urgent pointer: 0
        Options: (12 bytes), No-Operation (NOP), No-Operation (NOP), Timestamps
            TCP Option - No-Operation (NOP)
                Kind: No-Operation (1)
            TCP Option - No-Operation (NOP)
                Kind: No-Operation (1)
            TCP Option - Timestamps: TSval 174674385, TSecr 1813150359
                Kind: Time Stamp Option (8)
                Length: 10
                Timestamp value: 174674385
                Timestamp echo reply: 1813150359
        [SEQ/ACK analysis]
            [This is an ACK to the segment in frame: 6]
            [The RTT to ACK the segment was: 0.000092000 seconds]
            [iRTT: 0.049355000 seconds]

    No.     Time           Source                Destination           Protocol Length Info
          8 0.075483       192.168.199.154       47.90.120.149         TCP      89     49689 → 30612 [PSH, ACK] Seq=1 Ack=1 Win=131584 Len=23 TSval=174674386 TSecr=1813150359

    Frame 8: 89 bytes on wire (712 bits), 89 bytes captured (712 bits) on interface 0
        Interface id: 0 (en0)
            Interface name: en0
        Encapsulation type: Ethernet (1)
        Arrival Time: Sep  2, 2017 00:22:43.510457000 CST
        [Time shift for this packet: 0.000000000 seconds]
        Epoch Time: 1504282963.510457000 seconds
        [Time delta from previous captured frame: 0.001835000 seconds]
        [Time delta from previous displayed frame: 0.001835000 seconds]
        [Time since reference or first frame: 0.075483000 seconds]
        Frame Number: 8
        Frame Length: 89 bytes (712 bits)
        Capture Length: 89 bytes (712 bits)
        [Frame is marked: False]
        [Frame is ignored: False]
        [Protocols in frame: eth:ethertype:ip:tcp:data]
        [Coloring Rule Name: TCP]
        [Coloring Rule String: tcp]
    Ethernet II, Src: Apple_cd:f9:12 (34:36:3b:cd:f9:12), Dst: Hiwifi_34:31:98 (d4:ee:07:34:31:98)
        Destination: Hiwifi_34:31:98 (d4:ee:07:34:31:98)
            Address: Hiwifi_34:31:98 (d4:ee:07:34:31:98)
            .... ..0. .... .... .... .... = LG bit: Globally unique address (factory default)
            .... ...0 .... .... .... .... = IG bit: Individual address (unicast)
        Source: Apple_cd:f9:12 (34:36:3b:cd:f9:12)
            Address: Apple_cd:f9:12 (34:36:3b:cd:f9:12)
            .... ..0. .... .... .... .... = LG bit: Globally unique address (factory default)
            .... ...0 .... .... .... .... = IG bit: Individual address (unicast)
        Type: IPv4 (0x0800)
    Internet Protocol Version 4, Src: 192.168.199.154, Dst: 47.90.120.149
        0100 .... = Version: 4
        .... 0101 = Header Length: 20 bytes (5)
        Differentiated Services Field: 0x00 (DSCP: CS0, ECN: Not-ECT)
            0000 00.. = Differentiated Services Codepoint: Default (0)
            .... ..00 = Explicit Congestion Notification: Not ECN-Capable Transport (0)
        Total Length: 75
        Identification: 0x7385 (29573)
        Flags: 0x02 (Don't Fragment)
            0... .... = Reserved bit: Not set
            .1.. .... = Don't fragment: Set
            ..0. .... = More fragments: Not set
        Fragment offset: 0
        Time to live: 64
        Protocol: TCP (6)
        Header checksum: 0x96f5 [validation disabled]
        [Header checksum status: Unverified]
        Source: 192.168.199.154
        Destination: 47.90.120.149
        [Source GeoIP: Unknown]
        [Destination GeoIP: Unknown]
    Transmission Control Protocol, Src Port: 49689, Dst Port: 30612, Seq: 1, Ack: 1, Len: 23
        Source Port: 49689
        Destination Port: 30612
        [Stream index: 0]
        [TCP Segment Len: 23]
        Sequence number: 1    (relative sequence number)
        [Next sequence number: 24    (relative sequence number)]
        Acknowledgment number: 1    (relative ack number)
        1000 .... = Header Length: 32 bytes (8)
        Flags: 0x018 (PSH, ACK)
            000. .... .... = Reserved: Not set
            ...0 .... .... = Nonce: Not set
            .... 0... .... = Congestion Window Reduced (CWR): Not set
            .... .0.. .... = ECN-Echo: Not set
            .... ..0. .... = Urgent: Not set
            .... ...1 .... = Acknowledgment: Set
            .... .... 1... = Push: Set
            .... .... .0.. = Reset: Not set
            .... .... ..0. = Syn: Not set
            .... .... ...0 = Fin: Not set
            [TCP Flags: ·······AP···]
        Window size value: 4112
        [Calculated window size: 131584]
        [Window size scaling factor: 32]
        Checksum: 0xee13 [unverified]
        [Checksum Status: Unverified]
        Urgent pointer: 0
        Options: (12 bytes), No-Operation (NOP), No-Operation (NOP), Timestamps
            TCP Option - No-Operation (NOP)
                Kind: No-Operation (1)
            TCP Option - No-Operation (NOP)
                Kind: No-Operation (1)
            TCP Option - Timestamps: TSval 174674386, TSecr 1813150359
                Kind: Time Stamp Option (8)
                Length: 10
                Timestamp value: 174674386
                Timestamp echo reply: 1813150359
        [SEQ/ACK analysis]
            [iRTT: 0.049355000 seconds]
            [Bytes in flight: 23]
            [Bytes sent since last PSH flag: 23]
        TCP payload (23 bytes)
    Data (23 bytes)

    0000  db 79 30 10 9f b3 96 30 84 da 2b 4e 66 e6 18 ab   .y0....0..+Nf...
    0010  64 81 42 e9 fc 17 a6                              d.B....
        Data: db7930109fb3963084da2b4e66e618ab648142e9fc17a6
        [Length: 23]

    No.     Time           Source                Destination           Protocol Length Info
          9 0.086616       192.168.199.154       47.90.120.149         TCP      336    49689 → 30612 [PSH, ACK] Seq=24 Ack=1 Win=131584 Len=270 TSval=174674397 TSecr=1813150359

    Frame 9: 336 bytes on wire (2688 bits), 336 bytes captured (2688 bits) on interface 0
        Interface id: 0 (en0)
            Interface name: en0
        Encapsulation type: Ethernet (1)
        Arrival Time: Sep  2, 2017 00:22:43.521590000 CST
        [Time shift for this packet: 0.000000000 seconds]
        Epoch Time: 1504282963.521590000 seconds
        [Time delta from previous captured frame: 0.011133000 seconds]
        [Time delta from previous displayed frame: 0.011133000 seconds]
        [Time since reference or first frame: 0.086616000 seconds]
        Frame Number: 9
        Frame Length: 336 bytes (2688 bits)
        Capture Length: 336 bytes (2688 bits)
        [Frame is marked: False]
        [Frame is ignored: False]
        [Protocols in frame: eth:ethertype:ip:tcp:data]
        [Coloring Rule Name: TCP]
        [Coloring Rule String: tcp]
    Ethernet II, Src: Apple_cd:f9:12 (34:36:3b:cd:f9:12), Dst: Hiwifi_34:31:98 (d4:ee:07:34:31:98)
        Destination: Hiwifi_34:31:98 (d4:ee:07:34:31:98)
            Address: Hiwifi_34:31:98 (d4:ee:07:34:31:98)
            .... ..0. .... .... .... .... = LG bit: Globally unique address (factory default)
            .... ...0 .... .... .... .... = IG bit: Individual address (unicast)
        Source: Apple_cd:f9:12 (34:36:3b:cd:f9:12)
            Address: Apple_cd:f9:12 (34:36:3b:cd:f9:12)
            .... ..0. .... .... .... .... = LG bit: Globally unique address (factory default)
            .... ...0 .... .... .... .... = IG bit: Individual address (unicast)
        Type: IPv4 (0x0800)
    Internet Protocol Version 4, Src: 192.168.199.154, Dst: 47.90.120.149
        0100 .... = Version: 4
        .... 0101 = Header Length: 20 bytes (5)
        Differentiated Services Field: 0x00 (DSCP: CS0, ECN: Not-ECT)
            0000 00.. = Differentiated Services Codepoint: Default (0)
            .... ..00 = Explicit Congestion Notification: Not ECN-Capable Transport (0)
        Total Length: 322
        Identification: 0x4987 (18823)
        Flags: 0x02 (Don't Fragment)
            0... .... = Reserved bit: Not set
            .1.. .... = Don't fragment: Set
            ..0. .... = More fragments: Not set
        Fragment offset: 0
        Time to live: 64
        Protocol: TCP (6)
        Header checksum: 0xbffc [validation disabled]
        [Header checksum status: Unverified]
        Source: 192.168.199.154
        Destination: 47.90.120.149
        [Source GeoIP: Unknown]
        [Destination GeoIP: Unknown]
    Transmission Control Protocol, Src Port: 49689, Dst Port: 30612, Seq: 24, Ack: 1, Len: 270
        Source Port: 49689
        Destination Port: 30612
        [Stream index: 0]
        [TCP Segment Len: 270]
        Sequence number: 24    (relative sequence number)
        [Next sequence number: 294    (relative sequence number)]
        Acknowledgment number: 1    (relative ack number)
        1000 .... = Header Length: 32 bytes (8)
        Flags: 0x018 (PSH, ACK)
            000. .... .... = Reserved: Not set
            ...0 .... .... = Nonce: Not set
            .... 0... .... = Congestion Window Reduced (CWR): Not set
            .... .0.. .... = ECN-Echo: Not set
            .... ..0. .... = Urgent: Not set
            .... ...1 .... = Acknowledgment: Set
            .... .... 1... = Push: Set
            .... .... .0.. = Reset: Not set
            .... .... ..0. = Syn: Not set
            .... .... ...0 = Fin: Not set
            [TCP Flags: ·······AP···]
        Window size value: 4112
        [Calculated window size: 131584]
        [Window size scaling factor: 32]
        Checksum: 0x1520 [unverified]
        [Checksum Status: Unverified]
        Urgent pointer: 0
        Options: (12 bytes), No-Operation (NOP), No-Operation (NOP), Timestamps
            TCP Option - No-Operation (NOP)
                Kind: No-Operation (1)
            TCP Option - No-Operation (NOP)
                Kind: No-Operation (1)
            TCP Option - Timestamps: TSval 174674397, TSecr 1813150359
                Kind: Time Stamp Option (8)
                Length: 10
                Timestamp value: 174674397
                Timestamp echo reply: 1813150359
        [SEQ/ACK analysis]
            [iRTT: 0.049355000 seconds]
            [Bytes in flight: 293]
            [Bytes sent since last PSH flag: 270]
        TCP payload (270 bytes)
    Data (270 bytes)

    0000  b3 40 06 a8 36 64 ef 8a d5 9d 45 0f 64 02 21 5b   .@..6d....E.d.![
    0010  e5 e2 de a3 10 b1 4c bc 9e 53 16 dd 4b 01 d9 44   ......L..S..K..D
    0020  c3 3f 4f d2 35 2d c1 b2 60 f2 14 95 36 6b 2c a6   .?O.5-..`...6k,.
    0030  d5 7e 0b fd fa 55 2e a0 6a 5f c4 02 4d 19 47 4c   .~...U..j_..M.GL
    0040  77 fb 18 a8 73 32 2f 95 1f d4 6e a2 37 85 50 a4   w...s2/...n.7.P.
    0050  2f 68 78 b7 e5 98 1f ae 2d 27 af 6f 5d 2f 2b f9   /hx.....-'.o]/+.
    0060  e4 b4 ee 66 86 18 e9 a5 e5 21 fd 18 0b 4d 46 97   ...f.....!...MF.
    0070  16 bb a3 39 df b3 93 14 a7 26 28 8c 71 f3 fa 47   ...9.....&(.q..G
    0080  70 ac 7e fc 16 ba 56 70 d1 5a cd 38 ae 3c 33 66   p.~...Vp.Z.8.<3f
    0090  33 75 8b 81 c6 ae a7 e5 bf 73 9b 41 9b 4a 78 78   3u.......s.A.Jxx
    00a0  8e b6 71 fb b8 e4 98 39 8a 4a 73 8e 38 37 58 f4   ..q....9.Js.87X.
    00b0  f1 68 c8 ab e3 a5 bf fa 22 4e 09 04 1b e5 89 2f   .h......"N...../
    00c0  e4 d2 67 ce 1e cd 05 d3 c5 61 e2 0c bd 5b 14 c5   ..g......a...[..
    00d0  e0 aa 87 94 b1 4f bf d5 99 90 2d 30 2d 9d e7 0a   .....O....-0-...
    00e0  74 59 4a a4 7c 8b 0c 5a 98 3f ca af aa ed 9f ac   tYJ.|..Z.?......
    00f0  6a eb 8d 45 eb f3 d3 1c 2e 3c bb 51 97 6a ff cf   j..E.....<.Q.j..
    0100  3c 1f 29 05 08 f3 a7 d9 c0 b5 90 57 6e 8b         <.)........Wn.
        Data: b34006a83664ef8ad59d450f6402215be5e2dea310b14cbc...
        [Length: 270]

    No.     Time           Source                Destination           Protocol Length Info
         10 0.127217       47.90.120.149         192.168.199.154       TCP      66     30612 → 49689 [ACK] Seq=1 Ack=24 Win=14528 Len=0 TSval=1813150411 TSecr=174674386

    Frame 10: 66 bytes on wire (528 bits), 66 bytes captured (528 bits) on interface 0
        Interface id: 0 (en0)
            Interface name: en0
        Encapsulation type: Ethernet (1)
        Arrival Time: Sep  2, 2017 00:22:43.562191000 CST
        [Time shift for this packet: 0.000000000 seconds]
        Epoch Time: 1504282963.562191000 seconds
        [Time delta from previous captured frame: 0.040601000 seconds]
        [Time delta from previous displayed frame: 0.040601000 seconds]
        [Time since reference or first frame: 0.127217000 seconds]
        Frame Number: 10
        Frame Length: 66 bytes (528 bits)
        Capture Length: 66 bytes (528 bits)
        [Frame is marked: False]
        [Frame is ignored: False]
        [Protocols in frame: eth:ethertype:ip:tcp]
        [Coloring Rule Name: TCP]
        [Coloring Rule String: tcp]
    Ethernet II, Src: Hiwifi_34:31:98 (d4:ee:07:34:31:98), Dst: Apple_cd:f9:12 (34:36:3b:cd:f9:12)
        Destination: Apple_cd:f9:12 (34:36:3b:cd:f9:12)
            Address: Apple_cd:f9:12 (34:36:3b:cd:f9:12)
            .... ..0. .... .... .... .... = LG bit: Globally unique address (factory default)
            .... ...0 .... .... .... .... = IG bit: Individual address (unicast)
        Source: Hiwifi_34:31:98 (d4:ee:07:34:31:98)
            Address: Hiwifi_34:31:98 (d4:ee:07:34:31:98)
            .... ..0. .... .... .... .... = LG bit: Globally unique address (factory default)
            .... ...0 .... .... .... .... = IG bit: Individual address (unicast)
        Type: IPv4 (0x0800)
    Internet Protocol Version 4, Src: 47.90.120.149, Dst: 192.168.199.154
        0100 .... = Version: 4
        .... 0101 = Header Length: 20 bytes (5)
        Differentiated Services Field: 0x00 (DSCP: CS0, ECN: Not-ECT)
            0000 00.. = Differentiated Services Codepoint: Default (0)
            .... ..00 = Explicit Congestion Notification: Not ECN-Capable Transport (0)
        Total Length: 52
        Identification: 0x7160 (29024)
        Flags: 0x02 (Don't Fragment)
            0... .... = Reserved bit: Not set
            .1.. .... = Don't fragment: Set
            ..0. .... = More fragments: Not set
        Fragment offset: 0
        Time to live: 47
        Protocol: TCP (6)
        Header checksum: 0xaa31 [validation disabled]
        [Header checksum status: Unverified]
        Source: 47.90.120.149
        Destination: 192.168.199.154
        [Source GeoIP: Unknown]
        [Destination GeoIP: Unknown]
    Transmission Control Protocol, Src Port: 30612, Dst Port: 49689, Seq: 1, Ack: 24, Len: 0
        Source Port: 30612
        Destination Port: 49689
        [Stream index: 0]
        [TCP Segment Len: 0]
        Sequence number: 1    (relative sequence number)
        Acknowledgment number: 24    (relative ack number)
        1000 .... = Header Length: 32 bytes (8)
        Flags: 0x010 (ACK)
            000. .... .... = Reserved: Not set
            ...0 .... .... = Nonce: Not set
            .... 0... .... = Congestion Window Reduced (CWR): Not set
            .... .0.. .... = ECN-Echo: Not set
            .... ..0. .... = Urgent: Not set
            .... ...1 .... = Acknowledgment: Set
            .... .... 0... = Push: Not set
            .... .... .0.. = Reset: Not set
            .... .... ..0. = Syn: Not set
            .... .... ...0 = Fin: Not set
            [TCP Flags: ·······A····]
        Window size value: 227
        [Calculated window size: 14528]
        [Window size scaling factor: 64]
        Checksum: 0xb7c0 [unverified]
        [Checksum Status: Unverified]
        Urgent pointer: 0
        Options: (12 bytes), No-Operation (NOP), No-Operation (NOP), Timestamps
            TCP Option - No-Operation (NOP)
                Kind: No-Operation (1)
            TCP Option - No-Operation (NOP)
                Kind: No-Operation (1)
            TCP Option - Timestamps: TSval 1813150411, TSecr 174674386
                Kind: Time Stamp Option (8)
                Length: 10
                Timestamp value: 1813150411
                Timestamp echo reply: 174674386
        [SEQ/ACK analysis]
            [This is an ACK to the segment in frame: 8]
            [The RTT to ACK the segment was: 0.051734000 seconds]
            [iRTT: 0.049355000 seconds]

    No.     Time           Source                Destination           Protocol Length Info
         11 0.136884       47.90.120.149         192.168.199.154       TCP      66     30612 → 49689 [ACK] Seq=1 Ack=294 Win=15552 Len=0 TSval=1813150423 TSecr=174674397

    Frame 11: 66 bytes on wire (528 bits), 66 bytes captured (528 bits) on interface 0
        Interface id: 0 (en0)
            Interface name: en0
        Encapsulation type: Ethernet (1)
        Arrival Time: Sep  2, 2017 00:22:43.571858000 CST
        [Time shift for this packet: 0.000000000 seconds]
        Epoch Time: 1504282963.571858000 seconds
        [Time delta from previous captured frame: 0.009667000 seconds]
        [Time delta from previous displayed frame: 0.009667000 seconds]
        [Time since reference or first frame: 0.136884000 seconds]
        Frame Number: 11
        Frame Length: 66 bytes (528 bits)
        Capture Length: 66 bytes (528 bits)
        [Frame is marked: False]
        [Frame is ignored: False]
        [Protocols in frame: eth:ethertype:ip:tcp]
        [Coloring Rule Name: TCP]
        [Coloring Rule String: tcp]
    Ethernet II, Src: Hiwifi_34:31:98 (d4:ee:07:34:31:98), Dst: Apple_cd:f9:12 (34:36:3b:cd:f9:12)
        Destination: Apple_cd:f9:12 (34:36:3b:cd:f9:12)
            Address: Apple_cd:f9:12 (34:36:3b:cd:f9:12)
            .... ..0. .... .... .... .... = LG bit: Globally unique address (factory default)
            .... ...0 .... .... .... .... = IG bit: Individual address (unicast)
        Source: Hiwifi_34:31:98 (d4:ee:07:34:31:98)
            Address: Hiwifi_34:31:98 (d4:ee:07:34:31:98)
            .... ..0. .... .... .... .... = LG bit: Globally unique address (factory default)
            .... ...0 .... .... .... .... = IG bit: Individual address (unicast)
        Type: IPv4 (0x0800)
    Internet Protocol Version 4, Src: 47.90.120.149, Dst: 192.168.199.154
        0100 .... = Version: 4
        .... 0101 = Header Length: 20 bytes (5)
        Differentiated Services Field: 0x00 (DSCP: CS0, ECN: Not-ECT)
            0000 00.. = Differentiated Services Codepoint: Default (0)
            .... ..00 = Explicit Congestion Notification: Not ECN-Capable Transport (0)
        Total Length: 52
        Identification: 0x7161 (29025)
        Flags: 0x02 (Don't Fragment)
            0... .... = Reserved bit: Not set
            .1.. .... = Don't fragment: Set
            ..0. .... = More fragments: Not set
        Fragment offset: 0
        Time to live: 47
        Protocol: TCP (6)
        Header checksum: 0xaa30 [validation disabled]
        [Header checksum status: Unverified]
        Source: 47.90.120.149
        Destination: 192.168.199.154
        [Source GeoIP: Unknown]
        [Destination GeoIP: Unknown]
    Transmission Control Protocol, Src Port: 30612, Dst Port: 49689, Seq: 1, Ack: 294, Len: 0
        Source Port: 30612
        Destination Port: 49689
        [Stream index: 0]
        [TCP Segment Len: 0]
        Sequence number: 1    (relative sequence number)
        Acknowledgment number: 294    (relative ack number)
        1000 .... = Header Length: 32 bytes (8)
        Flags: 0x010 (ACK)
            000. .... .... = Reserved: Not set
            ...0 .... .... = Nonce: Not set
            .... 0... .... = Congestion Window Reduced (CWR): Not set
            .... .0.. .... = ECN-Echo: Not set
            .... ..0. .... = Urgent: Not set
            .... ...1 .... = Acknowledgment: Set
            .... .... 0... = Push: Not set
            .... .... .0.. = Reset: Not set
            .... .... ..0. = Syn: Not set
            .... .... ...0 = Fin: Not set
            [TCP Flags: ·······A····]
        Window size value: 243
        [Calculated window size: 15552]
        [Window size scaling factor: 64]
        Checksum: 0xb68b [unverified]
        [Checksum Status: Unverified]
        Urgent pointer: 0
        Options: (12 bytes), No-Operation (NOP), No-Operation (NOP), Timestamps
            TCP Option - No-Operation (NOP)
                Kind: No-Operation (1)
            TCP Option - No-Operation (NOP)
                Kind: No-Operation (1)
            TCP Option - Timestamps: TSval 1813150423, TSecr 174674397
                Kind: Time Stamp Option (8)
                Length: 10
                Timestamp value: 1813150423
                Timestamp echo reply: 174674397
        [SEQ/ACK analysis]
            [This is an ACK to the segment in frame: 9]
            [The RTT to ACK the segment was: 0.050268000 seconds]
            [iRTT: 0.049355000 seconds]


@Lukasa I do not know which step is most important，so i copy all..it is so long... hope  it is useful,Thanks~ 

Sadly I think I need the TLS handshake broken out, which means I need the raw PCAP file. Can you provide that for me?

That is all right～～ I will try my best to collect useful data ～aha @Lukasa 

I have the same problem

me too

can somebody fix it asap? and submit pull request.

If anyone that is experiencing this issue could provide a raw PCAP file as @Lukasa has mentioned it would help immensely with debugging this issue.

I also meet this problem. when i use proxy by http that ok. then I try use socks5，"SSLError: SOCKSHTTPSConnectionPool", I am happy to continue to provide information to help. 

Hey, Everybody. I modified code as below and it worked! but I dont know why!
proxies = {'https': "socks5h://127.0.0.1:1080"}
@Lukasa @iacky @imkean @Lovelcp @boostsup 

Yeah!
Thanks to @ArthurRyan 
proxies = {'https': "socks5h://127.0.0.1:1080"} is really worked! and I also dont know why!

Same issue here but merely on some sites, others worked well without adding h 
Perhaps there were some DNS poison from my ISP.

Interesting. It seems like we have a solution of sorts and no one has provided a PCAP. I'm closing this as stale. If anyone wants to provide the necessary information, we can reopen this.

Thanks，it's really worked. @ArthurRyan 

@ArthurRyan Thanks，it's worked for me too.
@ArthurRyan the difference between socks5h and socks5 based on [https://github.com/urllib3/urllib3/pull/1036](url) is:

> the proxy string, socks5h:// and socks4a:// mean that the hostname is
to be resolved by the socks server. socks5:// and socks4:// mean the
hostname is to be resolved locally.

 

> Hey, Everybody. I modified code as below and it worked! but I dont know why!
> proxies = {'https': "socks5h://127.0.0.1:1080"}
> @Lukasa @iacky @imkean @Lovelcp @boostsup

Thanks you very much, this problem has plagued me for several days.