如何解决的时候触发一个事件

问题描述:

虽然广播推杆时,我收到以下错误:“时间戳过期”从REST API响应:如何解决的时候触发一个事件

(1/1) BroadcastException Timestamp expired: Given timestamp (2017-10-18T00:55:07Z) not within 600s of server time (2017-10-17T12:23:17Z) in PusherBroadcaster.php (line 106) at 
    PusherBroadcaster->broadcast(array(object(PrivateChannel)), 'App\\Events\\TestEvent', array('message' => 'How are you')) in BroadcastEvent.php (line 48) at 
    BroadcastEvent->handle(object(PusherBroadcaster)) at 
    call_user_func_array(array(object(BroadcastEvent), 'handle'), array(object(PusherBroadcaster))) in BoundMethod.php (line 29) at 
    BoundMethod::Illuminate\Container\{closure}() in BoundMethod.php (line 87) at 
    BoundMethod::callBoundMethod(object(Application), array(object(BroadcastEvent), 'handle'), object(Closure)) in BoundMethod.php (line 31) at 
    BoundMethod::call(object(Application), array(object(BroadcastEvent), 'handle'), array(), null) in Container.php (line 539) at 
    Container->call(array(object(BroadcastEvent), 'handle')) in Dispatcher.php (line 94) at 
    Dispatcher->Illuminate\Bus\{closure}(object(BroadcastEvent)) in Pipeline.php (line 114) at 
    Pipeline->Illuminate\Pipeline\{closure}(object(BroadcastEvent)) in Pipeline.php (line 102) 

我使用Windows。

这是错误消息:Timestamp expired: Given timestamp (2017-10-18T00:55:07Z) not within 600s of server time (2017-10-17T12:23:17Z)

我已经正确配置了我的Pusher广播并触发了事件,但是 - 什么也没有。

下面是Laravel堆栈跟踪和Pusher调试控制台的屏幕截图。


我怎样才能解决这个问题?

+0

你的事件创建/推送代码是什么样的? –

看起来错误非常明显,事件的时间戳(2017-10-18T00:55:07Z)比当前服务器时间(2017-10-17T12:23:17Z)还要高出600秒。所以其中之一是错误的。因此,检查代码是否正确设置时间戳,并检查服务器时间是否正确。

+0

如何在laravel中设置时间戳..?我该如何纠正它。 – Divya

如果您使用的是Vagrant/Homestead,当您的计算机进入睡眠状态时,您的系统时间可能会发生变化并失去同步。

vagrant ssh 
sudo apt install ntpdate 
sudo ntpdate ntp.ubuntu.com 
sudo timedatectl set-ntp on 
sudo service ntp stop 
sudo ntpd -gq 
sudo service ntp start 

然后

cd /path/to/homestead 
    vagrant plugin install vagrant-vbguest 
    vagrant halt 
    vagrant up 

我有同样的问题,并纠正我的系统时间以这种方式解决了这个问题对我来说。这里的讨论是有帮助的: https://github.com/laravel/homestead/issues/799