CRITICAL messenger Error thrown while handling message AppBundle\Message\Message - php

I'm using the symfony messenger component : https://symfony.com/doc/current/messenger.html
But my logs are flooded by these messages when retries are failing :
16:14:31 CRITICAL [messenger] Error thrown while handling message AppBundle\Message\NewsletterMessage. Removing from transport after 3 retries. Error: "No newsletter subscriber found" ["message" => AppBundle\Message\NewsletterMessage^ { …},"class" => "AppBundle\Message\NewsletterMessage","retryCount" => 3,"error" => "No newsletter subscriber found","exception" => Symfony\Component\Messenger\Exception\HandlerFailedException^ { …}]
The thing is that I don't want critical messages: is there a way to change them into error messages ?
Found in the file :
Symfony\Component\Messenger\EventListener\SendFailedMessageForRetryListener
the responsible line at l.76 :
$this->logger->critical('Error thrown while handling message {class}. Removing from transport after {retryCount} retries. Error: "{error}"', $context + ['retryCount' => $retryCount, 'error' => $throwable->getMessage(), 'exception' => $throwable]);
Hope someone can help,
Thanks ! ^^

You may use failure_transport and make some logs for example
https://symfony.com/doc/current/messenger.html#retries-failures

Related

Stripe API Update DRAFT invoice for subscription (PHP)

