-
-
Notifications
You must be signed in to change notification settings - Fork 449
Description
Describe the bug
Running environment: PHP8.1 / "kreait/firebase-php":7.10.0
My local development environment is: windows
The online server environment is: Debian GNU/Linux 12 x86_64 (Py3.7.16)
When I was developing locally, I had no problem using 7.10.0 and could send messages normally. When my online server was updated to 7.10.0, I could not send messages. The error message was:
URL error 0: The cURL request was retried 3 times and did not succeed. The most likely reason for the failure is that cURL was unable to rewind the body of the request and subsequent retries resulted in the same error. Turn on the debug option to see what went wrong. See https://bugs.php.net/bug.php?id=47204 for more information. (see https://curl.haxx.se/libcurl/c/libcurl-errors.html) for https://fcm.googleapis.com/v1/projects/flutter-receive-sms/messages:send
Additionally an error page is returned.
411 Error. POST requests require a Content-length header. That’s all we know
Installed packages
"kreait/firebase-php":7.10.0
PHP version and extensions
-
Steps to reproduce the issue.
public function sendCloudMessaging(string $sendType, array $params): array|bool
{
Notification::fromArray([
'title' => $params['title'],
'body' => $params['body']
]);
if (!isset($data)) {
$params['data'] = ['jump' => 'my'];
}
$notification = Notification::create($params['title'], $params['body']);
$notification = $notification->withTitle($params['title'])->withBody($params['body']);
CloudMessage::withTarget($sendType, $params[$sendType])
->withNotification($notification)
->withData($params['data']);
$message = CloudMessage::fromArray([
$sendType => $params[$sendType],
'notification' => $notification,
'data' => $params['data']
]);
try {
if (is_array($params['token'])){
if (count($params['token']) > 500){
return false;
}
$result = $this->messaging->sendMulticast($message, $params['token']);
return ['success' => $result->successes()->count(), 'fail' => $result->failures()->count()];
}else{
$result = $this->messaging->send($message);
if (array_key_exists('name', $result)){
return ['success' => 1, 'fail' => 0];
}
return false;
}
} catch (MessagingException | FirebaseException $e) {
Log::error('sendCloudMessaging error' . $e->getMessage());
return false;
}
}
Error message/Stack trace
-
Additional information
No response