laravel8 使用队列触发给用户发订阅通知一直报:
local.ERROR: App\Jobs\PostServerMsg has been attempted too many times or run too long. The job many
但是我这个功能又是正常的,微信用户也能收到订阅的通知消息,只是日志里一直会提示这个错误信息。
系统用的宝塔的lnmp,用了进程管理守护器。
我自己找了很久都没解决问题,也在网上搜索了下也没解决,有人知道是什么情况吗?求指导一下代码如下:
这个是队列里的代码
public function handle()
{
try {
$base = new BaseController();
$res = $base->post_msg($this->info);
if (empty($res)) {
throw new \Exception($res);
}
$res = json_decode($res,true);
exit($res['errmsg']);
}catch (\Exception $e){
exit($e->getMessage());
}
}
这个是对应的操作
function post_msg($info){
//用户id、预约单id
$wx_id = DB::table('users')->where(['id'=>$info['user_id']])->value('wx_id');
// $wx_id = User::query()->where(['id'=>$info['user_id']])->value('wx_id');
// 传递一个闭包,如果数据不存在
$token = Cache::get('AccessToken', function() {
$res = $this->GetAccessToken();
$expiresAt = Carbon::now()->addSeconds($res['expires_in']);
Cache::put('AccessToken', $res['access_token'], $expiresAt);
return $res['access_token'];
});
$url = 'https://api.weixin.qq.com/cgi-bin/message/subscribe/send?access_token='.$token;
$template_id = $info['template_id'];
$arr = [
'touser'=>$wx_id,
'template_id'=>$template_id,
'page'=>$info['page'],
"miniprogram_state"=>"formal",//eveloper为开发版;trial为体验版;formal为正式版;默认为正式版
"lang"=>"zh_CN",
'data'=>$info['data'],
];
$arr = json_encode($arr);
$res = $this->https_curl($url,'post','json',$arr);
return $res;
}