Using wp-cron in backpress – problems with wp_remote_post, fsockopen error

I’m working on a BackPress project where I need to schedule cron tasks. The cron_uri for BP is stored in options, rather than hardcoded as it is in WP core. I’ve tried setting the option to mysite.com/wp-cron.php (where wp-cron.php is essentially a copy of the same file from WordPress, modified to include only the relevant files to my purposes.

The problem is, when this address is called from the wp_cron() function, it returns the following fsockopen error:

Read More

fsockopen() [function.fsockopen]:
unable to connect to :80
(php_network_getaddresses: getaddrinfo
failed: Name or service not known) in
/home/gad/public_html/backpress/class.wp-http.php
on line 646

I can open the cron uri directly using fsockopen and it doesn’t return any error. As best as I can figure out, the problem is somewhere in the HTTP Transport API, maybe in the WP_http->request() function, where BackPress checks the cron_uri against the application_uri option, to see if the request is a local one or not (and possibly treat the different requests differently?).

Strangely enough, if I just set the cron_uri to my home url, it works fine – I can intercept the request based on the GET request and include wp-cron.php before outputting anything.

I’m mainly confused as to why wp_remote_post doesn’t seem to work with this file, as it seems to work with most everything else I’ve tried to do with it.

Related posts

Leave a Reply

1 comment

  1. From quick look at source mechanics seem very similar, my first suggestion for WP would be to try and bump HTTP transport to curl (I do it with plugin in WP so no idea about specific code).

    curl seems to be considerably more robust for corner cases and it’s not WP’s first choice.