Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trying to push to an undefined event. #16

Open
human39 opened this issue Dec 9, 2013 · 8 comments
Open

Trying to push to an undefined event. #16

human39 opened this issue Dec 9, 2013 · 8 comments

Comments

@human39
Copy link

human39 commented Dec 9, 2013

Hello!

I built a call center monitoring application with NAMI.

I'm currently working on another program (not node.js/nami) to Originate a call. Every so often I'm getting the crash on the monitoring application

(Paths changed)

/home/user/app/node_modules/nami/src/nami.js:70
this.responses[event.actionid].events.push(event);
^
TypeError: Cannot read property 'events' of undefined
at Nami.onRawEvent
(/home/user/app/node_modules/nami/src/nami.js:70:39)
at Nami.EventEmitter.emit (events.js:96:17)
at Nami.onRawMessage
(/home/user/app/node_modules/nami/src/nami.js:119:14)
at Nami.EventEmitter.emit (events.js:96:17)
at Nami.onData
(/home/user/app/node_modules/nami/src/nami.js:142:14)
at Socket.Nami.onWelcomeMessage
(/home/user/app/node_modules/nami/src/nami.js:182:18)
at Socket.EventEmitter.emit (events.js:96:17)
at TCP.onread (net.js:392:31)

Even though I can't reproduce this all the time, I think this is directly related to my Originate or checking for OriginateResponse..

Other info: npm ls

├─┬ [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ ├─┬ [email protected]
│ │ ├── [email protected]
│ │ ├── [email protected]
│ │ ├── [email protected]
│ │ └── [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ └─┬ [email protected]
│ └── [email protected]
├── [email protected]
├─┬ [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ └── [email protected]
├─┬ [email protected]
│ └── [email protected]
└─┬ [email protected]
├── [email protected]
├── [email protected]
└─┬ [email protected]
├─┬ [email protected]
│ └── [email protected]
├── [email protected]
├─┬ [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ └── [email protected]
└── [email protected]

@rooftopsparrow
Copy link
Contributor

I am also seeing this randomly on boot. Trying to track down the source of the problem...I'll update here if I find the reason.

[2013-12-20T19:54:35.913Z] FATAL: liveserver/89541 on host: Cannot call method push of undefined
TypeError: Cannot call method push of undefined
    at Nami.onRawEvent (~/node_modules/nami/src/nami.js:77:47)
    at Nami.EventEmitter.emit (events.js:95:17)
    at Nami.onRawMessage (~/node_modules/nami/src/nami.js:130:14)
    at Nami.EventEmitter.emit (events.js:95:17)
    at Nami.onData (~/node_modules/nami/src/nami.js:153:14)
    at Socket.<anonymous> (~/node_modules/nami/src/nami.js:197:18)
    at Socket.EventEmitter.emit (events.js:95:17)
    at Socket.<anonymous> (_stream_readable.js:746:14)
    at Socket.EventEmitter.emit (events.js:92:17)
    at emitReadable_ (_stream_readable.js:408:10)

@rooftopsparrow
Copy link
Contributor

After dealing with this for a while I've narrowed it down to a quite specific case and is inline with the issue that @human39 is seeing as well.

When the socket is up and active, I can send an Action to AMI, like Ping for example, and get back Pong meaning that the keepalive was successful. However, there is a chance that the socket will get removed BEFORE response on the socket is fully read somehow.

Below is a scenario.

[2014-02-04T19:52:25.240Z]  INFO:  PING
[2014-02-04T19:52:25.561Z]  INFO:  PONG
[2014-02-04T19:52:25.561Z]  INFO:  Keep Alive successful
[2014-02-04T19:53:42.728Z]  INFO: PING
[2014-02-04T19:53:43.249Z]  WARN: Lost connection to the AMI. Reopening connection...
[2014-02-04T19:53:45.989Z] FATAL:  uncaughtException
    TypeError: Cannot call method push of undefined
        at Nami.onRawEvent (~/node_modules/nami/src/nami.js:77:47)
        at Nami.EventEmitter.emit (events.js:95:17)
        at Nami.onRawMessage (~/node_modules/nami/src/nami.js:130:14)
        at Nami.EventEmitter.emit (events.js:95:17)
        at Nami.onData (~/node_modules/nami/src/nami.js:153:14)
        at Socket.<anonymous> (~/node_modules/nami/src/nami.js:197:18)
        at Socket.EventEmitter.emit (events.js:95:17)
        at Socket.<anonymous> (_stream_readable.js:746:14)
        at Socket.EventEmitter.emit (events.js:92:17)
        at emitReadable_ (_stream_readable.js:408:10)

@human39
Copy link
Author

human39 commented Feb 4, 2014

I've since updated NAMI and rewrote the other application that seemed to be triggering this bug in Node(using NAMI). I haven't been bitten by this since then. Unfortunately, I don't have any more useful information than that.

@marcelog
Copy link
Owner

marcelog commented Feb 5, 2014

hey guys, thanks for discussing this! is there any chance that i can get a small example that triggers this error? i'll be happy to work on this, just need more info, since i haven't run into this issue myself

@rooftopsparrow
Copy link
Contributor

Hey @marcelog! Thanks for the interest.

Unfortunately its hard to reproduce because it is definitely based on network latency / stability. The network needs to be degraded to about 5-10% packet loss and some latency on the socket. If the network is really bad (really high packet loss and latency or even no connectivity), Nami performs as expected and cleanly kills the sockets. At least this is the experience I've had.

I will try to come up with a solid repro and let you know.

@marcelog
Copy link
Owner

marcelog commented Feb 5, 2014

hey :) mm interesting.. will look at the code, and see if i spot anything bad that could match with that scenario.. btw, sorry about not replying before (for both @rooftopsparrow and @human39), somehow i missed the email from github, please let me know if there are any updates, will do too

@jbasg
Copy link

jbasg commented Aug 29, 2014

Hola, ante todo felicitarte por el gran trabajo realizado. Yo he sufrido este error, creo que es debido a algún evento de respuesta a alguna accion hecha desde otra conexion ami . En mi caso lo he solucionado validando que exista el objeto this.responses[event.actionid] en el método onRawEvent


if (this.responses[event.actionid]){
this.responses[event.actionid].events.push(event) ;
}
Espero que sirva de ayuda. Saludos.

@marcelog
Copy link
Owner

Hey guys, could you join the comments on this pull https://github.com/marcelog/Nami/pull/30/files#r20016474? Seems to be the same thing or related, and more eyes could be useful :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants