is_wp_error and wp_remote_get cURL error 28 - wordpress

I'm using the following code. Assume $url is something like https://example.com/cron/cron.php. I'm getting the failure message, but it's actually working because in the linked script I send out an e-mail and I am receiving the e-mails.
So if it's working, then why is is_wp_error triggering?
if (is_wp_error($wp_remote_get = wp_remote_get($url))) {
echo "Failed to get script. Error: " . $wp_remote_get->get_error_message() . " Exiting...";
exit;
}
Got error: Failed to get script. Error: cURL error 28: Operation timed out after 5004 milliseconds with 0 out of -1 bytes received

So it was a bit of a silly issue. wp_remote_get retrieves the http response, but I thought it would just be visiting the url to run the script. The script takes a while to complete, so it must be running into time limits, which is what the error message seems to be suggesting.
I resolved this by just using wp_redirect instead. Would be nice if I can find a way to run the other script without redirecting though.

Related

Not able to download selenium-server log from the saucelab, getting FilenotFound Exception

I am not able to download selenium-server log from the saucelab
This is the error:
Sep 07, 2021 9:27:43 PM com.saucelabs.saucerest.SauceREST saveFile
WARNING: Error downloading Sauce Results
java.io.FileNotFoundException :
This is the code:
SauceREST sauceREST = new SauceREST(username, accesskey);
sauceREST.downloadLog(sessionid, "/target/saucelab");
This usually happens because either:
Your network infrastructure is blocking requests to the REST API
The test you're grabbing logs for hasn't finalised asset upload
Check whether you can download the logs manually (docs here):
curl -u "$SAUCE_USERNAME:$SAUCE_ACCESS_KEY" --location \
--request GET 'https://api.us-west-1.saucelabs.com/rest/v1/{USERNAME}/jobs/{JOB_ID}/assets/log.json'
If you can, try wrapping your REST code in a try/catch block, and if it fails, wait a small amount of time and try again.

How to fix a "URL Error #:Operation timed out after 300001 milliseconds with 0 bytes received" in WordPress

I have the following fatal error when trying to use Curl GET Method using woocommerce rest api V3 in WordPress. I have try to set_time_limit(0) and also, try with wp_remote_get method of WordPress but not solve issue. this because I get errors and I'm not able to fix them. I've set the timeout to 30 seconds. Also with this settings I get a timeout error and getting null response from REST API.
Fatal error: cURL Error: Operation timed out after 30009 milliseconds with 0 bytes received
Anyone have suggestion to fix this?
I think the answer here is likely what you're looking for https://wordpress.stackexchange.com/a/346236/31838
Increase the request timeout with a http_request_timeout filter
function custom_http_request_timeout( ) {
return 90;
}
add_filter( 'http_request_timeout', 'custom_http_request_timeout' );

Monitor asterisk calls with MRTG

I'm using mrtg to monitor cpu and network stats on my server. It all works fine...
The one thing that i am not being able to make it work is asterisk - I'm using a script i found on: https://karlsbakk.net/asterisk/scripts/asterisk-mrtg
I configured accordingly to my servers information, and then proceed to generate the stats of concurrent calls on asterisk using mrtg ... But the following error occurs:
2020-03-04 10:34:36: WARNING: Could not get any data from external command '/etc/mrtg/bin/mrtgasterisk.pl -h localhost -1 SIP -2 IAX2'
Maybe the external command did not even start.
2020-03-04 10:34:36: WARNING: Problem with External get '/etc/mrtg/bin/mrtgasterisk.pl -h localhost -1 SIP -2 IAX2':
Expected a Number for 'in' but nothing'
2020-03-04 10:34:36: WARNING: Problem with External get '/etc/mrtg/bin/mrtgasterisk.pl -h localhost -1 SIP -2 IAX2':
Expected a Number for 'out' but nothing'
2020-03-04 10:34:36: ERROR: Target[asterisk][_IN_] ' $target->[2]{$mode} ' did not eval into defined data
2020-03-04 10:34:36: ERROR: Target[asterisk][_OUT_] ' $target->[2]{$mode} ' did not eval into defined data
Did anyone ever went through this and was able to resolve it?
Try the actions in the script manually via Telnet with Asterisk Manager, then if it works execute the script and debug it.
Turns out the the perl script was outdated, doing a debug and testing the actions made me help discover what was wrong and then fix it.
This is the problem:
2020-03-04 10:34:36: WARNING: Could not get any data from external command '/etc/mrtg/bin/mrtgasterisk.pl -h localhost -1 SIP -2 IAX2'
Your script mrtgasterisk.pl is not completing correctly. Try running it interactively from the commandline and see if it outputs any helpful error messages. Possibly you are giving it the wrong parameters, or there are required modules not installed? All that MRTG knows is that the script is not running properly.

How can I stop nginx failling over when openresty throws runtime error deploying cert

We are using openresty and the lua-resty-auto-ssl package to generate certificates from Lets Encrypt but lately the server keeps falling over. Im guessing its triggered when a certificate trys to auto renew as generating a certificate for first time works fine ... the error we are seeing is
2019/05/12 08:25:24 [error] 2623#2623: *1024227 lua entry thread aborted: runtime error: ...sty/luajit/share/lua/5.1/resty/auto-ssl/servers/hook.lua:40: assertion failed!
stack traceback:
coroutine 0:
[C]: in function 'assert'
...sty/luajit/share/lua/5.1/resty/auto-ssl/servers/hook.lua:40: in function 'server'
.../local/openresty/luajit/share/lua/5.1/resty/auto-ssl.lua:99: in function 'hook_server'
content_by_lua(nginx.conf:194):2: in function <content_by_lua(nginx.conf:194):1>, client: 127.0.0.1, server: , request: "POST /deploy-cert HTTP/1.1", host: "127.0.0.1:8999"
From what I can see in the error it is failing to assert something when trying to deploy the cert which could be any of 4 things
assert(params["domain"])
assert(params["fullchain"])
assert(params["privkey"])
assert(params["expiry"])
Im a bit stuck to what I can do, its no good having the server dropping out on use. Thats the last error thats reported before the server goes offline so im guessing thats the cause? but not 100% sure.
Is there anywhere I can look to find out more information what causes the crash. Im new to nginx/openresty so fumbling my round a bit. Has anyone come across a similar issue?
Wrap it all in a function and call it with pcall or xpcall and add some logic to deal with the error.

exec function blocks other requests during the execution

I can't get http response when a exec or system function is excuting.
A specific request launch the exec function sudo find / -name toto, this take a while
During the execution, the client send any other requests
I don't get responses
Did you have a similar problem ? I tried shell_exec, exec, system...
I tried also this case :
A request launch a infinite loop
A second request launch an other script who return 'toto'
It work fine. What's wrong with exec ?
Thank you for your ideas

Resources