ad-m / python-anticaptcha

Client library for solve captchas with Anticaptcha.com support.
http://python-anticaptcha.readthedocs.io/en/latest/
MIT License
223 stars 51 forks source link

SSLError: HTTPSConnectionPool(host='api.anti-captcha.com', port=443) #12

Closed MislavSag closed 6 years ago

MislavSag commented 6 years ago

After using Anticaptcha services for some time, I got the following error:


  task 21 failed - "SSLError: HTTPSConnectionPool(host='api.anti-captcha.com', port=443): Max retries exceeded with url: /getTaskResult (Caused by SSLError(SSLError("bad handshake: SysCallError(-1, 'Unexpected EOF')",),))

Detailed traceback: 
  File "C:\Users\msagovac\AppData\Local\CONTIN~2\ANACON~1\lib\site-packages\python_anticaptcha\base.py", line 39, in join
    while not self.check_is_ready():
  File "C:\Users\msagovac\AppData\Local\CONTIN~2\ANACON~1\lib\site-packages\python_anticaptcha\base.py", line 24, in check_is_ready
    self._update()
  File "C:\Users\msagovac\AppData\Local\CONTIN~2\ANACON~1\lib\site-packages\python_anticaptcha\base.py", line 21, in _update
    self._last_result = self.client.getTaskResult(self.task_id)
  File "C:\Users\msagovac\AppData\Local\CONTIN~2\ANACON~1\lib\site-packages\python_anticaptcha\base.py", line 89, in getTaskResult
    response = self.session.post(urljoin(self.base_url, self.TASK_RESULT_URL), json=request).json()
  File "C:\Users\m

Do you know what could be a problem?

ad-m commented 6 years ago

Hello,

Does the problem occur constantly or sporadically? Can you use the library once?

I did not come across this problem before, but I have a few suggestions.

1 / Verify that you do not create multiple instances of "AnticaptchaClient" class. The "AnticaptchaClient" class provides a session that allows you to maintain an HTTPS connection. In your case you have a problem with a handshake, which occurs, among others when making a new HTTPS connection, which should not happen very offen.

2 / If you have safe connection, you can turn off HTTPS:

client = AnticaptchaClient(api_key, use_ssl=False)

3/ This message is related to the inability to establish a connection through the library I chose. In the network there are many solutions to problems related to the library, as well as the one called by you. This is a problem specific to your environment. See at following pages for sollution:

Let me know if you've managed to solve the problem. If not - I will try to help you in other ways, for example via TeamViewer / Telegram. I really want you to help use my library.

MislavSag commented 6 years ago

Hi, thanks for detailed answer.

I am using selenium grid through docker. I have 4 nodes and every node use Anticaptchaclient illiterately in parallel. The error appears after cca 10.500 iterations. It appears for the first time yesterday. I have started the same code 10 minutes ago. Till now there is no error. I will see in few hours if error will occur.

After that, I will try to remove s from htpps, to see if that helps.

ad-m commented 6 years ago

These could be one-off problems on the Anticaptcha.com site.

ad-m commented 6 years ago

@MislavSag , do you have a result or comments?

MislavSag commented 6 years ago

I have tried again and it's working now. I think it can be closed.

Thanks