当我运行Angular Pusher应用程序时...我收到错误

时间:2014-09-01 12:31:24

标签: angularjs pusher

TypeError: Not a buffer at new Hmac (crypto.js:226:17) at Object.Hmac (crypto.js:224:12) at Object.module.exports.Pusher.createSignedQueryString (E:\angular-pusher-gh-pages\node_modules\pusher\lib\pusher.js:167:43) at Object.module.exports.Pusher.post (E:\angular-pusher-gh-pages\node_modules\pusher\lib\pusher.js:84:28) at Object.module.exports.Pusher.trigger (E:\angular-pusher-gh-pages\node_modules\pusher\lib\pusher.js:69:17) at E:\angular-pusher-gh-pages\server.js:58:10 at callbacks (E:\angular-pusher-gh-pages\node_modules\express\lib\router\index.js:164:37) at param (E:\angular-pusher-gh-pages\node_modules\express\lib\router\index.js:138:11) at pass (E:\angular-pusher-gh-pages\node_modules\express\lib\router\index.js:145:5) at Router._dispatch (E:\angular-pusher-gh-pages\node_modules\express\lib\router\index.js:173:5)

1 个答案:

答案 0 :(得分:0)

我认为当您未在server.js中设置Pusher appId,key和secret时会发生这种情况。

var pusherConfig = {};
try {
  pusherConfig = require('./pusherConfig');
} catch (err) {
  pusherConfig.appId = process.env.PUSHER_APP_ID;
  pusherConfig.key = process.env.PUSHER_KEY;
  pusherConfig.secret = process.env.PUSHER_SECRET;
}

如您所见,它在环境变量中查找Pusher appId,key和secret,如果未设置,则HMAC将根据您的错误失败。

如果能解决问题,请告诉我。