PAMI icon indicating copy to clipboard operation
PAMI copied to clipboard

Call to a member function addEvent() on boolean

Open Shinhan opened this issue 8 years ago • 6 comments

We've been getting this intermittent error message in our logs, and would like this fixed.

Uncaught PHP Exception Symfony\Component\Debug\Exception\FatalErrorException: "Error: Call to a member function addEvent() on boolean" at /vendor/marcelog/pami/src/PAMI/Client/Impl/ClientImpl.php line 288

Full path changed to relative path for privacy reasons.

Shinhan avatar Oct 12 '16 11:10 Shinhan

Hello,

It's hard to say anything without knowing what you're doing exactly and with what (Asterisk version, action(s) that you're sending, logs for both the action sent and response and events received) but I'd say that your asterisk is returning a response without an ActionID header and that means a broken AMI implementation.

Please attach the logs for the action sent and the traffic coming in from Asterisk, as well as the asterisk version.

marcelog avatar Oct 12 '16 11:10 marcelog

Asterisk version is 1.6.2.6

I don't have the logs for the specific package that cause this fatal error since the logging is performed at the end of the script and this is a fatal error. The way I'm using this is parsing CoreShowChannelsAction events for any active calls (by doing lots of different getKey calls on the events) and at the end I log the output of getRawContent for each event.

All I can give you are logs for the next event (which did not have a fatal error) (I've only redacted real phone numbers):

[ { "Event" : "CoreShowChannel\r", "ActionID" : "1476172502.1219\r", "Channel" : "SIP/870-00009846\r", "UniqueID" : "1476172339.46774\r", "Context" : "DLPN_DialPlan870\r", "Extension" : "", "Priority" : "1\r", "ChannelState" : "6\r", "ChannelStateDesc" : "Up\r", "Application" : "AppDial\r", "ApplicationData" : "(Outgoing Line)\r", "CallerIDnum" : "870\r", "Duration" : "00:00:23\r", "AccountCode" : "", "BridgedChannel" : "SIP/trunk-Telekom-00009842\r", "BridgedUniqueID" : "1476172262.46770\r", "BridgedCallerIDnum" : "" }, { "Event" : "CoreShowChannel\r", "ActionID" : "1476172502.1219\r", "Channel" : "SIP/trunk-Telekom-00009842\r", "UniqueID" : "1476172262.46770\r", "Context" : "macro-realstexten\r", "Extension" : "s\r", "Priority" : "12\r", "ChannelState" : "6\r", "ChannelStateDesc" : "Up\r", "Application" : "Dial\r", "ApplicationData" : "SIP/870,30,tTkKWwXx\r", "CallerIDnum" : "\r", "Duration" : "00:00:23\r", "AccountCode" : "", "BridgedChannel" : "SIP/870-00009846\r", "BridgedUniqueID" : "1476172339.46774\r", "BridgedCallerIDnum" : "870" }, { "Event" : "CoreShowChannel\r", "ActionID" : "1476172502.1219\r", "Channel" : "SIP/403-00009834\r", "UniqueID" : "1476171728.46755\r", "Context" : "DLPN_DialPlan403\r", "Extension" : "", "Priority" : "1\r", "ChannelState" : "6\r", "ChannelStateDesc" : "Up\r", "Application" : "AppDial\r", "ApplicationData" : "(Outgoing Line)\r", "CallerIDnum" : "403\r", "Duration" : "00:10:33\r", "AccountCode" : "", "BridgedChannel" : "SIP/trunk-Telekom-00009831\r", "BridgedUniqueID" : "1476171709.46752\r", "BridgedCallerIDnum" : "" }, { "Event" : "CoreShowChannel\r", "ActionID" : "1476172502.1219\r", "Channel" : "SIP/trunk-Telekom-00009831\r", "UniqueID" : "1476171709.46752\r", "Context" : "macro-realstexten\r", "Extension" : "s\r", "Priority" : "12\r", "ChannelState" : "6\r", "ChannelStateDesc" : "Up\r", "Application" : "Dial\r", "ApplicationData" : "SIP/403,6,tTkKWwXx\r", "CallerIDnum" : "", "Duration" : "00:10:34\r", "AccountCode" : "", "BridgedChannel" : "SIP/403-00009834\r", "BridgedUniqueID" : "1476171728.46755\r", "BridgedCallerIDnum" : "403" } ]

Shinhan avatar Oct 12 '16 12:10 Shinhan

I'm investigating on it. I think could be a problem with concurrency requests from different processes.

The only reason that piece of code could fail, it's with a message with an ActionId.

I'm having the same problem and I added a logger few minutes ago. I will let you know, because we should first know which kind of message causes the problem.

thomasvargiu avatar Nov 26 '16 15:11 thomasvargiu

Ok. Problem is much serious. I think we have truncated message. Probably I'll write a fix soon

thomasvargiu avatar Nov 26 '16 16:11 thomasvargiu

I can't find the problem in the code. I'll activate the logger next week. @Shinhan Can you try injecting a logger you too? I would like to know which message can cause the problem.

thomasvargiu avatar Nov 26 '16 20:11 thomasvargiu

https://github.com/marcelog/PAMI/blob/master/src/PAMI/Client/Impl/ClientImpl.php

There's another one in the else statement.

in ::process():

                $response = $this->findResponse($event);
                $response->addEvent($event);
    protected function findResponse(IncomingMessage $message)
    {
        $actionId = $message->getActionId();
        if (isset($this->incomingQueue[$actionId])) {
            return $this->incomingQueue[$actionId];
        }
        return false;
    }

edge90 avatar Nov 29 '18 10:11 edge90