我是 nginx 的新手,我正在使用 nginx 作为 nginx_http_push_module 的 cometd 服务器
我有两个问题:
1、如何将nginx_http_push_module接收到的消息存入数据库?
2,如何获取 channel 的听众列表?
谢谢~
最佳答案
1,how can i save the messages which recieved by nginx_http_push_module into databases ?
您必须在服务器端订阅您感兴趣的 channel ,并在每条消息到达时将其存储在数据库中。
你可以使用 cURL例如,在 PHP 中重复长轮询 channel (您必须设置适当的超时和正确的缓存 header :If-None-Match 和 If-Modified-Since).
2,how can i get listeners list of a channel ?
旁注:nginx http push module protoco l 非常简单,这不是 bayeux .此模块中的订阅者/监听器只是订阅者 URL 上的事件 HTTP 连接。例如,如果您使用 interval-polling而不是长轮询,您将仅在建立连接期间的(非常)短时间内被计为订阅者。
这就是为什么一个 channel 的听众列表对于这个模块没有多大意义。
不过,您可以通过向发布 URL 发出 GET 请求来获取 channel 的活跃订阅者数量,但我严重怀疑您可以用它做任何事情。
关于php - nginx_http_push_module 和数据库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2771260/