I am using PHP and have a webhook generated with invoice.created. When the invoice is created, Stripe lets the draft invoice sit there for about an hour which gives us time to edit the invoice or adjust it. I use this time to check the database (via webhook) to see how many referrals this person has in the system to the adjust the coupons accordingly. I can't seem to adjust the invoice properly as I get errors in all the ways I have tried, which are:
$inv = {the invoice id and I get no error from the invoice ID being incorrect
define('STRIPE_API_KEY', 'sk_test_******************');
$stripe = new \Stripe\StripeClient(
STRIPE_API_KEY
);
$stripe->invoices->update(
$inv,
['discounts.coupon' => '20OFF']
);
Error is unknown object discounts.coupon
and
$stripe->invoices->update(
$inv,
['discount' => '20OFF']
);
Error = Fatal error: Uncaught (Status 400) (Request req_hsX1QTOxzWMiQn) Received unknown parameter: discount. Did you mean discounts? thrown in /home/searchoscn/public_html/vendor/stripe/stripe-php/lib/Exception/ApiErrorException.php on line 38
and
$stripe->invoices->update(
$inv,
['coupon' => '20OFF']
);
ERROR = Fatal error: Uncaught (Status 400) (Request req_yEwwOLoukR6j6Z) Received unknown parameter: coupon thrown in /home/searchoscn/public_html/vendor/stripe/stripe-php/lib/Exception/ApiErrorException.php on line 38
$stripe->invoices->update(
$inv,
['discounts' => ['coupon' => '20OFF']]
);
Fatal error: Uncaught (Status 400) (Request req_IDRP1Rjv1YoBZR) Invalid array thrown in /home/searchoscn/public_html/vendor/stripe/stripe-php/lib/Exception/ApiErrorException.php on line 38
I'm pretty sure I need to use 'discounts' but don't know how to structure the array to pass the coupon properly.
Trying to predict some questions or comments:
Yes, I do have an existing coupon with id of 20OFF. This is for 20% off
$inv does fetch the correct ID of the invoice at the time the webhook is sent.
Here is the link of the API documentation that I've been reading, but it isn't very helpful.
Instead of:
$stripe->invoices->update(
$inv,
['discounts.coupon' => '20OFF']
);
try:
$stripe->invoices->update(
$inv,
['discounts' => ['coupon' => $couponId]]
);
It looks like it must be the id of the coupon and not the customer facing code, e.g. 20OFF.
You would be able to get the id of the coupon from the dashboard (https://dashboard.stripe.com/coupons/) or by making another api request.
It's
$stripe->invoices->update(
$inv,
[
'discounts' => [
['coupon' => '20OFF']
]
]
);
As in, it's an array that then contains objects (in PHP those are both square brackets) and the objects refer to the coupon.

AMQPException Library error: table too large for buffer

I am using the messenger component in a Symfony application to process messages from rabbitmq.
When I send a 2-3mb message and an error occurs in my handler, the middleware that tries to send the message back to rabbit raises an exception of type:
AMQPException Library error: table too large for buffer
I found similar error in this links :
https://github.com/vyuldashev/laravel-queue-rabbitmq/issues/10
https://github.com/alanxz/rabbitmq-c/issues/224
https://github.com/php-amqp/php-amqp/issues/131
But I don't see any solution or workaround provided!
I found a workaround: when the message is being redirected back to queue (to retry later) one huge stamp is being added
In my serializer, in method 'encode' I filter stamps:
$allStamps = [];
foreach ($envelope->all() as $stampKey => $stamps) {
if ($stampKey === 'Symfony\Component\Messenger\Stamp\ErrorDetailsStamp') {
// this header could be huge and drasticaly increase a size of a message
continue;
}
$allStamps = array_merge($allStamps, $stamps);
}
return [
'body' => serialize($messageBody),
'headers' => [
// store stamps as a header - to be read in decode()
'stamps' => serialize($allStamps),
],
];

PHP ics-parser Multiple ICS Calls

I am using PHP ICS Parser https://github.com/u01jmg3/ics-parser to parse up to 33 remote URL's. The Parser intermittently fails parsing some of these URL's.
The actual exception error details returned by PHP ICS are:
exception 'Exception' with message 'The file path or URL 'admin.vrbo.com/icalendar/…; does not exist.
Here's my code:
foreach($ical_props_arr as $row) {
$property_title=$row['title'];
$import_url=$row['ical_import_url'];
try {
$ical = new ICal($import_url, array(
'defaultSpan' => 2, // Default value
'defaultTimeZone' => 'UTC',
'defaultWeekStart' => 'MO', // Default value
'disableCharacterReplacement' => false, // Default value
'skipRecurrence' => false, // Default value
'useTimeZoneWithRRules' => false, // Default value
));
} catch (\Exception $e) {
$error.='An Error Occurred importing: '.$import_url."\n";
$error.=$property_title." Import ICAL URL, appears to be Bad!!\n\n";
}
}
All of the URL's are confirmed good.
Could this be a PHP timing issue, calling the multiple URL's and not waiting for the remote server to respond quick enough?
Any help would be appreciated.
Thanks

Fatal error: Uncaught exception 'Exception' with message 'Incorrect response id: (request id: 1)'

I am using limesurvay github.com/trougakoss/LimeSurvey with github.com/weberhofer/jsonrpcphp and code for testing is
require_once 'C:/wamp/www/limesurvey/jsonrpcphp/src/org/jsonrpcphp/jsonRPCClient.php';
define( 'LS_BASEURL', 'http://10.10.10.29:823/limesurvey/index.php?r=admin/remotecontrol'); // adjust this one to your actual LimeSurvey URL
define( 'LS_USER', 'admin' );
define( 'LS_PASSWORD', 'admin' );
// the survey to process
$survey_id=989315;
// instanciate a new client
$myJSONRPCClient = new \org\jsonrpcphp\JsonRPCClient( LS_BASEURL);
//echo $myJSONRPCClient->getinfo();
// receive session key
$sessionKey= $myJSONRPCClient->get_session_key( LS_USER, LS_PASSWORD );
// receive all ids and info of groups belonging to a given survey
$groups = $myJSONRPCClient->list_groups( $sessionKey, $survey_id );
print_r($groups, null );
// release the session key
$myJSONRPCClient->release_session_key( $sessionKey );
and geting these errors: output result
( ! ) Fatal error: Uncaught exception 'Exception' with message 'Incorrect response id: (request id: 1)' in C:\wamp\www\limesurvey\jsonrpcphp\src\org\jsonrpcphp\JsonRPCClient.php on line 185
( ! ) Exception: Incorrect response id: (request id: 1) in C:\wamp\www\limesurvey\jsonrpcphp\src\org\jsonrpcphp\JsonRPCClient.php on line 185
Call Stack
# Time Memory Function Location
1 1.0022 252616 {main}( ) ..\test.php:0
2 1.0032 295944 org\jsonrpcphp\JsonRPCClient->get_session_key( ) ..\test.php:25
3 1.0032 296360 org\jsonrpcphp\JsonRPCClient->__call( ) ..\test.php:25
I got the same error when I forgot to enable JSON-RPC in Global Settings. Are you sure you enabled it? Just a thought.
"Go to Global settings, choose the tab 'Services' and select one of the two RPC services (XML-RPC or JSON-RPC) service."
https://manual.limesurvey.org/Global_settings
I got the same error and this was because I had chosen the XML API instead of the JSON API in the general settings.

PHP: Error in creating Server Instance in Google Cloud Compute

While using Google Cloud Compute's API in PHP, I am able to start, stop, delete instances as well as create and delete disks.
However, when trying to create an Instance, I keep getting this error
Invalid value for field 'resource.disks'
PHP Fatal error: Uncaught exception 'Google_Service_Exception' with message 'Error calling POST https://www.googleapis.com/compute/v1/projects/project/zones/zone/instances: (400) Invalid value for field 'resource.disks': ''. Boot disk must be specified.' in /var/www/html/google/google-api-php-client/src/Google/Http/REST
Here is the request I am making
self::connectClient();
$computeService = new Google_Service_Compute($this->client);
if ($this->client->getAccessToken())
{
$googleNetworkInterfaceObj = new Google_Service_Compute_NetworkInterface();
$network = self::DEFAULT_NETWORK;
$googleNetworkInterfaceObj->setNetwork($network);
$diskObj = self::getDisk($instance_name);
$new_instance = new Google_Service_Compute_Instance();
$new_instance->setName($instance_name);
$new_instance->setMachineType(self::DEFAULT_MACHINE_TYPE);
$new_instance->setNetworkInterfaces(array($googleNetworkInterfaceObj));
$new_instance->setDisks(array(
"source"=>$diskObj->selfLink,
"boot"=>true,
"type"=>"PERSISTENT",
"deviceName"=>$diskObj->name,
));
$insertInstance = $computeService->instances->insert(self::DEFAULT_PROJECT,self::DEFAULT_ZONE_NAME, $new_instance);
Any help will be highly appreciated, thank you.
Ok the solution was really simple (and silly)
Instead of
$new_instance->setDisks(array(
"source"=>$diskObj->selfLink,
"boot"=>true,
"type"=>"PERSISTENT",
"deviceName"=>$diskObj->name,
));
It's supposed to be
$new_instance->setDisks(array(
array(
'source'=>self::getDisk($instance_name)->selfLink,
'boot'=>true,
'type' => "PERSISTENT",
'deviceName'=>self::getDisk($instance_name)->name,
)
));

Categories