为什么 pusher 可以在本地主机上运行,​​但不能在实时网站上运行 [英] why pusher works on localhost but not on a live website

查看:45
本文介绍了为什么 pusher 可以在本地主机上运行,​​但不能在实时网站上运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用了 Pusher API 来放置一个简单的推送通知.我已经测试了所有东西并且 Pusher 可以在我的 localhost 上运行.当我将相同的代码放在实时网站上时,Pusher 不会发布我的消息.值得注意的是,如果我从本地主机推送,我可以在实时版本上看到消息.

I've used Pusher API to put a simple push notification in place. I've tested everything and Pusher works on my localhost. When I put the same code on a live website, Pusher doesn't publish my message. That's interesting to note that if I push from localhost I can see the message on the live version.

我订阅频道好像没有问题,但问题是我无法在频道上发布消息.

It seems that I have no problem subscribing to a channel, but the problem is that I cannot publish a message on the channel.

这是我的代码:

// Create pusher event
$pusher=Yii::app()->pusher;
$data = array('message'=>"myMessageContent");
$pusher->trigger('test_channel','my_event',$data);

有什么我不知道的吗?

编辑 1:

这是我从调试中得到的输出:

This is the output I've got from debugging:

string(112) "Timestamp expired: Given timestamp (2014-08-15T17:40:26Z) not within 600s of server time (2014-08-15T09:10:29Z) " 

我的服务器时间与我的 localhost (13:44) 完全相同,但在这里我看到了不同的东西?!17:40?

My server time is exactly the same as my localhost (13:44), but here I see something different?! 17:40?

推荐答案

服务器的时钟漂移很大,所以我在终端上使用 ntpdate ntp.ubuntu.com 并更正了时间.为了防止将来出现问题,我将其放在 crontab 中.

server's clock was drifted considerably so I used ntpdate ntp.ubuntu.com on terminal and corrected the time. To prevent future problems I put that in the crontab.

呸...

这篇关于为什么 pusher 可以在本地主机上运行,​​但不能在实时网站上运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