Forum

Thread tagged as: Problem, Runway, MailChimp

Mailchimp scheduled task failing

We're trying out the MailChimp App on an existing Runway site (diagnostics below). The lists/subscribers/campaigns have all come across, so the API key works. We moved onto the 'Webhooks' bit afterwards, found the tab/page and clicked Sync as described in the documentation for Installation of the MailChimp app. A few days later, I've looked in the Scheduled Tasks list and see hourly FAILED lines for the 'App' perch_mailchimp for the 'task' of import_data and a 'result' of unknown. Other scheduled tasks (pruning logs and backups) are working fine.

I wonder if we are supposed to do something with the webhooks URL (with the secret= parameter)? Should that be in the CRON list at regular intervals perhaps?

Is there any way of getting more diagnostics for this, to discover what's causing the 'FAILED' messages in the Scheduled Tasks list?

Perch Runway: 3.0.6, PHP: 7.1.4, MySQL: mysqlnd 5.0.12-dev - 20150407 - $Id: b396954eeb2d1d9ed7902b8bae237b287f21ad9e $, with PDO
Server OS: Linux, cgi-fcgi
Installed apps: content (3.0.6), assets (3.0.6), categories (3.0.6), jw_activity_log (1.0.1), perch_members (1.6.1), perch_mailchimp (3.1)
App runtimes: <?php $apps_list = [ 'perch_mailchimp', 'perch_members', ];
PERCH_LOGINPATH: /perch
PERCH_PATH: /home/hamsva/public_html/perch
PERCH_CORE: /home/hamsva/public_html/perch/core
PERCH_RESFILEPATH: /home/hamsva/public_html/perch/resources
Image manipulation: GD
PHP limits: Max upload 20M, Max POST 8M, Memory: 128M, Total max file upload: 8M
F1: 0c66c2e1f82f9e0b7617b2cb8270f2c7
Resource folder writeable: Yes
DOCUMENT_ROOT: /home/hamsva/public_html
HTTP_HOST: www.hamsva.org.uk
REQUEST_URI: /perch/core/settings/diagnostics/
SCRIPT_NAME: /perch/core/settings/diagnostics/index.php
Graham Street

Graham Street 17 points

  • 4 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

Do you get any errors in your error log?

No sign of an error log anywhere in the hosting account or /perch file structure.

Rachel Andrew

Rachel Andrew 394 points
Perch Support

Then that would be a good question to ask your host. Where is the error log?

I'll re-word that ... I know where the error log should be if there was one, but there isn't one. I've additionally searched all other folders in case one appeared elsewhere for some reason.

Drew McLellan

Drew McLellan 2638 points
Perch Support

If you look in the API section of your MailChimp account, are there any errors reported there?

Thanks for the pointer. I'll get that checked next. I don't have access to the MailChimp account so I'll need to get back to the customer.

I now have access to the customer's MailChimp account. I've looked in the API section (/account/api/) and see the 'Historical API calls per day' section. This is empty. In the 'Last 24 hours of API calls' section, there is one entry. It shows a date/time for yesterday morning, my office/home IP (not web server) address, a method of 'GET /lists/.../webhooks/', format 'php', and a user-agent of 'DrewM/MailChimp-API/3.0 (github.com/drewm/mailchimp-api)'. I'm wondering if this is the result of me running the webhooks URL in my web browser yesterday?

Is there any specific place in the MailChimp account where errors might appear, or have I got the right page?

Meantime the Scheduled Tasks list continues to show hourly FAILED messages of 'perch_mailchimp' for 'import_data' and Backups continue to work fine.

If I manually run scheduled tasks with https://www.*******.org.uk/perch/core/scheduled/run.php?secret=**** I see another FAILED message added to the Tasks list. Is there any way of triggering the display of some diagnostics in that run.php that might help diagnose this further? Or any other suggestions for where to get more diagnostics?

Graham

Drew McLellan

Drew McLellan 2638 points
Perch Support

In the bottom of /perch/core/scheduled/run.php you can uncomment the PerchUtil::output_debug(); which might give you some insight.

OK, I tried that and here's the output. Can't see anything wrong or in red ...

