logicalparadox / apnagent

Node.js adapter for Apple Push Notification (APN) Service.
http://logicalparadox.github.io/apnagent
216 stars 38 forks source link

Decoder Stream 11 not implemented #34

Open pbihler opened 9 years ago

pbihler commented 9 years ago

On our production server, I received this error causing a server restart:

Error uncaughtException: DecoderStream 11 not implemented.

Error: DecoderStream 11 not implemented.
 at Decoder._nudge (/home/code/live/agentXserver/node_modules/apnagent/node_modules/lotus/lib/lotus/decoder.js:138:18)
 at Buffers.g (events.js:199:16)
 at Buffers.emit (events.js:107:17)
 at Buffers.push (/home/code/live/agentXserver/node_modules/apnagent/node_modules/lotus/node_modules/bufs/lib/bufs.js:73:10)
 at Decoder._write (/home/code/live/agentXserver/node_modules/apnagent/node_modules/lotus/lib/lotus/decoder.js:154:15)
 at doWrite (_stream_writable.js:301:12)
 at writeOrBuffer (_stream_writable.js:288:5)
 at Decoder.Writable.write (_stream_writable.js:217:11)
 at TLSSocket.<anonymous> (/home/code/live/agentXserver/node_modules/apnagent/lib/apnagent/agent/live.js:159:18)
 at TLSSocket.emit (events.js:107:17)
 at readableAddChunk (_stream_readable.js:163:16)
 at TLSSocket.Readable.push (_stream_readable.js:126:10)
 at TCP.onread (net.js:538:20)

How can I catch it?

ExploreMqt commented 9 years ago

I'll take look and see if I can figure something out for you. I probably won't have an answer for you immediately. I'm still getting to know the internals.

logicalparadox commented 9 years ago

This is a tough one as it has to do with the parsing of the streaming buffer incoming from Apple. The 11 indicated with sub-stream on the multiplex to route the data to. With APN, there shouldn't be an 11 that I'm aware of. Two possibilites:

Has this only happened once?

pbihler commented 9 years ago

It just occured once, but we're not on heavy traffic, yet.

ExploreMqt commented 9 years ago

The unit tests for my app, which uses apnAgent, was running in the back ground and I just got this stack trace. I must not have something faked out correctly. But it also looks very familiar... Error: DecoderStream 11 not implemented. at Decoder._nudge (/Users/jim/Projects/TMinus5/CometServer/node_modules/apnagent/node_modules/lotus/lib/lotus/decoder.js:138:18) at Buffers.g (events.js:260:16) at emitOne (events.js:77:13) at Buffers.emit (events.js:169:7) at Buffers.push (/Users/jim/Projects/TMinus5/CometServer/node_modules/apnagent/node_modules/lotus/node_modules/bufs/lib/bufs.js:73:10) at Decoder._write (/Users/jim/Projects/TMinus5/CometServer/node_modules/apnagent/node_modules/lotus/lib/lotus/decoder.js:154:15) at doWrite (_stream_writable.js:292:12) at writeOrBuffer (_stream_writable.js:278:5) at Decoder.Writable.write (_stream_writable.js:207:11) at TLSSocket. (/Users/jim/Projects/TMinus5/CometServer/node_modules/apnagent/lib/apnagent/agent/live.js:159:18) at emitOne (events.js:77:13) at TLSSocket.emit (events.js:169:7) at readableAddChunk (_stream_readable.js:146:16) at TLSSocket.Readable.push (_stream_readable.js:110:10) at TLSWrap.onread (net.js:521:20) npm ERR! Test failed. See above for more details.

logicalparadox commented 9 years ago

Interesting indeed....

According to apn binary spec that should only ever be an 8 (as this is the response decoder).

Apple only ever sends a response back if the message had a problem. Since you both get 11 and there is no error code associated with 11, that should be getting parsed out. Furthermore, since you are both getting 11 it seems weird that it is left-overs from the identifier, as that would yield different results every time.

Before fixing this need to figure out where the 11 is coming from. Try sending a message that will trigger each of the error scenarios. Also, did either of you get an actual response error prior to this stack getting triggered?

ExploreMqt commented 9 years ago

This is everything from the last passing test to the point I restarted tests 71 passing (68ms)

/Users/jim/Projects/TMinus5/CometServer/test/botVotingTests.js:156 : spy ^ SyntaxError: Unexpected token : at exports.runInThisContext (vm.js:53:16) at Module._compile (module.js:413:25) at Object.Module._extensions..js (module.js:448:10) at Module.load (module.js:355:32) at Function.Module._load (module.js:310:12) at Module.require (module.js:365:17) at require (module.js:384:17) at /Users/jim/Projects/TMinus5/CometServer/node_modules/mocha/lib/mocha.js:192:27 at Array.forEach (native) at Mocha.loadFiles (/Users/jim/Projects/TMinus5/CometServer/node_modules/mocha/lib/mocha.js:189:14) at Mocha.run (/Users/jim/Projects/TMinus5/CometServer/node_modules/mocha/lib/mocha.js:422:31) at loadAndRun (/Users/jim/Projects/TMinus5/CometServer/node_modules/mocha/bin/_mocha:353:22) at rerun (/Users/jim/Projects/TMinus5/CometServer/node_modules/mocha/bin/_mocha:380:5) at /Users/jim/Projects/TMinus5/CometServer/node_modules/mocha/bin/_mocha:388:7 at StatWatcher. (/Users/jim/Projects/TMinus5/CometServer/node_modules/mocha/lib/utils.js:166:36) at emitTwo (events.js:87:13) at StatWatcher.emit (events.js:172:7) at StatWatcher._handle.onchange (fs.js:1285:10) events.js:141 throw er; // Unhandled 'error' event ^ Error: DecoderStream 11 not implemented. at Decoder._nudge (/Users/jim/Projects/TMinus5/CometServer/node_modules/apnagent/node_modules/lotus/lib/lotus/decoder.js:138:18) at Buffers.g (events.js:260:16) at emitOne (events.js:77:13) at Buffers.emit (events.js:169:7) at Buffers.push (/Users/jim/Projects/TMinus5/CometServer/node_modules/apnagent/node_modules/lotus/node_modules/bufs/lib/bufs.js:73:10) at Decoder._write (/Users/jim/Projects/TMinus5/CometServer/node_modules/apnagent/node_modules/lotus/lib/lotus/decoder.js:154:15) at doWrite (_stream_writable.js:292:12) at writeOrBuffer (_stream_writable.js:278:5) at Decoder.Writable.write (_stream_writable.js:207:11) at TLSSocket. (/Users/jim/Projects/TMinus5/CometServer/node_modules/apnagent/lib/apnagent/agent/live.js:159:18) at emitOne (events.js:77:13) at TLSSocket.emit (events.js:169:7) at readableAddChunk (_stream_readable.js:146:16) at TLSSocket.Readable.push (_stream_readable.js:110:10) at TLSWrap.onread (net.js:521:20) npm ERR! Test failed. See above for more details. Jims-MBP-2:CometServer jim$ npm test

ExploreMqt commented 9 years ago

I have autoSave turned on for my editor, so I frequently get "unexpected token" issues in my test records.

yourei commented 9 years ago

I am getting the same error on my server side as well. Any updates? Thanks!

alexpersian commented 9 years ago

Just to add more information to this issue, we have been getting the same error on our server using apnagent. Here's a screen grab. error