# IFrame method integration failing intermittently

**URL:** <https://forums.rocket.chat/t/iframe-method-integration-failing-intermittently/10686>\
**Category:** Development\
**Tags:** rocketchat-apps\
**Created:** [March 18, 2021, 2:00am UTC](https://forums.rocket.chat/t/iframe-method-integration-failing-intermittently/10686 "2021-03-18T02:00:17Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Soham](https://avatars.discourse-cdn.com/v4/letter/s/7ea924/32.png) [@Soham](https://forums.rocket.chat/u/Soham)\
**Post date:** [March 18, 2021, 2:00am UTC](https://forums.rocket.chat/t/iframe-method-integration-failing-intermittently/10686/1 "2021-03-18T02:00:18Z")

</div>

Hi,

I have implemented integration using the IFrame integration. I explicitly logout the user when he leaves the page. After the user comes back to the page we I am getting

`Uncaught Error: Methods should only receive results once`

How to solve this ?

Thank you.

---

<div class="post-metadata">

**Author:** ![dave.koo](https://sea1.discourse-cdn.com/flex021/user_avatar/forums.rocket.chat/dave.koo/32/2204_2.png) [@dave.koo](https://forums.rocket.chat/u/dave.koo)\
**Post date:** [March 20, 2021, 1:17am UTC](https://forums.rocket.chat/t/iframe-method-integration-failing-intermittently/10686/2 "2021-03-20T01:17:08Z")

</div>

I’m having a similar/related problem (same error message) but without using IFrames.

In my case I’m using standard email/password authentication. Whenever a logged-in user disconnects from the RC server and then reconnects, the client attempts to log the user in again immediately after the reconnect using the login token in the browser’s localStorage (if one exists).

If there is an error during that auto-login process, the user will not be logged in. If they were previously logged in, they will be logged out (which is what’s happening in my case - the user who was previously logged in is sometimes getting logged out immediately after reconnecting).

I’ve been looking into the source code for the accounts-base package which handles all the common auth logic. I’ll reply here when I find the cause of the issue since there’s a good chance it will be the same solution for you.

---

<div class="post-metadata">

**Author:** ![dave.koo](https://sea1.discourse-cdn.com/flex021/user_avatar/forums.rocket.chat/dave.koo/32/2204_2.png) [@dave.koo](https://forums.rocket.chat/u/dave.koo)\
**Post date:** [March 21, 2021, 9:18pm UTC](https://forums.rocket.chat/t/iframe-method-integration-failing-intermittently/10686/3 "2021-03-21T21:18:53Z")

</div>

So upon further troubleshooting, this appears to be due to a couple bugs in Meteor’s DDP client code. I’ve just opened a ticket with Meteor here:

> <https://github.com/meteor/meteor/issues/11355>
>
> I've noticed recently that some Meteor method calls don't complete successfully.
> Checking the browser console shows a couple different errors:
> Methods should only...

I’m still trying to figure out the 2nd bug I mention in that ticket (why currentMethodBlock is sometimes missing the method invoker for the corresponding DDP result message). I’ll post another update here when I’ve got that sorted out, hopefully later today since it’s a blocker on my current RC project.

Once I have a solution, we should be able to implement it right away by putting the fixed version of ddp-client into the /packages directory of the RC app while waiting for Meteor to fix it on their end.

@aaron.ogle @sing.li just a heads up that this could be affecting other parts of RC: anywhere multiple Meteor method calls are happening in parallel or in quick succession causing intermittent errors/bugs.

---

<div class="post-metadata">

**Author:** ![dave.koo](https://sea1.discourse-cdn.com/flex021/user_avatar/forums.rocket.chat/dave.koo/32/2204_2.png) [@dave.koo](https://forums.rocket.chat/u/dave.koo)\
**Post date:** [March 25, 2021, 7:19am UTC](https://forums.rocket.chat/t/iframe-method-integration-failing-intermittently/10686/4 "2021-03-25T07:19:02Z")

</div>

UPDATE: I’ve done some more digging and posted my final analysis and workaround here:

> [@User is sometimes logged out right after reconnecting to the RC server](https://forums.rocket.chat/t/user-is-sometimes-logged-out-right-after-reconnecting-to-the-rc-server/10671):
>
> Description tl;dr Can anyone think of a reason why the Rocket Chat web app would randomly log a user out when their browser reconnects to the RC server after being offline for a while? I’m using standard email/password auth and am nowhere near the 90 day login expiration threshold. It’s currently happening around once a day to my users. ============================== I’ve customized RC to properly install and function as a PWA (with very basic service worker). I have the PWA installed on my A…

The same solution will likely work for this IFrame issue as well.
