[Erledigt] Connections-Problem

Begonnen von FunkOdyssey, 08 August 2016, 13:03:02

Vorheriges Thema - Nächstes Thema

FunkOdyssey

Hallo,
ich habe mich sehr über das neuen Attribut "attr global dnsServer x.x.x.x" gefreut. Jedoch habe ich irgendetwas in meiner FHEM-Installation, was sich mit diesem Attribut überhaupt nicht versteht. Es werden immer mehr neue Connections/Files geöffnet. Das geht solange gut bis es sich in den Logs sammelt und damit FHEM langfristig zum Absturz bringt. Im FHEM-Log machen sich die Problem dann erkennbar, da verschiedene Module mit der Menge an Connections/Files(?) nicht klarkommen.

Loading device description failed with error: 500 Can't connect to 192.168.178.2:49000 (No route to host) at ./FHEM/00_SONOS.pm line 3747 thread 1
Hinweis: Das ist überhaupt nicht mein IP-Bereich.

2016.08.05 17:08:23 1: Accept failed (telnetForBlockingFn_1470298793.96777: Too many open files)

2016.08.05 17:07:41 1: FHEMWEB SSL/HTTPS error: Too many open files Failed to open Private Key error:02001018:system library:fopen:Too many open files

2016.08.05 16:51:23 3: Wetter: Cant create UDP socket:Too many open files

Wie gesagt: Entferne ich das Attribut, so habe ich wieder Ruhe. Ob das nun Ursache oder Auslöser ist, kann ich nicht sagen. Vielleicht läuft ja grundsätzlich etwas falsch und ich sehe es erst durch das Attribut dnsServer.

Hat jemand einen Tipp für mich? Danke.




Anbei ein wenig Debug-Informationen:

list .* FD

FritzBoxCallMonitor            29
Sonos                    183
WEB                      7
WEB_197.149.226.14_63046     239
WEB_87.107.89.153_50012     238
WEBapp                   9
WEBapp_127.0.0.1_51053     176
WEBhook                  6
WEBintern                8
ZWDongle_0               124
httpmod           242
hmusb                    5
pi_ctrl                  38
telnetForBlockingFn_1470645706.5302     4
telnetPort               11


ps aux | grep fhem


root      2370  0.0  0.1   1788  1248 ?        Ss   Aug06   0:00 startpar -f -- fhem
fhem     22336  3.0  7.1  71872 67632 ?        S    10:41   4:00 /usr/bin/perl fhem.pl fhem.cfg
fhem     22348  0.3  4.0  67600 38384 ?        Sl   10:41   0:28 /usr/bin/perl ./FHEM/00_SONOS.pm 4711 1 0
fhem     22356  0.0  5.9  62664 56584 ?        S    10:41   0:01 /usr/bin/perl fhem.pl fhem.cfg
root     22405  0.0  0.2   4768  2380 pts/0    S    10:46   0:00 su fhem
fhem     22406  0.0  0.3   5060  2984 pts/0    S+   10:46   0:00 bash
root     23296  0.0  0.1   3768  1820 pts/2    S+   12:50   0:00 grep fhem


lsof -p 22336 

