title: TimeoutError: [WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time Email-Listener
body: <p>I'm trying to create a Python code for automatically listen any incoming email then download attachment of that email. I found <a href="https://pypi.org/project/email-listener/" rel="nofollow noreferrer">Email-Listener</a> library and practice the documentation. I'm using the exact code from the documentation. This is the code:</p>
  <pre><code>import email_listener
  
  # Set your email, password, what folder you want to listen to, and where to save attachments
  email = &quot;example@gmail.com&quot;
  app_password = &quot;password&quot;
  folder = &quot;Inbox&quot;
  attachment_dir = &quot;/path/to/attachments&quot;
  el = email_listener.EmailListener(email, app_password, folder, attachment_dir)
  
  # Log into the IMAP server
  el.login()
  
  # Get the emails currently unread in the inbox
  messages = el.scrape()
  print(messages)
  
  # Start listening to the inbox and timeout after an hour
  timeout = 60
  el.listen(timeout)
  </code></pre>
  <p>Well it works, when program running it will listen and download any attachment from unread email, either already exist on inbox or not. But after about 15+ minutes the program will stopped and display this error message:</p>
  <pre><code>Traceback (most recent call last):
    File &quot;app.py&quot;, line 20, in &lt;module&gt;
      el.listen(timeout)
    File &quot;D:\PreProject\email_auto\emailauto_env\lib\site-packages\email_listener\__init__.py&quot;, line 333, in listen
      self.__idle(process_func=process_func, **kwargs)
    File &quot;D:\PreProject\email_auto\emailauto_env\lib\site-packages\email_listener\__init__.py&quot;, line 385, in __idle
      self.server.idle_done()
    File &quot;D:\PreProject\email_auto\emailauto_env\lib\site-packages\imapclient\imapclient.py&quot;, line 175, in wrapper
      return func(client, *args, **kwargs)
    File &quot;D:\PreProject\email_auto\emailauto_env\lib\site-packages\imapclient\imapclient.py&quot;, line 975, in idle_done
      return self._consume_until_tagged_response(self._idle_tag, &quot;IDLE&quot;)
    File &quot;D:\PreProject\email_auto\emailauto_env\lib\site-packages\imapclient\imapclient.py&quot;, line 1596, in _consume_until_tagged_response
      line = self._imap._get_response()
    File &quot;c:\users\0974\appdata\local\programs\python\python37\lib\imaplib.py&quot;, line 1047, in _get_response
      resp = self._get_line()
    File &quot;c:\users\0974\appdata\local\programs\python\python37\lib\imaplib.py&quot;, line 1149, in _get_line
      line = self.readline()
    File &quot;D:\PreProject\email_auto\emailauto_env\lib\site-packages\imapclient\tls.py&quot;, line 59, in readline
      return self.file.readline()
    File &quot;c:\users\0974\appdata\local\programs\python\python37\lib\socket.py&quot;, line 589, in readinto
      return self._sock.recv_into(b)
    File &quot;c:\users\0974\appdata\local\programs\python\python37\lib\ssl.py&quot;, line 1071, in recv_into
      return self.read(nbytes, buffer)
    File &quot;c:\users\0974\appdata\local\programs\python\python37\lib\ssl.py&quot;, line 929, in read
      return self._sslobj.read(len, buffer)
  TimeoutError: [WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond
  </code></pre>
  <p>Is there any solutions? And I don't mind if the solutions use other methods, like not using <code>Email-Listener</code> library</p>