ToothlessGear / node-gcm

A NodeJS wrapper library port to send data to Android devices via Google Cloud Messaging
https://github.com/ToothlessGear/node-gcm
Other
1.3k stars 206 forks source link

Exception while parsing response json #7

Closed yannooo closed 12 years ago

yannooo commented 12 years ago

Hello and thanks for your gcm node library.

I encounter this bug pretty often when sending notifications to multiple users at the same time, nine to be exact. When it occurs, the notification is not delivered to the intended recipients so it might be an error result from google.

Do you have any ideas on how to fix it? In the meantime I've added a debug log to print the response from google services. I'll let you know when I have more.

undefined:1
657.
^
SyntaxError: Unexpected token J
    at Object.parse (native)
    at IncomingMessage.<anonymous> (/var/www/apns/node_modules/node-gcm/lib/sender.js:123:25)
    at IncomingMessage.emit (events.js:88:20)
    at HTTPParser.parserOnMessageComplete [as onMessageComplete] (http.js:130:23)
    at CleartextStream.socketOnData [as ondata] (http.js:1288:20)
    at CleartextStream._push (tls.js:375:27)
    at SecurePair.cycle (tls.js:734:20)
    at EncryptedStream.write (tls.js:130:13)
    at Socket.ondata (stream.js:38:26)
    at Socket.emit (events.js:67:17)

Not sure it is related but I'm using node v0.6.18