COMMAND   PID USER   FD   TYPE DEVICE SIZE/OFF   NODE NAME
perl    22336 fhem  cwd    DIR  179,2     4096 149018 /opt/fhem
perl    22336 fhem  rtd    DIR  179,2     4096      2 /
perl    22336 fhem  txt    REG  179,2     9800  26399 /usr/bin/perl
perl    22336 fhem  mem    REG  179,2  1607760   9446 /usr/lib/locale/locale-archive
perl    22336 fhem  mem    REG  179,2   140788  14316 /lib/arm-linux-gnueabihf/libexpat.so.1.6.0
perl    22336 fhem  mem    REG  179,2   127520 262308 /usr/lib/perl5/auto/XML/Parser/Expat/Expat.so
perl    22336 fhem  mem    REG  179,2     8624 262439 /usr/lib/perl5/auto/Device/SerialPort/SerialPort.so
perl    22336 fhem  mem    REG  179,2   379036  26370 /usr/lib/perl/5.14.2/auto/re/re.so
perl    22336 fhem  mem    REG  179,2    34748 149669 /usr/lib/perl/5.14.2/auto/threads/shared/shared.so
perl    22336 fhem  mem    REG  179,2    38808 149670 /usr/lib/perl/5.14.2/auto/threads/threads.so
perl    22336 fhem  mem    REG  179,2    22232 149702 /usr/lib/perl/5.14.2/auto/PerlIO/encoding/encoding.so
perl    22336 fhem  mem    REG  179,2    38612  20351 /lib/arm-linux-gnueabihf/libnss_nis-2.19.so
perl    22336 fhem  mem    REG  179,2    71628  20339 /lib/arm-linux-gnueabihf/libnsl-2.19.so
perl    22336 fhem  mem    REG  179,2    30592  20341 /lib/arm-linux-gnueabihf/libnss_compat-2.19.so
perl    22336 fhem  mem    REG  179,2     9684  26363 /usr/lib/perl/5.14.2/auto/Cwd/Cwd.so
perl    22336 fhem  mem    REG  179,2    13128   2649 /usr/lib/perl5/auto/Text/Iconv/Iconv.so
perl    22336 fhem  mem    REG  179,2    17880 149689 /usr/lib/perl/5.14.2/auto/Encode/Unicode/Unicode.so
perl    22336 fhem  mem    REG  179,2    42800 261949 /usr/lib/perl5/auto/HTML/Parser/Parser.so
perl    22336 fhem  mem    REG  179,2     9716 149668 /usr/lib/perl/5.14.2/auto/I18N/Langinfo/Langinfo.so
perl    22336 fhem  mem    REG  179,2    30496 149685 /usr/lib/perl/5.14.2/auto/Encode/Encode.so
perl    22336 fhem  mem    REG  179,2    19564 133229 /usr/lib/perl5/auto/Socket6/Socket6.so
perl    22336 fhem  mem    REG  179,2    29660  59260 /usr/lib/perl5/auto/IO/Interface/Interface.so
perl    22336 fhem  mem    REG  179,2     5520 149663 /usr/lib/perl/5.14.2/auto/Sys/Hostname/Hostname.so
perl    22336 fhem  mem    REG  179,2     9724 149664 /usr/lib/perl/5.14.2/auto/Filter/Util/Call/Call.so
perl    22336 fhem  mem    REG  179,2    75620 149658 /usr/lib/perl/5.14.2/auto/Compress/Raw/Zlib/Zlib.so
perl    22336 fhem  mem    REG  179,2    18040  26368 /usr/lib/perl/5.14.2/auto/File/Glob/Glob.so
perl    22336 fhem  mem    REG  179,2    30384 149671 /usr/lib/perl/5.14.2/auto/Data/Dumper/Dumper.so
perl    22336 fhem  mem    REG  179,2    71488 149674 /usr/lib/perl/5.14.2/auto/Storable/Storable.so
perl    22336 fhem  mem    REG  179,2    53120 266557 /usr/lib/perl5/auto/JSON/XS/XS.so
perl    22336 fhem  mem    REG  179,2    75644  20363 /lib/arm-linux-gnueabihf/libresolv-2.19.so
perl    22336 fhem  mem    REG  179,2    18048  20342 /lib/arm-linux-gnueabihf/libnss_dns-2.19.so
perl    22336 fhem  mem    REG  179,2     7004  49989 /lib/libnss_mdns4_minimal.so.2
perl    22336 fhem  mem    REG  179,2    46820  20343 /lib/arm-linux-gnueabihf/libnss_files-2.19.so
perl    22336 fhem  mem    REG  179,2    87792   5180 /lib/arm-linux-gnueabihf/libz.so.1.2.7
perl    22336 fhem  mem    REG  179,2  1410392   8299 /usr/lib/arm-linux-gnueabihf/libcrypto.so.1.0.0
perl    22336 fhem  mem    REG  179,2   296732   8300 /usr/lib/arm-linux-gnueabihf/libssl.so.1.0.0
perl    22336 fhem  mem    REG  179,2     9656  26367 /usr/lib/perl/5.14.2/auto/attributes/attributes.so
perl    22336 fhem  mem    REG  179,2   402688 262154 /usr/lib/perl5/auto/Net/SSLeay/SSLeay.so
perl    22336 fhem  mem    REG  179,2    33884 154428 /usr/lib/perl5/auto/Crypt/Rijndael/Rijndael.so
perl    22336 fhem  mem    REG  179,2    13784 149683 /usr/lib/perl/5.14.2/auto/MIME/Base64/Base64.so
perl    22336 fhem  mem    REG  179,2    17932 149678 /usr/lib/perl/5.14.2/auto/Digest/MD5/MD5.so
perl    22336 fhem  mem    REG  179,2    84480  26361 /usr/lib/perl/5.14.2/auto/POSIX/POSIX.so
perl    22336 fhem  mem    REG  179,2    13840  26366 /usr/lib/perl/5.14.2/auto/Fcntl/Fcntl.so
perl    22336 fhem  mem    REG  179,2    26672  20364 /lib/arm-linux-gnueabihf/librt-2.19.so
perl    22336 fhem  mem    REG  179,2    22128  26365 /usr/lib/perl/5.14.2/auto/List/Util/Util.so
perl    22336 fhem  mem    REG  179,2    22080 149698 /usr/lib/perl/5.14.2/auto/Time/HiRes/HiRes.so
perl    22336 fhem  mem    REG  179,2    30312 262053 /usr/lib/perl5/auto/Socket/Socket.so
perl    22336 fhem  mem    REG  179,2   117520   2311 /lib/arm-linux-gnueabihf/libgcc_s.so.1
perl    22336 fhem  mem    REG  179,2    30300  20333 /lib/arm-linux-gnueabihf/libcrypt-2.19.so
perl    22336 fhem  mem    REG  179,2  1242776  20326 /lib/arm-linux-gnueabihf/libc-2.19.so
perl    22336 fhem  mem    REG  179,2   122308  20377 /lib/arm-linux-gnueabihf/libpthread-2.19.so
perl    22336 fhem  mem    REG  179,2   435804  20336 /lib/arm-linux-gnueabihf/libm-2.19.so
perl    22336 fhem  mem    REG  179,2     9820  20335 /lib/arm-linux-gnueabihf/libdl-2.19.so
perl    22336 fhem  mem    REG  179,2  1347628  26398 /usr/lib/libperl.so.5.14.2
perl    22336 fhem  mem    REG  179,2    13880  26362 /usr/lib/perl/5.14.2/auto/IO/IO.so
perl    22336 fhem  mem    REG  179,2   134448  20314 /lib/arm-linux-gnueabihf/ld-2.19.so
perl    22336 fhem  mem    REG  179,2    10170  27194 /usr/lib/arm-linux-gnueabihf/libcofi_rpi.so
perl    22336 fhem    0r   CHR    1,3      0t0   1029 /dev/null
perl    22336 fhem    1w   REG  179,2  2331586 170330 /opt/fhem/log/fhem-2016-08.log
perl    22336 fhem    2w   REG  179,2  2331586 170330 /opt/fhem/log/fhem-2016-08.log
perl    22336 fhem    3w   REG  179,2  2331586 170330 /opt/fhem/log/fhem-2016-08.log
perl    22336 fhem    4u  IPv4 135171      0t0    TCP localhost:39204 (LISTEN)
perl    22336 fhem    5u  IPv4 134110      0t0    TCP localhost:37499->localhost:1234 (ESTABLISHED)
perl    22336 fhem    6u  IPv4 134111      0t0    TCP *:omniorb (LISTEN)
perl    22336 fhem    7u  IPv4 134112      0t0    TCP *:8083 (LISTEN)
perl    22336 fhem    8u  IPv4 134113      0t0    TCP *:8089 (LISTEN)
perl    22336 fhem    9u  IPv4 134114      0t0    TCP *:8084 (LISTEN)
perl    22336 fhem   10w   REG  179,2  2331586 170330 /opt/fhem/log/fhem-2016-08.log
perl    22336 fhem   11u  IPv4 134115      0t0    TCP localhost:7072 (LISTEN)
...
perl    22336 fhem   29u  IPv4 134121      0t0    TCP FHEM.local:46962->fritz.box:1012 (ESTABLISHED)
...
perl    22336 fhem   38u  IPv4 134122      0t0    TCP localhost:36551->localhost:5000 (ESTABLISHED)
...
perl    22336 fhem   47u  sock    0,8      0t0 134127 can't identify protocol
...
perl    22336 fhem   52u  sock    0,8      0t0 130928 can't identify protocol
perl    22336 fhem   53u  sock    0,8      0t0 134899 can't identify protocol
...
perl    22336 fhem  124u   CHR  166,0      0t0   1455 /dev/ttyACM0
...
perl    22336 fhem  175u  sock    0,8      0t0 135172 can't identify protocol
perl    22336 fhem  176u  IPv4 134728      0t0    TCP localhost:8084->localhost:51053 (ESTABLISHED)
perl    22336 fhem  177u  sock    0,8      0t0 135074 can't identify protocol
perl    22336 fhem  178u  sock    0,8      0t0 135089 can't identify protocol
perl    22336 fhem  179u  sock    0,8      0t0 137272 can't identify protocol
perl    22336 fhem  180u  sock    0,8      0t0 135110 can't identify protocol
perl    22336 fhem  181u  sock    0,8      0t0 135009 can't identify protocol
perl    22336 fhem  182u  sock    0,8      0t0 135478 can't identify protocol
perl    22336 fhem  183u  IPv4 134801      0t0    TCP localhost:55219->localhost:4711 (ESTABLISHED)
perl    22336 fhem  184u  sock    0,8      0t0 137228 can't identify protocol
perl    22336 fhem  185u  sock    0,8      0t0 135651 can't identify protocol
perl    22336 fhem  186u  sock    0,8      0t0 137433 can't identify protocol
perl    22336 fhem  187u  sock    0,8      0t0 137313 can't identify protocol
perl    22336 fhem  188u  sock    0,8      0t0 137331 can't identify protocol
perl    22336 fhem  189u  sock    0,8      0t0 137354 can't identify protocol
perl    22336 fhem  190u  sock    0,8      0t0 137398 can't identify protocol
perl    22336 fhem  191u  sock    0,8      0t0 137467 can't identify protocol
perl    22336 fhem  192u  sock    0,8      0t0 137518 can't identify protocol
perl    22336 fhem  193u  sock    0,8      0t0 137634 can't identify protocol
perl    22336 fhem  194u  sock    0,8      0t0 141049 can't identify protocol
perl    22336 fhem  195u  sock    0,8      0t0 137582 can't identify protocol
perl    22336 fhem  196u  sock    0,8      0t0 137703 can't identify protocol
perl    22336 fhem  197u  sock    0,8      0t0 137740 can't identify protocol
perl    22336 fhem  198u  sock    0,8      0t0 137777 can't identify protocol
perl    22336 fhem  199u  sock    0,8      0t0 137805 can't identify protocol
perl    22336 fhem  200u  sock    0,8      0t0 137834 can't identify protocol
perl    22336 fhem  201u  sock    0,8      0t0 137851 can't identify protocol
perl    22336 fhem  202u  sock    0,8      0t0 136516 can't identify protocol
perl    22336 fhem  203u  sock    0,8      0t0 137904 can't identify protocol
perl    22336 fhem  204u  sock    0,8      0t0 137940 can't identify protocol
perl    22336 fhem  205u  sock    0,8      0t0 137985 can't identify protocol
perl    22336 fhem  206u  sock    0,8      0t0 138008 can't identify protocol
perl    22336 fhem  207u  sock    0,8      0t0 138028 can't identify protocol
perl    22336 fhem  208u  sock    0,8      0t0 136604 can't identify protocol
perl    22336 fhem  209u  sock    0,8      0t0 138081 can't identify protocol
perl    22336 fhem  210u  sock    0,8      0t0 138116 can't identify protocol
perl    22336 fhem  211u  sock    0,8      0t0 139913 can't identify protocol
perl    22336 fhem  212u  sock    0,8      0t0 138165 can't identify protocol
perl    22336 fhem  213u  sock    0,8      0t0 138185 can't identify protocol
perl    22336 fhem  214u  sock    0,8      0t0 140084 can't identify protocol
perl    22336 fhem  215u  sock    0,8      0t0 140144 can't identify protocol
perl    22336 fhem  216u  sock    0,8      0t0 140289 can't identify protocol
perl    22336 fhem  217u  sock    0,8      0t0 140309 can't identify protocol
perl    22336 fhem  218u  sock    0,8      0t0 140328 can't identify protocol
perl    22336 fhem  219u  sock    0,8      0t0 140349 can't identify protocol
perl    22336 fhem  220u  sock    0,8      0t0 140366 can't identify protocol
perl    22336 fhem  221u  sock    0,8      0t0 140383 can't identify protocol
perl    22336 fhem  222u  sock    0,8      0t0 140413 can't identify protocol
perl    22336 fhem  223u  sock    0,8      0t0 140437 can't identify protocol
perl    22336 fhem  224u  sock    0,8      0t0 140505 can't identify protocol
perl    22336 fhem  225u  sock    0,8      0t0 140524 can't identify protocol
perl    22336 fhem  226u  sock    0,8      0t0 140618 can't identify protocol
perl    22336 fhem  227u  sock    0,8      0t0 140543 can't identify protocol
perl    22336 fhem  228u  sock    0,8      0t0 140469 can't identify protocol
perl    22336 fhem  229u  sock    0,8      0t0 140570 can't identify protocol
perl    22336 fhem  230u  sock    0,8      0t0 140647 can't identify protocol
perl    22336 fhem  231u  sock    0,8      0t0 140716 can't identify protocol
perl    22336 fhem  232u  sock    0,8      0t0 140682 can't identify protocol
perl    22336 fhem  233u  sock    0,8      0t0 140815 can't identify protocol
perl    22336 fhem  234u  sock    0,8      0t0 140755 can't identify protocol
perl    22336 fhem  235u  sock    0,8      0t0 140785 can't identify protocol
perl    22336 fhem  236u  sock    0,8      0t0 137129 can't identify protocol
perl    22336 fhem  237u  sock    0,8      0t0 138609 can't identify protocol
perl    22336 fhem  238u  sock    0,8      0t0 141132 can't identify protocol



