Node-RED Handle error from node that throws no standardexception - error-handling

I want to use the Pushover Node to send notifications. I'm already using it via curl for some time and very seldom some messages aren't sent. Thats why I have in bash
echo "$curlOutput" | grep -qP '{"status":1'
if [ ! $? -eq 0 ]
then
echo "$2" | mail --append "Content-Type: text/plain; charset=UTF-8" -s "$1" name#company.com
fi
to capture the error and then send the message via email.
Now I want to do something similiar in Node-Red. For testing purposes if simulated a network error via sudo iptables -A OUTPUT -d 104.20.0.0/16 -m comment --comment "Pushovertest" -j REJECT
That successfully blocks. In node-red-log I see
18 May 13:46:24 - [error] [pushover:252a17dc.1239d8] Error: connect
ECONNREFUSED 104.20.125.71:443
Now look at this Node-RED flow
The error is displayed in the debug window and comes from pushover node. The catch node doesn't catch the expection, obviously because pushover doesn't use the exception framework https://developer.ibm.com/recipes/tutorials/nodered-exception-handling-framework/
First test passed: There is an error logged. But how can I react to this error within Node-RED to do something else in this case?

I'll guess from looking at the source that the error is coming from line 103
of the 57-pushover.js file.
The call to node.error() on this line is not pushing the incoming msg object so it won't be passed to the catch node. There are 2 signatures for the node.error() function, the first just takes the error message, the second takes the error message and the incoming msg object, only the second forwards the error and msg object is passed to the catch node.
Please feel free to submit a pull request to update this node.

Related

Change Replication and other base commands

I have been attempting to do something here, I will explain what I am attempting and what I have done thus far which is not much since I cannot find the information online.
There is a feature that has not been added to Proxmox (according to others online), "-w" option for zvol transfers (send and recv zfs commands)
Full story:
I have some blades and wanted to create a high-availability system with (if)possible load balancing for a work cloud solution.I set my software up and that worked great.
When I try to replicate I receive:
2022-11-30 07:57:03 123-0: start replication job2022-11-30 07:57:03 123-0: guest => VM 123, running => 2041662022-11-30 07:57:03 123-0: volumes => local-zfs:vm-123-disk-02022-11-30 07:58:15 123-0: create snapshot '__replicate_123-0_1669823823__' on local-zfs:vm-123-disk-02022-11-30 07:58:15 123-0: using secure transmission, rate limit: none2022-11-30 07:58:15 123-0: full sync 'local-zfs:vm-123-disk-0' (__replicate_123-0_1669823823__)2022-11-30 07:58:30 123-0: cannot send rpool/data/vm-123-disk-0#__replicate_123-0_1669823823__: encrypted dataset rpool/data/vm-123-disk-0 may not be sent with properties without the raw flag2022-11-30 07:58:30 123-0: warning: cannot send 'rpool/data/vm-123-disk-0#__replicate_123-0_1669823823__': backup failed2022-11-30 07:58:30 123-0: command 'zfs send -Rpv -- rpool/data/vm-123-disk-0#__replicate_123-0_1669823823__' failed: exit code 12022-11-30 07:58:30 123-0: cannot receive: failed to read from stream2022-11-30 07:58:30 123-0: cannot open 'rpool/data/vm-123-disk-0': dataset does not exist2022-11-30 07:58:30 123-0: command 'zfs recv -F -- rpool/data/vm-123-disk-0' failed: exit code 12022-11-30 07:58:30 123-0: delete previous replication snapshot '__replicate_123-0_1669823823__' on local-zfs:vm-123-disk-02022-11-30 07:58:31 123-0: end replication job with error: command 'set -o pipefail && pvesm export local-zfs:vm-123-disk-0 zfs - -with-snapshots 1 -snapshot __replicate_123-0_1669823823__ | /usr/bin/ssh -e none -o 'BatchMode=yes' -o 'HostKeyAlias=ProxmoxVEBlade1' root#192.168.1.175 -- pvesm import local-zfs:vm-123-disk-0 zfs - -with-snapshots 1 -snapshot __replicate_123-0_1669823823__ -allow-rename 0' failed: exit code
The simple solution to this is to add -w for raw transfer.
So my question is, to introduce functional replication in Proxmox VE, How would I add/modify options of the standard send recv futions of ZFS.Thank you for your time and answers. Please use simplest terms as I am very ignorant of this stuff.
I was directed here by someone who probably could do this but is too busy to help. They told me this is likely the only place I would get a "real" answer.
So far I have determined that the command is called by a Perl script. But where that script is, I am unsure.
Note: Non-Encrypted zvols are not an option. Unfortunately.

