title: Airflow SSHOperator's Socket exception: Bad file descriptor
body: <p>In Airflow, I use an SSHOperator to call an API that works on some automation work. The work ran successfully and the report did generate, but Airflow returns the task failed due to the Socket exception.</p>
  <p>This error sometimes occurs, and I would like to know the reason that caused it.</p>
  <p>The error message received:</p>
  <pre><code>[2021-07-20 08:00:07,345] {ssh.py:109} INFO - Running command: curl -u &lt;user:pw&gt; &lt;URL&gt;
  [2021-07-20 08:00:07,414] {ssh.py:145} WARNING -   % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                   Dload  Upload   Total   Spent    Left  Speed
  
    0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
  [2021-07-20 08:00:08,420] {ssh.py:145} WARNING - 
    0     0    0     0    0     0      0      0 --:--:--  0:00:01 --:--:--     0
  [2021-07-20 08:00:09,421] {ssh.py:145} WARNING - 
    0     0    0     0    0     0      0      0 --:--:--  0:00:02 --:--:--     0
  [2021-07-20 08:00:10,423] {ssh.py:145} WARNING - 
    0     0    0     0    0     0      0      0 --:--:--  0:00:03 --:--:--     0
  [2021-07-20 08:00:10,615] {ssh.py:141} INFO - Report Sent Successfully.
  [2021-07-20 08:00:10,616] {transport.py:1819} ERROR - Socket exception: Bad file descriptor (9)
  [2021-07-20 08:00:10,633] {taskinstance.py:1481} ERROR - Task failed with exception
  Traceback (most recent call last):
    File &quot;/u01/airflow-venv/lib/python3.8/site-packages/airflow/providers/ssh/operators/ssh.py&quot;, line 152, in execute
      stdout.channel.close()
    File &quot;/u01/airflow-venv/lib/python3.8/site-packages/paramiko/channel.py&quot;, line 671, in close
      self.transport._send_user_message(m)
    File &quot;/u01/airflow-venv/lib/python3.8/site-packages/paramiko/transport.py&quot;, line 1863, in _send_user_message
      self._send_message(data)
    File &quot;/u01/airflow-venv/lib/python3.8/site-packages/paramiko/transport.py&quot;, line 1839, in _send_message
      self.packetizer.send_message(data)
    File &quot;/u01/airflow-venv/lib/python3.8/site-packages/paramiko/packet.py&quot;, line 431, in send_message
      self.write_all(out)
    File &quot;/u01/airflow-venv/lib/python3.8/site-packages/paramiko/packet.py&quot;, line 367, in write_all
      raise EOFError()
  EOFError
  
  During handling of the above exception, another exception occurred:
  
  Traceback (most recent call last):
    File &quot;/u01/airflow-venv/lib/python3.8/site-packages/airflow/models/taskinstance.py&quot;, line 1137, in _run_raw_task
      self._prepare_and_execute_task_with_callbacks(context, task)
    File &quot;/u01/airflow-venv/lib/python3.8/site-packages/airflow/models/taskinstance.py&quot;, line 1311, in _prepare_and_execute_task_with_callbacks
      result = self._execute_task(context, task_copy)
    File &quot;/u01/airflow-venv/lib/python3.8/site-packages/airflow/models/taskinstance.py&quot;, line 1336, in _execute_task
      result = task_copy.execute(context=context)
    File &quot;/u01/airflow-venv/lib/python3.8/site-packages/airflow/providers/ssh/operators/ssh.py&quot;, line 171, in execute
      raise AirflowException(f&quot;SSH operator error: {str(e)}&quot;)
  airflow.exceptions.AirflowException: SSH operator error: 
  </code></pre>
  <p>--- edit ---</p>
  <pre class="lang-py prettyprint-override"><code>generate_report = SSHOperator(
      task_id = 'generate_report',
      ssh_conn_id = 'ssh_123',
      command = curl -u user:password &quot;http://localhost:1234/path/to/trigger/report_creation_API?async=false&quot;,
  )
  </code></pre>