I have a Wordpress instance on my development box with the WP REST API plugin installed. I am attempting to create my own plugin to use wp_remote_get() to communicate with my own custom PHP application on the same box.
I have set up my hosts file with the name of the custom PHP application. I have written a simple cURL request which is able to connect.
$curl = curl_init();
curl_setopt( $curl, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt( $curl, CURLOPT_HEADER, 1 );
curl_setopt( $curl, CURLOPT_POST, false );
curl_setopt( $curl, CURLOPT_URL, "http://foo.richard.local/notify/$post_id" );
$curlData = curl_exec( $curl );
However when I try to use wp_remote_get() i'm getting a WP_Error
$response = wp_remote_get(
"http://foo.richard.local/notify/$post_id"
);
if ( is_wp_error( $response ) ) {
$errorResponse = $response->get_error_message();
}
Operation timed out after 5514 milliseconds with 0 bytes received
I have increased the timeout, but I'm still getting the same response.
I have installed the excellent Core Control plugin to verify the HTTP configuration settings.
The https_local_ssl_verify and https_ssl_verify filters have been set in my plugin.
The Core Control External HTTP Access Logger looks like this:
foo.richard.local
, then start looking at how that's possible? How is the domain name being mapped to an IP address, and what is that IP address? Then consider that while you're able to connect, maybe the web server itself is unaware of that information. For example, if you're running a Linux VM, consider editing/etc/hosts
.