Found error 'CRASH REPORT Process' on RabbitMQ in every 10 mins

I found error on RabbitMQ in every 10 mins. Please help me to investigate this problem.
Error message.
021-09-09 13:25:30.084 [error] <0.14464.32> CRASH REPORT Process <0.14464.32> with 0 neighbours crashed with reason: no function clause matching rabbit_mgmt_wm_node:find_type(rabbit#controller1, []) line 79
2021-09-09 13:25:30.085 [error] <0.14457.32> Ranch listener rabbit_web_dispatch_sup_15672, connection process <0.14457.32>, stream 1 had its request process <0.14464.32> exit with reason function_clause and stacktrace [{rabbit_mgmt_wm_no
I had the same issue with Zabbix monitoring the RabbitMQ server every minute which generated a crash-error with the same frequency.
The URL used by Zabbix to monitor contained a domain part to the node name ie. rabbit#my_host.zzz.aws instead of the actual node name as displayed by the console: rabbit#my_host. this explains why rabbit_mgmt_wm_node:find_type failed and crashed.
This was verified using curl as shown below:
curl -v -u user:passwd 'http://127.0.0.1:15672/api/nodes/rabbit#my_host?memory=true'
which returned a valid response, HTTP/1.1 200 OK, when the node name matched and the crash/error when it did not.
please refer to this thread:
https://groups.google.com/g/rabbitmq-users/c/N0EgrLn55XQ

MongooseIM REST API's not working for POST requests

Have anyone tried the MongooseIM 2.0.0 Bets services to hit web services.
I am able to to the GET calls as defined in this Swagger site link but unable to get the POST request as it gives me error for the same data that I use with my IP address instead of localhost.
Here in my Mongoose Im error response.
] emulator Error in process <0.4026.0> on node mongooseim#localhost
with exit value:
{{nocatch,[{reason,{error,{3,invalid_json}}},{mfa,{mongoose_api_admin,from_json,2}},{stacktrace,[{jiffy,decode,2,[{file,"src/jiffy.erl"},{line,68}]},{mongoose_api_common,parse_request_body,1,[{file,"src/mongoose_api_common.erl"},{line,169}]},{mongoose_api_admin,from_json,2,[{file,"src/mongoose_api_admin.erl"},{line,114}]},{cowboy_rest,call,3,[{file,"src/cowboy_rest.erl"},{line,976}]},{cowboy_rest,process_content_type,3,[{file,"src/cowboy_rest.erl"},{line,777}]},{cowboy_protocol,execute,4,[{file,"src/cowboy_protocol.erl"},{line,442}]}]},{req,[{socket,#Port<0.35385>},{transport,ranch_tcp},{connection,keepalive},{pid,<0.4026.0>},{method,<<"POST">>},{version,'HTTP/1.1'},{peer,{{118,200,26,4},1036}},{host,<<"ec2-54-111-111-111.ap-southeast-1.compute.amazonaws.com">>},{host_info,undefined},{port,8090},{path,<<"/api/messages">>},{path_info,undefined},{qs,<<>>},{qs_vals,undefined},{bindings,[]},{headers,[{<<"host">>,<<"ec2-54-111-111-111.ap-southeast-1.compute.amazonaws.com:8090">>},{<<"user-agent">>,<<"curl/7.49.1">>},{<<"content-type">>,<<"application/json">>},{<<"accept">>,<<"application/json">>},{<<"content-length">>,<<"208">>}]},{p_headers,[{<<"content-type">>,{<<"application">>,<<"json">>,[]}},{<<"if-modified-since">>,undefined},{<<"if-none-match">>,undefined},{<<"if-unmodified-since">>,undefined},{<<"if-match">>,undefined},{<<"accept">>,[{{<<"application">>,<<"json">>,[]},1000,[]}]}]},{cookies,undefined},{meta,[{media_type,{<<"application">>,<<"json">>,[]}},{charset,undefined}]},{body_state,waiting},{buffer,<<"{
\ \n \"caller\":
\"+6512345699#ec2-54-111-111-111.ap-southeast-1.compute.amazonaws.com\", \ \n \"to\":
\"+6512345678#ec2-54-111-111-111.ap-southeast-1.compute.amazonaws.com\", \ \n \"body\": \"Hi Rabbit!\" \ \n
}">>},{multipart,undefined},{resp_compress,false},{resp_state,waiting},{resp_headers,[{<<"content-type">>,[<<"application">>,<<"/">>,<<"json">>,<<>>]}]},{resp_body,<<>>},{onresponse,undefined}]},{state,{http_api_state,[<<"GET">>,<<"POST">>,<<"POST">>,<<"GET">>,<<"POST">>,<<"GET">>,<<"POST">>,<<"POST">>,<<"POST">>,<<"GET">>,<<"GET">>,<<"DELETE">>,<<"DELETE">>,<<"POST">>,<<"DELETE">>,<<"POST">>,<<"PUT">>],[],undefined,<<"messages">>,undefined,admin,[]}}]},[{cowboy_rest,process_content_type,3,[{file,"src/cowboy_rest.erl"},{line,777}]},{cowboy_protocol,execute,4,[{file,"src/cowboy_protocol.erl"},{line,442}]}]}
2016-11-02 05:25:37.428 [error] <0.4026.0> Ranch listener
'ejabberd_cowboy_166.36.16.166_8090' terminated with reason:
{nocatch,[{reason,{error,{3,invalid_json}}},{mfa,{mongoose_api_admin,from_json,2}},{stacktrace,[{jiffy,decode,2,[{file,"src/jiffy.erl"},{line,68}]},{mongoose_api_common,parse_request_body,1,[{file,"src/mongoose_api_common.erl"},{line,169}]},{mongoose_api_admin,from_json,2,[{file,"src/mongoose_api_admin.erl"},{line,114}]},{cowboy_rest,call,3,[{file,"src/cowboy_rest.erl"},{line,976}]},{cowboy_rest,process_content_type,3,[{file,"src/cowboy_rest.erl"},{line,777}]},{cowboy_protocol,execute,4,[{file,...},...]}]},...]}
in cowboy_rest:process_content_type/3 line 777
This was probably answered here: https://github.com/esl/MongooseIM/issues/1055 already. Am I right?

Internal Server Error 500 on Apache for perl script

I have a perl script in my cgi-bin. It first prints out the following statements
print "Status: 200 OK\nContent-Type: text/html\n\n";
It generates a html form on the terminal perfectly but when I try running it on the browser it gives the following error
Internal Server Error The server encountered an internal error or
misconfiguration and was unable to complete your request. Please
contact the server administrator at [no address given] to inform them
of the time this error occurred, and the actions you performed just
before this error.
I have enabled cgi-bin in the apache configuration, the error log prints the following error
End of script output before headers
What could be the problem and how should I resolve it
You must have the Content-Type be the first thing printed back to the screen. Also make sure the script is set as executable.
print "Status: 200 OK\nContent-Type: text/html\n\n";
Should be:
print "Content-Type: text/html\n\nStatus: 200 OK\n";
The script also needs to be executable by Apache for it to work
chmod a+x YourScript.pl
I've tested with the following script and once I fixed the permissions it works just fine. You also only need to set the status if it isn't 200 as that's the default.
#!/usr/bin/perl
use strict;
print "Status: 200\nContent-Type: text/html\n\n";
print "<p>Foo</p>";

Send request to google's geocoding API from the terminal

I'm trying to geocode a lot of data. I have a lot of machines across which to spread the load (so that I won't go over the 2,500 requests per IP address per day). I am using a script to make the requests with either wget or cURL. However, both wget and cURL yield the same "request denied" message. That being said, when I make the request from my browser, it works perfectly. An example request is:
wget http://maps.googleapis.com/maps/api/geocode/json?address=1600+Amphitheatre+Parkway,+Mountain+View,+CA&sensor=true
And the resulting output is:
[1] 93930
05:00 PM ~: --2011-12-19 17:00:25-- http://maps.googleapis.com/maps/api/geocode/json?address=1600+Amphitheatre+Parkway,+Mountain+View,+CA
Resolving maps.googleapis.com... 72.14.204.95
Connecting to maps.googleapis.com|72.14.204.95|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [application/json]
Saving to: `json?address=1600+Amphitheatre+Parkway,+Mountain+View,+CA'
[ <=> ] 54 --.-K/s in 0s
2011-12-19 17:00:25 (1.32 MB/s) - `json?address=1600+Amphitheatre+Parkway,+Mountain+View,+CA' saved [54]
The file it wrote to only contains:
{
"results" : [],
"status" : "REQUEST_DENIED"
}
Any help is much appreciated.
The '&' character that separates the address and sensor parameters isn't getting passed along to the wget command, but instead is telling your shell to run wget in the background. The resulting query is missing the required 'sensor' parameter, which should be set to true or false based on your input.
wget "http://maps.googleapis.com/maps/api/geocode/json?address=1600+Amphitheatre+Parkway,+Mountain+View,+CA&sensor=false"