python - send requests to twitter with `requests` : OpenSSL.SSL.SysCallError: (104, 'Connection reset by peer') -


i'm using python package requests send requests https://mobile.twitter.com/username/following.

at first, encounter exception : requests.exceptions.sslerror: [errno 8] _ssl.c:504: eof occurred in violation of protocol. solve that, follow solution write ssladapter specify protocol_tlsv1.

after that, encounter exception : requests.exceptions.sslerror: [errno bad handshake] (-1, 'unexpected eof’). and, found this, send request , receive data in same process.

and then, use requests send requests https://api.twitter.com/1.1/friends/ids.json. second exception gone(still didn't understand why). encounter third exception : openssl.ssl.syscallerror: (104, 'connection reset peer'). found this in so. , add time.sleep(10) before send requests. third exception still happen.

so second , third exception still happen. maybe response content big read? or it's problem of twitter server(some solutions said ).

the code send requests https://mobile.twitter.com/username/followers in here

and code send requests twitter rest api followers/ids in here

this traceback second exception:

    traceback (most recent call last):       file "gen_friendship.py", line 218, in <module>         start(sed_login, max_depth)       file "gen_friendship.py", line 201, in start         get_followers(node)       file "gen_friendship.py", line 131, in get_followers         response = retrieve(followers_url % name)       file "gen_friendship.py", line 33, in retrieve         response = requester.get(url)       file "/usr/local/lib/python2.7/dist-packages/requests/sessions.py", line 476, in         return self.request('get', url, **kwargs)       file "/usr/local/lib/python2.7/dist-packages/requests/sessions.py", line 464, in request         resp = self.send(prep, **send_kwargs)       file "/usr/local/lib/python2.7/dist-packages/requests/sessions.py", line 576, in send         r = adapter.send(request, **kwargs)       file "/usr/local/lib/python2.7/dist-packages/requests/adapters.py", line 431, in send         raise sslerror(e, request=request)     requests.exceptions.sslerror: [errno bad handshake] (-1, 'unexpected eof') 

this traceback third exception:

    traceback (most recent call last):       file "gen_friendship_with_i.py", line 283, in <module>         start(sed_login, max_depth)       file "gen_friendship_with_i.py", line 266, in start         get_followers(node)       file "gen_friendship_with_i.py", line 150, in get_followers         response = retrieve(followers_url, params)       file "gen_friendship_with_i.py", line 72, in retrieve         response = requester.get(url, params = params, headers = headers)       file "/usr/lib/python2.6/site-packages/requests/sessions.py", line 476, in         return self.request('get', url, **kwargs)       file "/usr/lib/python2.6/site-packages/requests/sessions.py", line 464, in request         resp = self.send(prep, **send_kwargs)       file "/usr/lib/python2.6/site-packages/requests/sessions.py", line 576, in send         r = adapter.send(request, **kwargs)       file "/usr/lib/python2.6/site-packages/requests/adapters.py", line 370, in send         timeout=timeout       file "/usr/lib/python2.6/site-packages/requests/packages/urllib3/connectionpool.py", line 544, in urlopen body=body, headers=headers)       file "/usr/lib/python2.6/site-packages/requests/packages/urllib3/connectionpool.py", line 374, in _make_request         httplib_response = conn.getresponse()       file "/usr/lib64/python2.6/httplib.py", line 990, in getresponse response.begin()       file "/usr/lib64/python2.6/httplib.py", line 391, in begin version, status, reason = self._read_status()       file "/usr/lib64/python2.6/httplib.py", line 349, in _read_status         line = self.fp.readline()       file "/usr/lib64/python2.6/socket.py", line 433, in readline         data = recv(1)       file "/usr/lib/python2.6/site-packages/requests/packages/urllib3/contrib/pyopenssl.py", line 188, in recv         data = self.connection.recv(*args, **kwargs)     openssl.ssl.syscallerror: (104, 'connection reset peer') 


Popular posts from this blog