Debug Message - Perch Runway 3.0.6
[1] SELECT * FROM perch2_pages WHERE pagePath='/perch/core/scheduled/run.php' LIMIT 1
[1] SHOW TABLES LIKE "perch2_scheduled_tasks"
[1] SELECT * FROM perch2_backup_plans WHERE planActive='1' ORDER BY planCreated ASC
[3] SELECT taskApp, taskKey, MAX(taskStartTime) AS t FROM perch2_scheduled_tasks WHERE taskApp IN ('jw_activity_log', 'perch_mailchimp', 'Backup') GROUP BY taskApp, taskKey
INSERT INTO perch2_scheduled_tasks(taskApp,taskKey,taskStartTime,taskResult,taskMessage) VALUES('perch_mailchimp','import_data','2017-06-06 13:24:09','FAILED','Task failed to complete, or is still running.')
[1] SELECT * FROM perch2_scheduled_tasks WHERE taskID='3311' LIMIT 1
[1] SELECT * FROM perch2_mailchimp_imports WHERE 1=1 ORDER BY importUpdated ASC LIMIT 1
UPDATE perch2_scheduled_tasks SET taskApp='perch_mailchimp', taskKey='import_data', taskStartTime='2017-06-06 13:24:09', taskEndTime='2017-06-06 13:24:09', taskResult='FAILED', taskMessage='Unknown.' WHERE taskID='3311'
[3] SELECT taskApp, taskKey FROM perch2_scheduled_tasks GROUP BY taskApp, taskKey
DELETE FROM perch2_scheduled_tasks WHERE taskID IN (SELECT * FROM ( SELECT taskID FROM perch2_scheduled_tasks WHERE taskApp='Backup' AND taskKey='plan_4' ORDER BY taskStartTime DESC LIMIT 10, 9999999 ) AS tmp)
DELETE FROM perch2_scheduled_tasks WHERE taskID IN (SELECT * FROM ( SELECT taskID FROM perch2_scheduled_tasks WHERE taskApp='jw_activity_log' AND taskKey='prune_actions_log' ORDER BY taskStartTime DESC LIMIT 10, 9999999 ) AS tmp)
DELETE FROM perch2_scheduled_tasks WHERE taskID IN (SELECT * FROM ( SELECT taskID FROM perch2_scheduled_tasks WHERE taskApp='perch_mailchimp' AND taskKey='import_data' ORDER BY taskStartTime DESC LIMIT 10, 9999999 ) AS tmp)
[1] OPTIMIZE TABLE perch2_scheduled_tasks

I then added PerchUtil::output_debug(); to /perch/addons/apps/perch_mailchimp/api/webhooks/index.php and got this output ...

Debug Message - Perch Runway 3.0.6
[1] SELECT * FROM perch2_pages WHERE pagePath='/perch/addons/apps/perch_mailchimp/api/webhooks/index.php' LIMIT 1
[36] SELECT DISTINCT settingID, settingValue FROM perch2_settings WHERE userID=0

I spotted a 'file_put_contents' line at the foot of perch_mailchimp/api/webhooks/index.php so uncommented it for debug as the line above suggested. A logfile was created but it is zero length.

Finally, some more info on an earlier posting ... In the 'Last 24 hours of API calls' section, there is one entry. It shows a date/time for yesterday morning, my office/home IP (not web server) address, a method of 'GET /lists/.../webhooks/', format 'php', and a user-agent of 'DrewM/MailChimp-API/3.0 (github.com/drewm/mailchimp-api)'. I now know this is caused by clicking the Sync button on the Perch 'webhooks' page, because I can recreate it.

Drew McLellan

Drew McLellan 2638 points
Perch Support

Did you get a failure entry? Not every task runs every time.

I've done some further tests, now I have access to the customer's MailChimp account. I've added myself to a list in MailChimp. I then visited Perch Runway (MailChimp area) and clicked the Sync button. Over a period of a few minutes, I see several 'good' entries in MailChimp's API call list. When the activity subsided, Perch stops telling me that the Subscriber List is updating. I can then see my name/email in the Subscriber List inside Perch. So, using the Sync button is working.

During that testing period (and in the last hour), the Perch Scheduled Task list shows another entry of FAILED for the 'perch_mailchimp' app, for the 'import_data' task. For that date/time, there is no corresponding entry (good or bad) in the list of API calls inside MailChimp.

I've checked the CRON log and it shows the scheduled task running (and the Backup APP shows as OK for the same timestamp in the Scheduled Tasks list). So, it looks to me as if the issue is the running of the 'perch_mailchimp' in the scheduled tasks. CRON is scheduled to execute 'run.php' every 15 minutes. But every hour, an OK Backup and a FAILED mailchimp task show up in the Scheduled Task list.

Are there any diagnostics I can put into the perch_mailchimp app?

I did try disabling Backup for a while in case that was interfering with it, but it made no difference (as expected).

Drew McLellan

Drew McLellan 2638 points
Perch Support

Is there data you're expecting to sync?

Yes, I just checked. The number of subscribers has changed in MailChimp, and a mailshot went out yesterday too. None of those changes are currently reflected inside the MailChimp section of Perch Runway. If I click the 'sync' button/link I would expect things would update over the coming hour or so. I can do that if you wish, but was holding off doing that as I'd like to find out why the scheduled task isn't keeping things sync'd.

Drew McLellan

Drew McLellan 2638 points
Perch Support

I don't have an immediate answer, so you should do whatever you need to do to ensure business continuity.

We're only testing the MailChimp functionality at the moment, even though the site itself has been live for quite some time. At the moment, the customer is manually adding new newsletters (links) to the site and customers subscribe to the list another way. They only recently moved to MailChimp so we're seeing if the 'add on' can provide any benefits in their site. So, we're quite happy to try/test anything to get this working and it won't affect what the end user sees.

A quick update on this. The way this customer has set up MailChimp for their list and mailings isn't quite right. So all their test mailings would have appeared publicly and the naming of things wasn't consistent either. It would have looked a bit of mess, if we'd gone public with it on their website. So, with that and because we couldn't get the automatic synchronisation working, we've currently given up trying to use the plugin on the site. We've now deleted it, but I may set up a test system to play around with things sometime in the future.