Answers.Body: <p>Sorry - we've not seen this (yet) - best to post an issue on our GitHub queue: <a href="https://github.com/iATSPayments/com.iatspayments.civicrm" rel="nofollow">https://github.com/iATSPayments/com.iatspayments.civicrm</a> - so that both Alan and myself as well as iATS staff sees this. </p>
  
  <p>Perhaps the automatic ones are not run as -u your webuser but as another user - different env - different drush? </p>
  
  <p>My favourite/most stable/like clockwork (no drift) way to run the recurring contributions job is:</p>
  
  <p>to switch it OFF in the scheduled jobs GUI</p>
  
  <p>and then to:</p>
  
  <blockquote>
    <h1>apache crontab for drupal/civicrm:</h1>
    
    <p>0 2 * * * /usr/bin/php /usr/local/bin/drush.php --root='/var/www/platform/site/' --uri='<a href="https://site.org" rel="nofollow">https://site.org</a>' -u 1 civicrm-api job.iatsrecurringcontributions auth=0 -y</p>
    
    <h1>and then run the scheduled jobs that are switched ON:</h1>
    
    <p>3 * * * * /usr/bin/php /usr/local/bin/drush.php --root='/var/www/platform/site/' --uri='<a href="https://site.org" rel="nofollow">https://site.org</a>' -u 1 civicrm-api job.execute auth=0 -y</p>
  </blockquote>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-08-25T19:04:03.110Z
