8

I am running an openSUSE Tumbleweed installation with KDE Plasma 5.4.3 . I tend to use a fair number of programs ( Eclipse, Firefox, Slack, Evolution, Konsole, various java applications ) and after some time I can't open new programs anymore due to

Maximum number of clients reachedxlsclients:  unable to open display ":0"

I am unable to determine which program causes the error. When xlsclients works it displays around 20-30 programs so I suspect that it does not display the right information.

How can I debug this issue and find out which program causes the error?

thanasisp
  • 8,122

1 Answers1

7

xlsclients and xrestop didn't tell me much, either. Most writeups of people researching this problem focus on finding the total open Unix sockets. But the lsofc -c Xorg advice is much better.

However, you can use ss to get at that info more directly these days. This command shows me the unix (local) sockets connecting to Xorg:

sudo ss -x src "*/tmp/.X11-unix/*" 

You might need to experiment with the filter part to get it to work on your environment. Experiment with sudo ss -x alone to see everything and try to filter from there.

I can't find a way to have ss identify the source app (like lsofc does) but with a few pipes I can get to this:

sudo ss -x src "*/tmp/.X11-unix/*" | grep -Eo "[0-9]+\s*$" | while read port
do sudo ss -p -x | grep -w $port | grep -v X11-unix 
done | grep -Eo '".+"' | sort | uniq -c | sort -rn

Output looks like this:

  8 "slack"
  8 "code"
  7 "brave"
  5 "kded5"
  2 "kwin_x11"
  2 "ksmserver"
  2 "kscreen_backend"
  1 "zoom"
  1 "zim"
  :

When I ran this while getting the "Maximum number of clients reached" problem, this search turned up a list of 256 clients. So I'm pretty confident that this is the right tool to find the culprit.

You can find out more about ss at these pages:

Here's a commented version of that gnarly script line:

sudo ss -x src "*/tmp/.X11-unix/*" |  # List X11 sessions
  grep -Eo "[0-9]+\s*$" |             # extract the port number
  while read port ; do                # For every connected port
    sudo ss -p -x | grep -w $port |   #   Find the connecting process
    grep -v X11-unix                  #   but ignore the x11 side
  done | grep -Eo '".+"' |            # extract process names
  sort | uniq -c |                    # Count the number of repeats
  sort -rn                            # And sort them descending by count
Phil Hord
  • 233
  • 1
    Nice command thank you, in May'22 on my fedora 36 it showed kded5 was hogging all the windows, killing the kded5 process fixed it. Putting this here as this question was my best google hit for the error. – Yann TM May 09 '22 at 12:08
  • 2
    Thank you for this script Phil Hord! I was unable to find this information any other way. @YannTM Same here on kded5, I reported the issue at https://bugs.kde.org/show_bug.cgi?id=453280 -- please upvote and comment. – Raman May 10 '22 at 13:46
  • I saw that and already commented two days ago, @Raman. I went searching for a solution again and found your bug report. "Hey! He links to a script. I wonder if it's better than the others." And it linked to my script. lol Glad I could help move the ball forward. Didn't expect it to pay off so fast. :-D – Phil Hord May 10 '22 at 22:50
  • Lol love it when stuff like that happens. – Raman May 10 '22 at 23:52
  • Yep, same issue with kded5, running killall kded5 helped me – Stardust Jul 17 '22 at 20:39