iantrich / restriction-card

🔒 Apply restrictions to Lovelace cards
MIT License
265 stars 23 forks source link

Card Bug? Client exceeded max pending messages #3

Closed kathy705 closed 4 years ago

kathy705 commented 4 years ago

Hi, when I let Home Assistant open for a while, I get hundreds of these entries in my log: ERROR (MainThread) [homeassistant.components.websocket_api.http.connection.139694929600976] Client exceeded max pending messages [2]: 512 Additionally the "reconnecting" toast message flashes up and dissapears alternating. When I remove the restriction card everything is fine again. Is there any way to read the pending messages and check their origin or something like that? Best regards, Kathy

iantrich commented 4 years ago

Can you share your config so I can try to reproduce?

kathy705 commented 4 years ago

How much do you need? The card config, lovelace config or the complete HA config?

kathy705 commented 4 years ago

Hi, today the error didn't appear anymore. Maybe it was just network problem or something like this and this card was just the proverbial straw that broke the camel's back. I'll close this for now and keep an eye on that error message. If it comes back, I check out if removing other cards also help (I only removed just this one, because it was the last one added and had no problems before). Sorry for bothering you!

kathy705 commented 4 years ago

Update: The error is back and the restriction card is at the moment the only cause I can find. I can imagine that there are several errors coming together.

What might cause the issue, that the restriction card seems to reload the underlying card very often. This is visible with cards that take a moment to refresh after reload (I used the mini-graph-card just for demonstration purpose - that's of course not a real usecase): card2 There's also an error in the console: card The error does not appear when I use an internal card like the map-card, but the reload issue also happens.

And last but not least - here's the config of the card (but I don't think it helps in that case)

card:
  color_thresholds:
    - color: '#c0392b'
      value: 48
    - color: '#f5c400'
      value: 38
    - color: '#5abd20'
      value: 32
  entities:
    - sensor.cpu_temperatur
  height: 50
  hours_to_show: 24
  line_width: 3
  points_per_hour: 4
  show:
    labels: true
    points: hover
  type: 'custom:mini-graph-card'
type: 'custom:restriction-card'
iantrich commented 4 years ago

The card should be only recreated if your configuration changes or if you are using the condition option to make the lock dependent on the state of another entity. You don't have that second piece, so that's not it. I'll see if I can reproduce. Are you seeing this on any other cards besides mini-graph-card? I seem to recall a similar issue for the mini-graph-card in the vertical-stack-in-card.

iantrich commented 4 years ago

Is is just custom cards? I might have a theory then...

kathy705 commented 4 years ago

This also happens e.g. with the iframe card and map card. I just found out that if I have multiple cards in one view, all of them refresh at the same time and it seems to happen anytime some other event happens. E.g. when I click execute on a script, I can see that the card refreshes everytime I click.

iantrich commented 4 years ago

sounds like the "ll-rebuild" event is being fired indefinitely. that's for the details, I'll see what I can find.

kathy705 commented 4 years ago

FYI: It doesn't seem to be any custom_component or custom lovelace addon (like any custom-card or CCH or card-mod etc), as I just removed everything and the problem still persists.

maram-code commented 4 years ago

I seem to have the same problem!

iantrich commented 4 years ago

Can either of you provide me the simplest view configuration you have that present this issue?

iantrich commented 4 years ago

Also, is the "max pending messages" still happening or just the flashing of cards now?

kathy705 commented 4 years ago

The simplest view config with which the problem occurs is this:

  - title: TEST
    path: test
    badges: []
    cards:
      - type: 'custom:restriction-card'
        card:
          type: map
          entities: []

And max pending messages is still happening

iantrich commented 4 years ago

I can't seem to replicate, but I'm guessing you also have a lot of incoming updates on your system. Even then, like I said earlier, the restriction-card only re-renders if your config changes or a condition changes under the conditions option. Otherwise it is just a pass-through, sending the hass object down to the child, but not re-rendering anything, itself.

Can you try putting the map in a vertical-stack, maybe even the custom vertical-stack-in-card and see if the issue persists?

ludeeus commented 4 years ago

Another thing, try using /local/community/restriction-card/restriction-card.js to make sure HACS is not doing anything funny here.

Clear the cache to make the change.

kathy705 commented 4 years ago

You mean this way, right? (replacing restriction card with vertical stack):

type: 'custom:vertical-stack-in-card'
cards:
  - type: map
    entities: []
type: vertical-stack
cards:
  - type: map
    entities: []

With this, the flashing is gone.

@ludeeus I already tried that, but tried again and it didn't help

iantrich commented 4 years ago

I'll try to do some further digging tonight

kathy705 commented 4 years ago

I reduced my complete lovelace config to this, opened in another browser which never opened HA before (so absolutely not cached) and the problem persists:

resources:
  - type: js
    url: /local/community/restriction-card/restriction-card.js
title: Home
views:
  - title: TEST
    path: test
    badges: []
    cards:
      - type: 'custom:restriction-card'
        card:
          type: map
          entities: []

I also missed to confirm: Yes, I have lots of incoming updates on my system. Thank you very much for your effort!

iantrich commented 4 years ago

Got a test environment setup and found the bug right away :tada: was a simple typo in my update check :see_no_evil: thanks, everyone!

kathy705 commented 4 years ago

Yeah! It's working 🎉 Thank you!