rudolfkoenig

Vorweg: bitte Probleme in den im MAINTAINER.txt hinterlegten Forum posten, fuer HttpUtils ist das Automatisierung.
Die Server Gruppen habe ich nicht abonniert.

HttpUtils_NonblockingGet hat in der Tat vergessen, das socket (und damit das belegte FD) abzuraeumen, falls das DNS-Lookup schiefgegangen ist. Hat aber nichts mit gesetzten dnsAddr zu tun, und das war vor dem dnsServer-Attribut-Einbau auch schon so. Habs gefixt, und eingecheckt, ab morgen per update.

HowTo check:
# ls -l /proc/<fhem-pid>/fd
fhem> { HttpUtils_NonblockingGet({ url=>"http://www.google.d3e/", callback=>sub($$$){ Log 1,"ERR:$_[1] DATA:$_[2]" } }) }
# ls -l /proc/<fhem-pid>/fd



FunkOdyssey

#2
Zitat von: rudolfkoenig am 09 August 2016, 17:19:56
Vorweg: bitte Probleme in den im MAINTAINER.txt hinterlegten Forum posten, fuer HttpUtils ist das Automatisierung.
Die Server Gruppen habe ich nicht abonniert.

Oh, das wusste ich nicht. Werde es mir merken. Ich habe den Thread nun verschoben.

