The Inner Workings of Jetpack

I have multiple sites using Jetpack services at various levels from the Free through the Premium service.    Some sites are playing nicely with the Jetpack services at WordPress.com but not all sites.  This post is my notes repository for debugging this issue.

Jetpack issues

Various sites on my server are working poorly with Jetpack.  Some have few issues.  Others are not running MOST of the Jetpack services.    There is definitely an underlying problem that impacts some sites more than others.

Cannot enable Google Analytics or other Professional Plan options

On the WordPress.StoreLocatorPlus.com site I cannot get Jetpack to talk to my server for the Professional services.  I cannot enable the Google Analytics or other Professional options.    Jetpack can see their API talking to my server but it is not completing all requests.    I can see the requests coming into my server and nothing is coming up in the debug logs (enabling WP_DEBUG).

“Jetpack Premium plan is powering up”

On this site (Lance.Bio) I always see that the Premium plan is powering up.   I click on the monetize your site with ads or enable Premium video player links and always get a generic “Error updating settings” message.

Jetpack Premium plan is always powering up!

 

Jetpack Error updating settings. (Error) — doesn’t provide much useful info.

Spam protection “flickers”

On the Lance.bio site the Spam Protection box under security constantly checks that spam protection is in place, reports that it is and immediately checks again causing a status “flicker”.

Testing Jetpack communication

The public API at WordPress.com will give you some meta about a site and what is accessible.    This API URL is the “glue” that hooks Jetpack up to your website and moves meta data back-and-forth between the Jetpack plugin and the WordPress.com engine.

https://public-api.wordpress.com/rest/v1/sites/<your-wordpress-hostname>

Your server access logs will also give you some insight into the Jetpack communication stack:

Jetpack uses XML RPC which means all communication must be performed via a POST transaction through the web server.

Proxy services – allowing XML-RPC

You will need to make sure your proxy service does not block xmlrpc.php calls.   Services that are WordPress-aware, such as Sucuri, will have specific settings for allowing calls to xmlrpc.php.

This is not the issue with my servers as I can see in the access logs that Jetpack is talking to my server on xmlrpc.php.

Turning on WordPress debugging

Time to see if one of the plugins or other pieces of PHP code is breaking the site.   I go to my site’s wp-config.php and turn on the WP_DEBUG log.

I execute the public API call against my site and check the debug.log file in my wp-content directory.    I’m not seeing a debug.log file in that directory which means nothing is breaking on either the WPSLP site or Lance.bio site.    I can test this by adding a piece of broken PHP code to either site in one of the plugins or the main theme functions.php and see the file is created; I know the logging is working and therefore can assume that the PHP code is fine.   The problem is elsewhere.

Checking server log files

I run nginx on my server as I do not need the excess overhead provided by Apache or other web servers.    Since I am the system admin for the entire server I can find my log files in the nginx configured path, typically /var/log/nginx/<sitename>_error.log and <sitename>_access.log.

I can see the requests coming in to the access log.   Everything looks normal.

However the error log file shows something interesting.

Investigating FastCGI The buffer you checked in was not checked out

The first article that seems to have some useful tech info was found on a GitHub Gist.

Let’s check our maximum and average request sizes on the lance.bio site.

This tells me that the average server response is 1,056 bytes with a maximum response of 65,156 bytes.

My server is configured to use a default page size of 4k (4,096) bytes.

Nginx defaults for FastCGI is to have eight (8) 4k buffers for 32k total of FastCGI buffering.

My average response is 1,056 bytes so it will use 1 of the 8 buffers available, no problem.  But what happens with a larger response and are those larger responses images (likely) or actual FastCGI responses?

The above awk command reads the ENTIRE access log and adds up the response size for anything with .php in the request that returned a 200 status code (field 9 = the status code, field 7 = the URL , field 10 = size of request).

That exercise was great for checking to make sure my configured buffers are large enough, which they are. If they were not I’d be seeing “upstream response is buffered to a temporary file” warnings in my error log for the site and I’m not.

All of this checks out.

Jetpack synce-queue

Turns out the error message is coming directly from the Jetpack plugin.    The Jetpack Jetpack_Sync_Queue class it barfing because something is out of sync.

Turns out this error message is coming directly from Jetpack:

The validate_checkout() method is only called from the Jetpack_Sync_Queue class in two places:

  • the checking() method
  • the close() method

One of the call stacks that triggers the error:

 

Looks like the folks at Jetpack are going to have to help uncover this issue.

Leave a Reply

%d bloggers like this: