我正在使用存在状态和通道存在类型的Pusher Webhook,并且在本地使用ngrok将请求代理到我的计算机。 每当将Webhook请求发送到我的本地服务器时,它就会被接收并在ngrok中返回200状态代码,但是对于同样的请求,我在Pusher调试控制台中看到“ webhook失败,由于超时”。 我使用microtime(true)为控制器执行计时,通常它需要0.05325984954834,这比Pusher 3秒超时要短。 问题是什么?请如何解决?
这是我的代码:
public function channelExistance(Request $request){
// return response('ok', 200);
$start = microtime(true);
if($this->requestValid($request)){
foreach ($request->input('events') as $event) {
$name = $event['name'];
$channel_name = $event['channel'];
if(stripos($channel_name, 'presence') === false && stripos($channel_name, 'private') === false){
if($event['name'] == 'channel_occupied'){
$this->manager->channelStarted($channel_name);
}
elseif($event['name'] == 'channel_vacated'){
$this->manager->supporterIsFreed($channel_name);
// return response('ok', 200);
}
}
}
}
$end = microtime(true) - $start;
logger('time taken: '.$end);
header("Status: 200 OK");
}
答案 0 :(得分:0)
这表明您没有正确返回200响应。 仔细阅读this answer,可以发现有多种返回响应的方法。根据您的情况,您可以替换
header("Status: 200 OK");
使用
header("HTTP/1.1 200 OK");