Answers.LastActivityDate: 2016-08-31T16:49:26.700Z
Answers.LastEditDate: 2016-08-31T16:49:26.700Z
Answers.UserDisplayName: KarinG - Semper IT
Body: <p>We are setup with iATS for credit/debit card and ACH transactions and are in the last stages of testing.  One time card and ACH contributions are working.  For the sake of testing, we are doing daily recurring contributions to make sure the mechanism works.  We haven't yet tested recurring ACH.  Recurring credit card transactions are going through, but with mixed results.</p>
  
  <p><strong>Issue:</strong> Within the last week, we've gotten intermittent errors during the recurring contribution scheduled job that prevents the contribution from being marked <code>Complete</code> in Civi.  The error is "Error Fetching HTTP Headers."</p>
  
  <p><strong>Symptoms:</strong> Two transactions with through perfectly (Aug 17 12:00am; Aug 23 12:00am) and emailed automatic receipts.  The other transactions, however, are processing (visible in iATS' journal and with my bank), but marked <code>Pending (Incomplete Transaction)</code> in Civi.  The Civi source reads: <code>iATS Payments Recurring Contribution (id=2) Unexpected Server Error, please see your logs</code>. Emails for these Pending transactions did not send.</p>
  
  <p><strong>Details:</strong></p>
  
  <p>In the Job Log for <code>iatsrecurringcontributions</code>:
  The job last night started at 2016-08-24 00:00:04 and then finished at 2016-08-24 00:01:07 with these details:</p>
  
  <blockquote>
    <p>Parameters parsed (and passed to API method): 
    a:1:{s:7:"version";i:3;}</p>
    
    <p>Full message:  Finished execution of iATS Payments Recurring
    Contributions with result: Success (1 contribution record(s) were
    processed.</p>
    
    <p>Failed to process recurring contribution id 2: Unexpected Server Error, please see your logs
    Created activity record for contact id 203)</p>
  </blockquote>
  
  <p>In looking at the Drupal logs, I have two relevant records for last night's Pending (Incomplete Transaction), an error and a notice, both from hostname 127.0.0.1.</p>
  
  <p><strong><em>The error:</em></strong></p>
  
  <pre><code>SoapFault: SoapFault Object (
  [message:protected] =&gt; Error Fetching http headers
  [...a long list of arrays detailing the transaction, our iATS information, API calls and drush commands]
  [previous:Exception:private] =&gt; 
  [faultstring] =&gt; Error Fetching http headers
  [faultcode] =&gt; HTTP
  )
  </code></pre>
  
  <p><strong><em>The notice:</em></strong></p>
  
  <pre><code>Raw Response:
  HEADER:
  BODY:
  BODYEND:
  </code></pre>
  
  <p><strong>Attempted Resolution:</strong> From initial searches in Stackexchange and Google at large, it might be a server setting, perhaps?  After a couple days of trouble initially, I increased two settings in my /etc/my.cnf file just to test and then restarted httpd and nginx:</p>
  
  <pre><code>max_allowed_packet = 128M (was 16M)
  wait_timeout = 300 (was 60)
  </code></pre>
  
  <p>Since I still had the issue last night, it must be something else.  <strong>Any ideas on how to resolve the "Error Fetching http headers"</strong>?</p>
  
  <p>Civi 4.6.14 (will be updating to 4.6.20 before go-live); Drupal 7.44; iATS Payments extension 1.5.3; CentOS Linux 7.2.1511; Plesk 12.5.3; PHP 5.6.24 on website; PHP 5.4.16 on command line; nginx 1.11.1; Apache 2.4.6</p>
  
Tags: <civicontribute><recurring-contributions><scheduled-job><iats>
Title: Error Fetching HTTP headers - iATS Recurring contribution
ThreadText: # Error Fetching HTTP headers - iATS Recurring contribution
  
  (Asked by: username_0 on 2016-08-24)
  
  We are setup with iATS for credit/debit card and ACH transactions and are in the last stages of testing.  One time card and ACH contributions are working.  For the sake of testing, we are doing daily recurring contributions to make sure the mechanism works.  We haven't yet tested recurring ACH.  Recurring credit card transactions are going through, but with mixed results.
  Issue: Within the last week, we've gotten intermittent errors during the recurring contribution scheduled job that prevents the contribution from being marked Complete in Civi.  The error is "Error Fetching HTTP Headers."
  Symptoms: Two transactions with through perfectly (Aug 17 12:00am; Aug 23 12:00am) and emailed automatic receipts.  The other transactions, however, are processing (visible in iATS' journal and with my bank), but marked Pending (Incomplete Transaction) in Civi.  The Civi source reads: iATS Payments Recurring Contribution (id=2) Unexpected Server Error, please see your logs. Emails for these Pending transactions did not send.
  Details:
  In the Job Log for iatsrecurringcontributions:
  The job last night started at 2016-08-24 00:00:04 and then finished at 2016-08-24 00:01:07 with these details:
  
  Parameters parsed (and passed to API method): 
    a:1:{s:7:"version";i:3;}
  Full message:  Finished execution of iATS Payments Recurring
    Contributions with result: Success (1 contribution record(s) were
    processed.
  Failed to process recurring contribution id 2: Unexpected Server Error, please see your logs
    Created activity record for contact id 203)
  
  In looking at the Drupal logs, I have two relevant records for last night's Pending (Incomplete Transaction), an error and a notice, both from hostname 127.0.0.1.
  The error:
  SoapFault: SoapFault Object (
  [message:protected] => Error Fetching http headers
  [...a long list of arrays detailing the transaction, our iATS information, API calls and drush commands]
  [previous:Exception:private] => 
  [faultstring] => Error Fetching http headers
  [faultcode] => HTTP
  )
  
  The notice:
  Raw Response:
  HEADER:
  BODY:
  BODYEND:
  
  Attempted Resolution: From initial searches in Stackexchange and Google at large, it might be a server setting, perhaps?  After a couple days of trouble initially, I increased two settings in my /etc/my.cnf file just to test and then restarted httpd and nginx:
  max_allowed_packet = 128M (was 16M)
  wait_timeout = 300 (was 60)
  
  Since I still had the issue last night, it must be something else.  Any ideas on how to resolve the "Error Fetching http headers"?
  Civi 4.6.14 (will be updating to 4.6.20 before go-live); Drupal 7.44; iATS Payments extension 1.5.3; CentOS Linux 7.2.1511; Plesk 12.5.3; PHP 5.6.24 on website; PHP 5.4.16 on command line; nginx 1.11.1; Apache 2.4.6
  
  **Tags:** civicontribute, recurring-contributions, scheduled-job, iats
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2016-08-25. Score: 2 | Accepted answer
  
  Sorry - we've not seen this (yet) - best to post an issue on our GitHub queue: <https://github.com/iATSPayments/com.iatspayments.civicrm> - so that both Alan and myself as well as iATS staff sees this.
  
  Perhaps the automatic ones are not run as -u your webuser but as another user - different env - different drush?
  
  My favourite/most stable/like clockwork (no drift) way to run the recurring contributions job is:
  
  to switch it OFF in the scheduled jobs GUI
  
  and then to:
  
  > # apache crontab for drupal/civicrm:
  >
  > 0 2 \* \* \* /usr/bin/php /usr/local/bin/drush.php --root='/var/www/platform/site/' --uri='<https://site.org>' -u 1 civicrm-api job.iatsrecurringcontributions auth=0 -y
  >
  > # and then run the scheduled jobs that are switched ON:
  >
  > 3 \* \* \* \* /usr/bin/php /usr/local/bin/drush.php --root='/var/www/platform/site/' --uri='<https://site.org>' -u 1 civicrm-api job.execute auth=0 -y
  
  
  ---
  
  