Zitat von: rudolfkoenig am 09 August 2016, 17:19:56
HttpUtils_NonblockingGet hat in der Tat vergessen, das socket (und damit das belegte FD) abzuraeumen, falls das DNS-Lookup schiefgegangen ist. Hat aber nichts mit gesetzten dnsAddr zu tun, und das war vor dem dnsServer-Attribut-Einbau auch schon so. Habs gefixt, und eingecheckt, ab morgen per update.

Hmm, okay. Vielen Dank für den Fix.
Ich hätte aber wetten können, dass ich das nur mit gesetztem dnsServer-Attribut habe. Ich kann es sogar (fast) reproduzieren bzw. provozieren.

Zitat von: rudolfkoenig am 09 August 2016, 17:19:56
HowTo check:
# ls -l /proc/<fhem-pid>/fd
fhem> { HttpUtils_NonblockingGet({ url=>"http://www.google.d3e/", callback=>sub($$$){ Log 1,"ERR:$_[1] DATA:$_[2]" } }) }
# ls -l /proc/<fhem-pid>/fd


Das habe ich nun mehrmals ausprobiert.
Ohne dnsServer sind wenige socket-Einträge (ls -l /proc/<fhem-pid>/fd) hinzugekommen. Aber irgendwie auch nicht immer. Ich muss mir das mal in Ruhe anschauen.
Jedoch in dem Augenblick wo ich den DNS-Server als Attribut ergänzt hatte, wurde die socket-Liste um ein Vielfaches voller.

