admin管理员组文章数量:1323150
On my website I use wp_remote_get to fetch data from mydomain/wp-json/wp/v2/pages/75
When I run it on my localhost it works fine, but after sending to production server (mydomain) suddenly I’m getting error: ‘cURL error 28: Operation timed out after 5000 milliseconds with 0 bytes received’ + VPS starts acting crazy (100% cpu usage and memory).
It can’t retrieve data from the same domain. When I changed url to some random REST mockup it is working again.
How can I get data from WP REST on the same domain??
(VPS info: debian 9, php 7.3, curl 7.52.1 and latest wordpress 5.2.2)
Thanks in advance!
On my website I use wp_remote_get to fetch data from mydomain/wp-json/wp/v2/pages/75
When I run it on my localhost it works fine, but after sending to production server (mydomain) suddenly I’m getting error: ‘cURL error 28: Operation timed out after 5000 milliseconds with 0 bytes received’ + VPS starts acting crazy (100% cpu usage and memory).
It can’t retrieve data from the same domain. When I changed url to some random REST mockup it is working again.
How can I get data from WP REST on the same domain??
(VPS info: debian 9, php 7.3, curl 7.52.1 and latest wordpress 5.2.2)
Thanks in advance!
Share Improve this question asked Jun 24, 2019 at 19:11 SebaSeba 411 silver badge3 bronze badges1 Answer
Reset to default 7By default, WordPress set the timeout value for cURL in wp-includes/class-wp-http-curl.php to 5 seconds and the same value is also set to HTTP requests in wp-includes/class-http.php that is a newer class for making HTTP requests that can use also cURL if it’s present in the server.
In your case, 5 seconds was not enough to perform the WP REST call, but it was enough to perform the dummy call. Generally, in terms of doing an HTTP request 5 seconds should be enough in most cases. But it seems in your WP REST endpoint you are doing too much work that need more than 5 seconds.
You can increase the timeout value to any value (15 seconds for example) by the following filter.
function custom_http_request_timeout( ) {
return 15;
}
add_filter( 'http_request_timeout', 'custom_http_request_timeout' );
本文标签: wp remote getwpremotegetcURL error 28only on same domain
版权声明:本文标题:wp remote get - wp_remote_get - cURL error 28 - only on same domain 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742140884a2422573.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论