【问题标题】:Sending asynchronous message Pusher HTTP API for PHP发送异步消息 Pusher HTTP API for PHP
【发布时间】:2017-06-01 15:36:20
【问题描述】:

我在for 循环中使用pusher-http-php 发送消息。 $pusher->trigger 呼叫等待返回继续。如果没有 Pusher 消息,循环需要 2-3 秒。使用trigger 调用会导致504 错误,并且在数据库中需要半个多小时。 有没有办法在 PHP 中异步发送这些消息?

【问题讨论】:

标签: php asynchronous pusher


【解决方案1】:

the $pusher->trigger method 向 Pusher 发出同步 HTTP 请求是对的。您可以使用$pusher->triggerBatch 来减少网络延迟。

如果你真的想让$pusher->trigger 异步,你可以将它包装在一个异步任务中。 Here's an introduction to async PHP.

【讨论】:

    猜你喜欢
    • 2017-07-22
    • 2011-04-05
    • 2017-03-03
    • 1970-01-01
    • 2012-12-23
    • 1970-01-01
    • 2018-10-10
    • 2015-01-09
    相关资源
    最近更新 更多