FHEM-Log-Ausgabe mit dnsServer:

2016.08.09 17:39:14 1: ERR:DNS: No A record found DATA:
2016.08.09 17:39:57 1: ERR:DNS: No A record found DATA:


FHEM-Log-Ausgabe ohne dnsServer:

2016.08.09 17:40:44 1: ERR:gethostbyname www.google.d3e failed DATA:
2016.08.09 17:41:30 1: ERR:gethostbyname www.google.d3e failed DATA:





Nachtrag:

Ich habe mir die neueste Version der HttpUtils.pm aus dem SVN geholt und FHEM neugestartet.
Keine Ahnung, ob das normal ist, aber ich hatte direkt nach dem Neustart ca. 10-15 "Sockets" offen.
FÜhre ich deinen Befehl aus, so sehe ich für wenige Sekunden einen neuen Sockets-Eintrag. Dieser verschwindet dann wieder.
(ich habe das ls nach Datum/Zeit sortiert)
Hier spielt es auch absolut keine Rolle, ob ein dnsAttribut gesetzt ist oder nicht.

Nun frage ich mich nur, ob eine gewisse Anzahl an "Sockets-Einträge" normal sind. :-)
Aber ich denke schon, oder?

rudolfkoenig

Eine gewisse Anzahl an Sockets ist normal: 1x pro Telnet-Verbindung, ca 6x pro Browser (das reduziert sich automatisch auf 1 oder 2).
FHEM2FHEM braucht 1 oder 2, alle per Netzwerk angebundene Geraete mind. 1, usw.

Die unterschiedlichen DNS-Fehlermeldungen sind gewollt, damit ich an dem Text sehe, wo es herkommt.

FunkOdyssey

Danke. Keine Probleme mehr hier.