提问人:Андрей Двойкин 提问时间:10/4/2023 最后编辑:Андрей Двойкин 更新时间:10/5/2023 访问量:64
发送通知时,它会给出错误
When sending notifications, it gives an error
问:
通过队列向大量用户发送通知时,发送了一半用户后全部陷入错误
(GuzzleHttp\Exception\ConnectException:cURL 错误 6:无法解析 /var/www/jai/vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php:210 中 https://fcm.googleapis.com/fcm/send 的主机:fcm.googleapis.com(请参阅 https://curl.haxx.se/libcurl/c/libcurl-errors.html)。
之后,它停止并且不再继续工作。告诉我如何处理此错误并继续进一步执行队列。
public function handle(): void
{
try {
$usersGroup = User::query()->whereNotNull('fcm_token')
->select(['id', 'fcm_token', 'gender']);
if ($this->group === UserNotification::GROUP_MALE) {
$usersGroup = $usersGroup->where('gender', '=', User::MALE);
}
if ($this->group === UserNotification::GROUP_FEMALE) {
$usersGroup = $usersGroup->where('gender', User::FEMALE);
}
$usersGroup->chunk(1500, function ($users) {
foreach ($users as $user) {
Log::channel('notification')
->debug("Sending push notification to {$this->group} user group:", [
'user_id' => $user->id,
'fcm_token' => $user->fcm_token
]);
$this->fcmService->send($user->fcm_token, $this->title, $this->body);
}
});
}catch (ConnectException $e){
Log::error('Ошибка ConnectException: ' . $e->getMessage());
}
}
答: 暂无答案
评论
Could not resolve host: fcm.googleapis.com
表示它无法再找到该主机。如果它发生在一个大型队列的中间,那么它可能是你自己的/服务器网络中的某些东西断开了连接或限制了它