Live Helper Chat support forum.. Old google groups forum can be found here

You are not logged in.

Announcement

#1 2021-01-08 15:24:33

elplaza
Member
Registered: 2020-12-07
Posts: 21

Failed to load chat object

Hi,
I'm go crazy with a strage problem  mad

My listener is on start chat event and have to push a message to the chat.
To do this, in my listener, I make a api call to /restapi/addmsgadmin but chat was not found:
            $Chat = erLhcoreClassChat::getSession()->load( 'erLhcoreClassModelChat', $form->chat_id);

            if (!($Chat instanceof erLhcoreClassModelChat)) {
                throw new Exception('Chat could not be found!');
            }

Exception message is:
A query failed internally in Persistent Object: No object of class 'erLhcoreClassModelChat' with id '844409'.

So I try to investigate deeper adding some log with erLhcoreClassLog::write before the call and after.
The strange thing is:
- before the call: $Chat = erLhcoreClassChat::getSession()->load( 'erLhcoreClassModelChat', $chatId);   found the chat
- after the call, as I said before, using same method, chat was not found!

p.s. searching in database with a db client I the chat was found

p.s. there is another way to add message to chat other than api call?

Thanks in advance

Last edited by elplaza (2021-01-08 15:51:11)

Offline

#2 2021-01-08 15:51:32

remdex
Administrator
From: Lithuania
Registered: 2012-09-23
Posts: 3,368
Website

Re: Failed to load chat object

If you are listening to `chat.chat_started` older LHC versions were executing this event during db transactions. It means that transaction is not commited yet and any other call would not see this chat yet. Newer versions calls this after transaction is commited so this problem dissapears.

So please update your LHC version. Or describe how exactly you are starting a chat.

Offline

#3 2021-01-12 10:04:08

elplaza
Member
Registered: 2020-12-07
Posts: 21

Re: Failed to load chat object

Hi remdex,
I'm starting chat in this way:
- widget in external site page
- added listener on event chat.chat_started, get params and make api call

Thanks in advance,

Offline

#4 2021-01-12 10:05:05

remdex
Administrator
From: Lithuania
Registered: 2012-09-23
Posts: 3,368
Website

Re: Failed to load chat object

Same response applies as above and I have nothing to add...

Offline

Board footer