Articles in this section
Category / Section

Authentication keeps expiring or Delay not working

3 mins read
Updated:

Sometimes, the authentication token on your website might expire, causing the authentication to fail on your website. This can happen due to various reasons, such as cron jobs not running on time, the website blocking the wp_remote_post() function, etc.

Same goes with the Delay module, as it is also depend on the WordPress Cron jobs.

If you’re facing the authentication token expiration issue or delay not working issue multiple times, here’s how you can troubleshoot and fix the issue -

1 ) Cron jobs on your website are not executing on time

Cron jobs are scheduled tasks that run at specific intervals. They are used to renew the authentication token on your website. If the cron jobs on your website are not executing on time, the authentication token will expire, and you will need to re-authenticate your website with Flowmattic.

To fix this issue, you can use a plugin like WP Crontrol to check if the cron jobs on your website are running correctly. If you find that the cron jobs are not running on time, you can try disabling and re-enabling the cron jobs to see if that fixes the issue.

Another and more reliable way to fix this issue is to set up a server-side cron job to run the wp-cron.php file on your website at regular intervals. This will ensure that the cron jobs on your website are running on time and that the authentication token does not expire.

Before setting up a server-side cron job, make sure the WordPress cron is disabled on your website. You can disable the WordPress cron by adding the following line of code to your wp-config.php file -

Setting Cron using Cloudflare

define( 'DISABLE_WP_CRON', true ); 

If you’re using Cloudflare to manage your website, here’s how you can set the cron job on Cloudflare -

  1. Log in to your Cloudflare account.
  2. Go to the Workers tab.
  3. Click on Create a Worker ( Click on Hello World button )
  4. Click Deploy and on the next screen, click “Edit Code”
  5. Remove the existing code from worker.js file
  6. Copy and paste the following code into the Worker editor and click Deploy button
addEventListener('scheduled', event => {
 event.waitUntil(handleScheduled(event.scheduledTime))
})

async function handleScheduled(scheduledDate) {
 const response = await fetch('https://yourwebsite.com/wp-cron.php?doing_wp_cron')
 const text = await response.text()
 console.log(text)
} 
  1. Replace ‘https://yourwebsite.com/wp-cron.php’ with the URL of your website’s wp-cron.php file.
  2. Click on Save and Deploy.
  3. Now, go to your worker and switch to the “Settings” tab.
  4. Click on “Trigger Events” on the settings page.
  5. Click on “Add Trigger Event” and select “Cron Triggers” from the available options.
  6. Set the schedule for the cron job to run every minute or every 5 minutes maximum.
  7. Click on the “Add” button at the bottom of the page to save the changes.
  8. Now, your server-side cron job is set up, and the cron jobs on your website will run on time.

If you’re not using Cloudflare, you can set up a server-side cron job using cPanel or any other hosting control panel that your hosting provider offers. You can also contact your hosting provider for help in setting up a server-side cron job on your website.

2 ) Website is blocking the wp_remote_post() function

Some websites have security measures in place that block the wp_remote_post() function, which is used to renew the authentication token on your website. If your website is blocking the wp_remote_post() function, the authentication token will expire, and you will need to re-authenticate your website with Flowmattic.

If you’re using a security plugin on your website, you can try disabling the plugin temporarily to see if that fixes the issue. If disabling the security plugin fixes the issue, you can contact the plugin developer to see if they can provide a solution to whitelist the wp_remote_post() function on your website.

Was this article useful?
Like
Dislike
Help us improve this page
Please provide feedback or comments
Access denied
Access denied