收到新订阅者时 rs/pushd 崩溃

Posted

技术标签:

【中文标题】收到新订阅者时 rs/pushd 崩溃【英文标题】:rs/pushd crashes when a new subscriber is received 【发布时间】:2015-02-05 17:57:06 【问题描述】:

我正在尝试使用https://github.com/rs/pushd 作为推送通知服务器。

每当我尝试添加新订阅者时,服务器都会因堆栈跟踪而崩溃:

/home/ec2-user/push_server/pushd/node_modules/redis/index.js:602
                throw err;
                      ^
TypeError: Cannot set property 'id' of null
  at /home/ec2-user/push_server/pushd/lib/api.coffee:20:21
  at /home/ec2-user/push_server/pushd/lib/subscriber.coffee:133:21
  at try_callback (/home/ec2-user/push_server/pushd/node_modules/redis/index.js:592:9)
  at RedisClient.return_reply (/home/ec2-user/push_server/pushd/node_modules/redis/index.js:685:13)
  at HiredisReplyParser.<anonymous> (/home/ec2-user/push_server/pushd/node_modules/redis/index.js:321:14)
  at HiredisReplyParser.emit (events.js:95:17)
  at HiredisReplyParser.execute (/home/ec2-user/push_server/pushd/node_modules/redis/lib/parser/hiredis.js:43:18)
  at RedisClient.on_data (/home/ec2-user/push_server/pushd/node_modules/redis/index.js:547:27)
  at Socket.<anonymous> (/home/ec2-user/push_server/pushd/node_modules/redis/index.js:102:14)
  at Socket.emit (events.js:95:17)
  at Socket.<anonymous> (_stream_readable.js:765:14)
  at Socket.emit (events.js:92:17)
  at emitReadable_ (_stream_readable.js:427:10)
  at emitReadable (_stream_readable.js:423:5)
  at readableAddChunk (_stream_readable.js:166:9)
  at Socket.Readable.push (_stream_readable.js:128:10)
  at TCP.onread (net.js:529:21)

这是应该添加新订阅者的命令(文档中的示例),并导致崩溃:

curl -d proto=apns -d token=FE66489F304DC75B8D6E8200DFF8A456E8DAEACEC428B427E9518741C92C6660 -d lang=fr -d badge=0 -d category=show -d contentAvailable=true http://localhost/subscribers

崩溃发生在订阅者添加到数据库之前。

服务器是 AWS 上的 RHEL 微实例

版本

Redis 服务器 2.8.19。

Node.js 0.10.36.

CoffeeScript 1.9.0

任何帮助将不胜感激。

【问题讨论】:

【参考方案1】:
/lib/event.coffee
-        throw new Error("Missing redis connection") if not redis?
+        throw new Error("Missing redis connection") if not @redis?
/lib/subscriber.coffee
-                if info?.updated? # subscriber exists
+                if @info?.updated? # subscriber exists
                     # transform numeric value to number type
-                    for own key, value of info
+                    for own key, value of @info

【讨论】:

以上是关于收到新订阅者时 rs/pushd 崩溃的主要内容,如果未能解决你的问题,请参考以下文章

第二个物理发布者如何收到新订阅者的通知?

向 MailChimp 添加新订阅者返回错误请求

redis频道收到发布者信息后可以只推信息给一个订阅者吗

使用 Paypal IPN 订阅

观察者模式(Observer Pattern)

在 Firebase Cloud Messaging 上订阅数百个主题时,iOS 应用程序崩溃