OSDir


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

what is error[111] and how to deal with it on sending the email notification?


#############


from airflow import DAG
from airflow.operators.bash_operator import BashOperator
from airflow.operators.python_operator import PythonOperator
from airflow.operators.email_operator import EmailOperator
from airflow.utils.email import send_email_smtp
import datetime as dt




default_args = {
    'owner': 'arflow',
    'depends_on_past': False,
    'start_date': dt.datetime(2018, 10, 30),
    'email':['****@gmail.com'],
    'email_on_failure': True,
    'email_on_retry': False,
    #'retries': 1,
    #'retry_delay': timedelta(minutes=5),
}

dag =  DAG('Raja's Airflow',
         default_args=default_args,
         schedule_interval='0 3 * * *') 

notify_email = EmailOperator(task_id='email',to=['****@gmail.com'],subject="HI",html_content="raw content #2",dag=dag)

t1 = BashOperator(task_id='load_data',
                                bash_command='python3 /usr/share/airflow/documents/scripts/Airflow-Testing/arfotest.py',email_on_failure = notify_email,dag=dag)

t1


###########
Content of .cfg file
smtp_host = Smtp.live.com
smtp_starttls = True
smtp_ssl = False
smtp_user = ***
smtp_password= ****
smtp_port = 587
smtp_mail_from=***(same as stmp_user)

##################

This is the error, I'm getting it

[2018-11-01 11:18:56,405] {models.py:1769} ERROR - [Errno 111] Connection refused
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/airflow/models.py", line 1766, in handle_failure
    self.email_alert(error, is_retry=False)
  File "/usr/local/lib/python2.7/dist-packages/airflow/models.py", line 1945, in email_alert
    send_email(task.email, title, body)
  File "/usr/local/lib/python2.7/dist-packages/airflow/utils/email.py", line 53, in send_email
    mime_subtype=mime_subtype, mime_charset=mime_charset, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/airflow/utils/email.py", line 99, in send_email_smtp
    send_MIME_email(SMTP_MAIL_FROM, recipients, msg, dryrun)
  File "/usr/local/lib/python2.7/dist-packages/airflow/utils/email.py", line 119, in send_MIME_email
    s = smtplib.SMTP_SSL(SMTP_HOST, SMTP_PORT) if SMTP_SSL else smtplib.SMTP(SMTP_HOST, SMTP_PORT)
  File "/usr/lib/python2.7/smtplib.py", line 256, in __init__
    (code, msg) = self.connect(host, port)
  File "/usr/lib/python2.7/smtplib.py", line 317, in connect
    self.sock = self._get_socket(host, port, self.timeout)
  File "/usr/lib/python2.7/smtplib.py", line 292, in _get_socket
    return socket.create_connection((host, port), timeout)
  File "/usr/lib/python2.7/socket.py", line 575, in create_connection
    raise err
error: [Errno 111] Connection refused