{"id":5791,"date":"2021-10-01T13:58:57","date_gmt":"2021-10-01T10:58:57","guid":{"rendered":"https:\/\/skeletor.org.ua\/?p=5791"},"modified":"2021-10-01T14:27:07","modified_gmt":"2021-10-01T11:27:07","slug":"error-error-while-accepting-connection-kafka-network-acceptor","status":"publish","type":"post","link":"https:\/\/skeletor.org.ua\/?p=5791","title":{"rendered":"ERROR Error while accepting connection (kafka.network.Acceptor)"},"content":{"rendered":"\n<p>\u0414\u0430, \u0438\u043c\u0435\u043d\u043d\u043e \u0441 \u0442\u0430\u043a\u0438\u043c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435\u043c \u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u0430\u0434\u0430\u0442\u044c <strong>kafka <\/strong>\u0441\u043f\u0443\u0441\u0442\u044f \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u043f\u043e\u0441\u043b\u0435 \u0437\u0430\u043f\u0443\u0441\u043a\u0430. \u0412\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0440\u0435\u0436\u0438\u043c\u0430 <strong>debug <\/strong>\u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u043b\u043e &#8220;\u043f\u043e\u043d\u044f\u0442\u043d\u043e\u0441\u0442\u044c&#8221;<\/p>\n\n\n<p><code><br>\nERROR Error while accepting connection (kafka.network.Acceptor)<br>\njava.net.SocketException: Invalid argument<br>\n        at sun.nio.ch.Net.setIntOption0(Native Method)<br>\n        at sun.nio.ch.Net.setSocketOption(Net.java:341)<br>\n        at sun.nio.ch.SocketChannelImpl.setOption(SocketChannelImpl.java:190)<br>\n        at sun.nio.ch.SocketAdaptor.setBooleanOption(SocketAdaptor.java:271)<br>\n        at sun.nio.ch.SocketAdaptor.setTcpNoDelay(SocketAdaptor.java:306)<br>\n        at kafka.network.Acceptor.accept(SocketServer.scala:654)<br>\n        at kafka.network.Acceptor.run(SocketServer.scala:579)<br>\n        at java.lang.Thread.run(Thread.java:748)<br>\n<\/code><\/p>\n<p><!--more--><\/p>\n<p>\u041f\u043e\u0447\u0435\u043c\u0443 \u043f\u0430\u0434\u0430\u043b\u0430 <strong>kafka<\/strong>? \u041e\u043d\u0430 \u043f\u043b\u043e\u0434\u0438\u043b\u0430 \u0441\u043e\u043a\u0435\u0442\u044b \u0441 \u043f\u043e\u0440\u0442\u043e\u043c <strong>0<\/strong><\/p>\n<p><code>sockname: AF_INET 0.0.0.0 port: 0<br>\n<\/code><\/p>\n<p>\u0418 \u0441\u043e\u043a\u0435\u0442\u044b \u043d\u0435 \u0437\u0430\u043a\u0440\u044b\u0432\u0430\u043b\u0438\u0441\u044c. \u0412 \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u043c\u043e\u043c\u0435\u043d\u0442 \u0434\u043e\u0441\u0442\u0438\u0433\u0430\u043b\u0441\u044f \u043b\u0438\u043c\u0438\u0442 \u043d\u0430 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043e\u0442\u043a\u0440\u044b\u0442\u044b\u0445 \u0444\u0430\u0439\u043b\u043e\u0432 \u0438 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043f\u0440\u0438\u0431\u0438\u0432\u0430\u043b\u0441\u044f \u0441\u0438\u0441\u0442\u0435\u043c\u043e\u0439.<\/p>\n<p>\u041f\u043e \u0441\u043b\u043e\u0432\u0430\u043c <strong>java<\/strong>-\u0441\u043e\u0442\u0440\u0443\u0434\u043d\u0438\u043a\u0430 \u0434\u0435\u043b\u043e \u043c\u043e\u0433\u043b\u043e \u0431\u044b\u0442\u044c \u0432 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0435 <strong>setTcpNoDelay<\/strong> \u043f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 TCP-\u0441\u043e\u043a\u0435\u0442\u0430. \u0411\u044b\u0441\u0442\u0440\u043e\u0435 \u0433\u0443\u0433\u043b\u0435\u043d\u0438\u0435 \u043d\u0430\u0432\u0435\u043b\u043e \u043d\u0430 <a href=\"https:\/\/bugs.java.com\/bugdatabase\/view_bug.do?bug_id=6799574\">bug<\/a>&nbsp;\u0438 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u0440\u0435\u0448\u0435\u043d\u0438\u044f (\u043a\u0441\u0442\u0430\u0442\u0438, \u044d\u0442\u043e\u0442 \u0431\u0430\u0433 \u0442\u0430\u043a \u0436\u0435 \u043f\u0440\u0438\u0441\u0443\u0442\u0441\u0442\u0432\u043e\u0432\u0430\u043b \u0438 \u0432 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0445 <strong>Solaris-based OS<\/strong>, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 <a href=\"https:\/\/github.com\/joyent\/illumos-joyent\/issues\/148\">Illumos<\/a>&nbsp;, <a href=\"https:\/\/smartos.org\/bugview\/OS-6312\">smartOS<\/a>). \u041d\u0435\u0441\u043c\u043e\u0442\u0440\u044f \u043d\u0430 &#8220;\u0441\u0442\u0430\u0440\u043e\u0441\u0442\u044c&#8221; \u0431\u0430\u0433\u0430, \u043e\u043d \u0432\u0441\u0451 \u0435\u0449\u0451 \u043f\u0440\u0438\u0441\u0443\u0442\u0441\u0442\u0432\u043e\u0432\u0430\u043b \u0438 \u0440\u0435\u0448\u0438\u043b\u0441\u044f \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u043c \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u043c \u043f\u043e \u0441\u0441\u044b\u043b\u043a\u0435. \u041d\u0443, \u043a\u0430\u043a \u0440\u0435\u0448\u0438\u043b\u0441\u044f, \u0441\u043e\u043a\u0435\u0442\u044b \u043f\u0440\u0435\u043a\u0440\u0430\u0442\u0438\u043b\u0438\u0441\u044c \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c\u0441\u044f, \u043d\u043e \u043e\u0448\u0438\u0431\u043a\u0438 \u0432 \u043b\u043e\u0433 \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u043b\u0438 \u043f\u0438\u0441\u0430\u0442\u044c\u0441\u044f.<\/p>\n<p>\u041a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u0431\u044b, \u043d\u0430 \u044d\u0442\u043e\u043c \u0441\u0442\u0430\u0442\u044c\u044e \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043a\u043e\u043d\u0447\u0438\u0442\u044c, \u0432\u0435\u0434\u044c \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 &#8220;\u0432\u0440\u043e\u0434\u0435 \u0431\u044b&#8221; \u0440\u0435\u0448\u0435\u043d\u0430. \u041d\u043e \u0430\u043a\u0430\u0434\u0435\u043c\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0438\u043d\u0442\u0435\u0440\u0435\u0441 \u0432\u0437\u044f\u043b \u0441\u0432\u043e\u0439 \u0438 \u044f \u0440\u0435\u0448\u0438\u043b \u043f\u043e\u0433\u043b\u0443\u0431\u0436\u0435 \u0443\u0437\u043d\u0430\u0442\u044c, \u043f\u043e\u0447\u0435\u043c\u0443 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442 \u0434\u0430\u043d\u043d\u0430\u044f \u043e\u0448\u0438\u0431\u043a\u0430 \u0438 \u043c\u043e\u0436\u043d\u043e \u043b\u0438 \u0432\u043e\u043e\u0431\u0449\u0435 \u043e\u0442 \u043d\u0435\u0451 \u0438\u0437\u0431\u0430\u0432\u0438\u0442\u0441\u044f?<\/p>\n<p>\u0418\u0437 \u0432\u044b\u0432\u043e\u0434\u0430 \u043e\u0448\u0438\u0431\u043a\u0438, \u0437\u043d\u0430\u0447\u0438\u0442, \u0447\u0442\u043e \u043f\u043e \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u043f\u0440\u0438\u0447\u0438\u043d\u0435 \u043d\u0435\u043b\u044c\u0437\u044f \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c <strong>TCP_NODELAY<\/strong>. \u0415\u0441\u043b\u0438 \u043a\u0440\u0430\u0442\u043a\u043e &#8211; \u0442\u043e \u044d\u0442\u0430 \u043e\u043f\u0446\u0438\u044f \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u043f\u0430\u043a\u0435\u0442\u044b \u0441\u0440\u0430\u0437\u0443, \u043d\u0435 \u0434\u043e\u0436\u0438\u0434\u0430\u044f\u0441\u044c \u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0431\u043e\u043b\u0435\u0435 \u043e\u0431\u044a\u0451\u043c\u043d\u043e\u0433\u043e \u043f\u0430\u043a\u0435\u0442\u0430 \u0441 \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u043e\u0439 \u0437\u0430 1 \u0440\u0430\u0437 \u0432\u0441\u0435\u0445 \u0434\u0430\u043d\u043d\u044b\u0445. \u0422\u0430\u043a\u043e\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0443\u0441\u043a\u043e\u0440\u044f\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u0443 \u043e\u0431\u043c\u0435\u043d\u0430 \u0432 \u0441\u0435\u0442\u0438 \u043f\u0440\u0438 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0443\u0441\u043b\u043e\u0432\u0438\u044f\u0445. \u0414\u0435\u0442\u0430\u043b\u044c\u043d\u0435\u0435 \u043e\u0431 \u044d\u0442\u043e\u043c \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c <a href=\"https:\/\/it.wikireading.ru\/7123\">\u0437\u0434\u0435\u0441\u044c<\/a>&nbsp;\u0438 <a href=\"https:\/\/www.extrahop.com\/company\/blog\/2016\/tcp-nodelay-nagle-quickack-best-practices\/\">\u0437\u0434\u0435\u0441\u044c<\/a><\/p>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u0447\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0447\u0435\u0440\u0435\u0437 <strong>truss<\/strong>:<\/p>\n<p><code><br>\n\/46:    accept(676, 0x07463D30, 0x7FFF9FFF64F4, SOV_DEFAULT) = 21992<br>\n\/46:    fcntl(21992, F_GETFL)                           = 130<br>\n\/46:    fcntl(21992, F_SETFL, FWRITE)                   = 0<br>\n\/46:    getsockname(21992, 0x7FFF9FFF64F0, 0x7FFF9FFF64E8, SOV_DEFAULT) = 0<br>\n\/46:    getsockname(21992, 0x7FFF9FFF64F0, 0x7FFF9FFF64EC, SOV_DEFAULT) = 0<br>\n\/46:    fcntl(21992, F_GETFL)                           = 2<br>\n\/46:    fcntl(21992, F_SETFL, FWRITE|FNONBLOCK)         = 0<br>\n\/46:    setsockopt(21992, tcp, TCP_NODELAY, 0x7FFF9FFF6470, 4, SOV_DEFAULT) = 0<br>\n\/46:    setsockopt(21992, SOL_SOCKET, SO_KEEPALIVE, 0x7FFF9FFF6470, 4, SOV_DEFAULT) = 0<br>\n\/46:    setsockopt(21992, SOL_SOCKET, SO_SNDBUF, 0x7FFF9FFF6470, 4, SOV_DEFAULT) = 0<br>\n<\/code><\/p>\n<p>\u041a\u0430\u043a \u0432\u0438\u0434\u0438\u043c, \u0438\u0434\u0451\u0442 \u043f\u043e\u043f\u044b\u0442\u043a\u0430 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u0444\u043b\u0430\u0433\u0430 <strong>TCP_NODELAY<\/strong> \u0438 \u043a\u043e\u0434 \u0432\u043e\u0437\u0432\u0440\u0430\u0442\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <strong>setsockopt == 0<\/strong>, \u0437\u043d\u0430\u0447\u0438\u0442, \u0447\u0442\u043e \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u043e, \u043d\u043e \u0435\u0441\u043b\u0438 \u0432\u0437\u0433\u043b\u044f\u043d\u0443\u0442\u044c \u0447\u0435\u0440\u0435\u0437 pfiles \u043d\u0430 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0438 \u043d\u0430\u0439\u0442\u0438 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u0441\u043e\u043a\u0435\u0442, \u043c\u044b \u0443\u0432\u0438\u0434\u0438\u043c, \u0447\u0442\u043e \u0444\u043b\u0430\u0433\u0430 <strong>TCP_NODELAY<\/strong> &#8211; \u043d\u0435\u0442:<\/p>\n<pre> 32404: S_IFSOCK mode:0666 dev:16377,0 ino:21992 uid:0 gid:0 size:0 \n      O_RDWR|O_NONBLOCK\n        sockname: AF_INET 0.0.0.0  port: 0\n        SOCK_STREAM\n        SO_REUSEADDR,SO_SNDBUF(256000),SO_RCVBUF(104256)\n        congestion control: newreno\n<\/pre>\n\n\n<p>\u041a\u0430\u043a \u0436\u0435 \u0442\u0430\u043a? \u041e\u0431\u0440\u0430\u0442\u0438\u043c\u0441\u044f \u043a <a href=\"https:\/\/docs.oracle.com\/cd\/E88353_01\/html\/E37843\/setsockopt-3c.html\">\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 <\/a>\u0444\u0443\u043d\u043a\u0446\u0438\u0438 setsockopts \u0438 \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u043d\u0430\u0439\u0442\u0438 <strong>TCP_NODELAY <\/strong>\u0438 \u0432 \u0432\u0435\u0440\u0441\u0438\u0438 \u0434\u043b\u044f <strong>Solaris <\/strong>\u0435\u0433\u043e \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043d\u0435\u0442. \u041d\u0430 \u0432\u0441\u044f\u043a\u0438\u0439 \u0441\u043b\u0443\u0447\u0430\u0439 \u043f\u0440\u0438\u043b\u043e\u0436\u0443 <a href=\"http:\/\/www.unixguide.net\/network\/socketfaq\/2.16.shtml\">\u0432\u044b\u0434\u0435\u0440\u0436\u043a\u0443 <\/a>\u0438\u0437 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u043f\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0435 <strong>TCP_NODELAY<\/strong>. \u0412\u044b\u0445\u043e\u0434\u0438\u0442, \u044d\u0442\u043e\u0433\u043e \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 \u043d\u0435\u0442, \u043d\u043e \u043f\u0440\u0438 \u044d\u0442\u043e\u043c, <strong>setsockopt <\/strong>\u043d\u0435 \u0440\u0443\u0433\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u043d\u0435\u0432\u0435\u0440\u043d\u044b\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0433\u043e\u0432\u043e\u0440\u0438\u0442, \u0447\u0442\u043e \u0442\u0438\u043f\u0430 \u0432\u0441\u0451 \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u043b\u043e\u0441\u044c. \u041f\u0440\u043e\u0431\u0443\u0435\u043c \u043f\u043e\u0438\u0441\u043a\u0430\u0442\u044c \u043f\u043e \u043f\u0430\u043f\u043a\u0435 include \u0438 \u043d\u0430\u0445\u043e\u0434\u0438\u043c \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430<\/p>\n\n\n<pre>\/usr\/include\/netinet\/tcp.h:#define      TCP_NODELAY     0x01    \/* don't delay send to coalesce packets *\/<\/pre>\n\n\n<p>\u0417\u043d\u0430\u0447\u0438\u0442 \u0435\u0441\u0442\u044c! \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u043c. \u0414\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u044f \u0432\u0437\u044f\u043b \u0441\u043a\u0440\u0438\u043f\u0442 \u043d\u0430 <strong>python&#8217;e<\/strong>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442 <strong>TCP_NODELAY<\/strong><\/p>\n\n\n<pre>#!\/usr\/bin\/python\n\nimport socket\n\nsock = socket.socket()\nsock.bind(('127.0.0.1', 45454))\nsock.setsockopt(socket.SOL_SOCKET, socket.TCP_NODELAY, 1)\nsock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)\nsock.setsockopt(socket.SOL_TCP, socket.TCP_NODELAY, 1)\nsock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)\nsock.listen(1)\nconn, addr = sock.accept()\n\nprint ('connected:', addr)\n\nwhile True:\n    data = conn.recv(1024)\n    if not data:\n        break\n    conn.send(data.upper())\n\nconn.close()\n<\/pre>\n\n\n<p>\u041d\u043e \u0447\u0435\u0440\u0435\u0437 <strong>pfiles <\/strong>\u043d\u0438\u043a\u0430\u043a\u043e\u0433\u043e <strong>NODELAY <\/strong>\u043d\u0435 \u0432\u0438\u0434\u043d\u043e. \u0417\u0430\u0442\u043e \u0432\u043c\u0435\u0441\u0442\u043e \u043d\u0435\u0433\u043e \u043f\u043e\u044f\u0432\u0438\u043b\u0441\u044f <strong>SO_DEBUG<\/strong>. <\/p>\n\n\n<pre>3: S_IFSOCK mode:0666 dev:16377,0 ino:33482 uid:0 gid:0 size:0 \n      O_RDWR\n        sockname: AF_INET 127.0.0.1  port: 45454\n        SOCK_STREAM\n        SO_DEBUG,SO_ACCEPTCONN,SO_SNDBUF(256000),SO_RCVBUF(256000)\n<\/pre>\n\n\n<p>\u041f\u0440\u043e\u0431\u0443\u0435\u043c \u043f\u043e\u0438\u0441\u043a\u0430\u0442\u044c \u043f\u043e <strong>SO_DEBUG <\/strong>\u0438 \u043d\u0430\u0445\u043e\u0434\u0438\u043c \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u0443\u044e \u0432\u0435\u0449\u044c:<\/p>\n\n\n<pre>$ grep SO_DEBUG \/usr\/include\/sys\/socket.h\n#define SO_DEBUG        0x0001          \/* turn on debugging info recording *\/<\/pre>\n\n\n<p>\u0438 \u0447\u0442\u043e \u043c\u044b \u0432\u0438\u0434\u0438\u043c? \u041f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e, \u043e\u0434\u043d\u043e \u0438 \u0442\u043e \u0436\u0435 \u0447\u0438\u0441\u043b\u043e\u0432\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 &#8220;<strong>1<\/strong>&#8220;. \u0422\u043e \u0435\u0441\u0442\u044c, \u0432\u043c\u0435\u0441\u0442\u043e <strong>TCP_NODELAY <\/strong>\u0432\u044b\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0444\u043b\u0430\u0433 <strong>DEBUG<\/strong>. \u0414\u043b\u044f \u0443\u0432\u0435\u0440\u0435\u043d\u043d\u043e\u0441\u0442\u0438, \u0440\u0435\u0448\u0438\u043b \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0443 \u0444\u043b\u0430\u0433\u0430 \u0447\u0435\u0440\u0435\u0437 <strong>\u0421<\/strong>-\u0448\u043d\u044b\u0439 \u043a\u043e\u0434. \u042f \u0437\u043d\u0430\u043b, \u0447\u0442\u043e \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0431\u0443\u0434\u0435\u0442 \u0442\u0430\u043a\u0438\u043c \u0436\u0435, \u043d\u043e \u043d\u0430 \u0432\u0441\u044f\u043a\u0438\u0439 \u0441\u043b\u0443\u0447\u0430\u0439 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u043b. \u0414\u0430, \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043e\u043a\u0430\u0437\u0430\u043b\u0441\u044f \u0442\u0430\u043a\u0438\u043c \u0436\u0435. \u0422\u043e \u0435\u0441\u0442\u044c, \u043f\u043e \u0444\u0430\u043a\u0442\u0443 <strong>TCP_NODELAY <\/strong>\u043e\u0442\u043a\u043b\u044e\u0447\u0451\u043d \u043d\u0430 \u0443\u0440\u043e\u0432\u043d\u0435 \u041e\u0421. \u042d\u0442\u043e \u043a\u043e\u0441\u0432\u0435\u043d\u043d\u043e \u043f\u043e\u0434\u0442\u0432\u0435\u0440\u0436\u0434\u0430\u0435\u0442 \u0438 \u043f\u043e\u043f\u044b\u0442\u043a\u0430 \u043c\u0430\u043d\u0438\u043f\u0443\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u043c <a href=\"https:\/\/docs.oracle.com\/cd\/E26505_01\/html\/E37386\/chapter4-31.html\">tcp_naglim_def<\/a> , \u043d\u043e \u0432 <strong>11.4<\/strong> (\u0431\u044b\u043b \u0432\u043f\u043b\u043e\u0442\u044c \u0434\u043e <strong>11.0<\/strong> \u0438 \u0443\u0431\u0440\u0430\u043b\u0438, \u043d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 <strong>11.1<\/strong>) \u0435\u0433\u043e \u0443\u0436\u0435 \u043d\u0435\u0442 \u0432 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438, \u0445\u043e\u0442\u044f \u043f\u043e \u0444\u0430\u043a\u0442\u0443 \u043f\u0440\u0438\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0438 \u0438\u043c\u0435\u0435\u0442 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <strong>65535<\/strong>. \u0421\u043c\u0435\u043d\u0430 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0432 1 (\u0445\u043e\u0442\u044f \u0432 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u0432\u044b\u0448\u0435 \u0441\u043a\u0430\u0437\u0430\u043d\u043e, \u0447\u0442\u043e \u0438\u043c\u0435\u043d\u043d\u043e \u0442\u0430\u043c \u043c\u043e\u0436\u043d\u043e \u043e\u0442\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u041d\u0430\u0433\u0435\u043b\u044f, \u0442\u043e \u0435\u0441\u0442\u044c \u0432\u043a\u043b\u044e\u0447\u0438\u0442\u044c <strong>TCP_NODELAY<\/strong>) \u043d\u0438 \u043a \u0447\u0435\u043c\u0443 \u043d\u0435 \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442.<\/p>\n\n\n\n<p>\u0418 \u0442\u0443\u0442 \u043d\u0430\u0432\u0435\u0440\u043d\u043e\u0435 \u043d\u0443\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0432\u044b\u0432\u043e\u0434, \u0447\u0442\u043e <strong>TCP_NODELAY<\/strong>, \u043e\u0442\u043a\u043b\u044e\u0447\u0451\u043d. \u041d\u043e! \u041d\u0443\u0436\u043d\u043e \u0436\u0435 \u043f\u0440\u043e\u0432\u0435\u0441\u0442\u0438 \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442, \u0433\u0434\u0435 \u0431\u0443\u0434\u0435\u0442 \u0432\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u0438\u0435 \u043f\u0430\u043a\u0435\u0442\u044b \u0438\u043b\u0438, \u043d\u0430\u043e\u0431\u043e\u0440\u043e\u0442, \u0431\u043e\u043b\u044c\u0448\u0438\u0435. \u041d\u0430\u0448\u043b\u0430\u0441\u044c <a href=\"https:\/\/blog.gopheracademy.com\/advent-2019\/control-packetflow-tcp-nodelay\/\">\u0441\u0442\u0430\u0442\u044c\u044f<\/a>, \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u044d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c. \u041f\u043e\u0441\u043b\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438, \u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0447\u0442\u043e <strong>TCP_NODELAY <\/strong>\u0432\u043a\u043b\u044e\u0447\u0451\u043d \u0438 \u0432\u044b\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0435\u0433\u043e \u043d\u0435\u043b\u044c\u0437\u044f. \u0422\u043e \u0435\u0441\u0442\u044c, \u043b\u043e\u0433\u0438\u043a\u0430 \u0442\u0430\u043a\u0430\u044f: \u0432 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u0445 sock opts \u043d\u0435 \u0441\u0432\u0435\u0442\u0438\u0442\u0441\u044f, \u043f\u043e \u0444\u0430\u043a\u0442\u0443 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442, \u0432 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u043d\u0435 \u043e\u043f\u0438\u0441\u0430\u043d \u0438 \u043e\u0448\u0438\u0431\u043e\u043a \u043d\u0435 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 )).<\/p>\n\n\n\n<p>\u0420\u0435\u0437\u044e\u043c\u0438\u0440\u0443\u0435\u043c, \u043f\u0440\u0438\u0447\u0438\u043d\u0430 &#8211; \u043d\u0430\u0439\u0434\u0435\u043d\u0430. \u0410 \u043a\u0430\u043a \u0434\u0435\u043b\u0430 \u043e\u0431\u0441\u0442\u043e\u044f\u0442 \u0432 \u0434\u0440\u0443\u0433\u0438\u0445 \u041e\u0421?<\/p>\n\n\n\n<p><strong><em><span class=\"has-inline-color has-blue-color\">FreeBSD.<\/span><\/em><\/strong><\/p>\n\n\n\n<p>\u0422\u0443\u0442 \u0432\u0441\u0451 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043a\u0430\u043a \u043d\u0430\u0434\u043e \u0431\u0435\u0437 \u043f\u0440\u043e\u0431\u043b\u0435\u043c:<\/p>\n\n\n<pre>$ lsof -a -p 18011 -i 4 -T f\nCOMMAND     PID     USER   FD   TYPE             DEVICE SIZE\/OFF NODE NAME\npython3.7 18011 skeletor    3u  IPv4 0xfffff8002bda87a0      0t0  TCP 127.0.0.1:45454 (SO=ACCEPTCONN,DEBUG,PQLEN=0,QLEN=0,QLIM=1,RCVBUF=0,REUSEADDR,SNDBUF=0 TF=MSS=536,NODELAY,REQ_SCALE,REQ_TSTMP)<\/pre>\n\n\n<p><strong><em><span class=\"has-inline-color has-blue-color\">Linux.<\/span><\/em><\/strong><\/p>\n\n\n\n<p>\u0422\u0443\u0442 \u0442\u043e\u0436\u0435 \u0432\u0441\u0451 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0431\u0435\u0437 \u043f\u0440\u043e\u0431\u043b\u0435\u043c, \u043d\u043e \u0432\u043e\u0442 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c <strong>socket options<\/strong> \u0447\u0435\u0440\u0435\u0437 <strong>lsof <\/strong>\u0443\u0436\u0435 \u043d\u0435\u043b\u044c\u0437\u044f. \u041d\u0438\u0436\u0435 \u0432\u044b\u0434\u0435\u0440\u0436\u043a\u0430 \u0438\u0437 <strong>man lsof<\/strong>:<\/p>\n\n\n<blockquote>\n<p><span style=\"color: #993366;\">Linux<\/span><br><span style=\"color: #993366;\">No socket options and values, socket states, or TCP<\/span><br><span style=\"color: #993366;\">flags and values are reported. The support for &#8220;-Tf&#8221;<\/span><br><span style=\"color: #993366;\">could not be added to Linux, because socket options,<\/span><br><span style=\"color: #993366;\">socket states, and TCP flags and values are not<\/span><br><span style=\"color: #993366;\">available via the \/proc file system.&#8221;<\/span><\/p>\n<\/blockquote>\n<p>\u0422\u0443\u0442 \u043d\u0430 \u043f\u043e\u043c\u043e\u0449\u044c \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442 \u043c\u043e\u0434\u0443\u043b\u044c \u044f\u0434\u0440\u0430 <a href=\"https:\/\/github.com\/veithen\/knetstat\">knetstat<\/a> \u041d\u0438\u0436\u0435 \u043f\u0440\u0438\u043c\u0435\u0440 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f:<\/p>\n<pre>     0      0 0.0.0.0:80              0.0.0.0:*               LSTN      SO_REUSEADDR=1,SO_REUSEPORT=0,SO_KEEPALIVE=0,TCP_NODELAY=0,TCP_FASTOPEN=0,TCP_DEFER_ACCEPT=0\n     0      0 127.0.0.1:45454           0.0.0.0:*               LSTN      SO_REUSEADDR=1,SO_REUSEPORT=0,SO_KEEPALIVE=0,TCP_NODELAY=1,TCP_FASTOPEN=0,TCP_DEFER_ACCEPT=0\n<\/pre>\n\n\n<p>\u041d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u041f\u041e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043c\u0435\u043d\u044f <strong>TCP_NODELAY<\/strong>, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, <a href=\"https:\/\/nginx.org\/ru\/docs\/http\/ngx_http_core_module.html#tcp_nodelay\">nginx<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u0414\u0430, \u0438\u043c\u0435\u043d\u043d\u043e \u0441 \u0442\u0430\u043a\u0438\u043c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435\u043c \u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u0430\u0434\u0430\u0442\u044c kafka \u0441\u043f\u0443\u0441\u0442\u044f \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u043f\u043e\u0441\u043b\u0435 \u0437\u0430\u043f\u0443\u0441\u043a\u0430. \u0412\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0440\u0435\u0436\u0438\u043c\u0430 debug \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u043b\u043e &#8220;\u043f\u043e\u043d\u044f\u0442\u043d\u043e\u0441\u0442\u044c&#8221; ERROR Error while accepting connection (kafka.network.Acceptor) java.net.SocketException: Invalid argument at sun.nio.ch.Net.setIntOption0(Native Method) at sun.nio.ch.Net.setSocketOption(Net.java:341) at sun.nio.ch.SocketChannelImpl.setOption(SocketChannelImpl.java:190) at sun.nio.ch.SocketAdaptor.setBooleanOption(SocketAdaptor.java:271) at sun.nio.ch.SocketAdaptor.setTcpNoDelay(SocketAdaptor.java:306) at kafka.network.Acceptor.accept(SocketServer.scala:654) at kafka.network.Acceptor.run(SocketServer.scala:579) at java.lang.Thread.run(Thread.java:748)<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,5,10,24,15],"tags":[],"class_list":["post-5791","post","type-post","status-publish","format-standard","hentry","category-freebsd","category-linux","category-others","category-solaris","category-www"],"_links":{"self":[{"href":"https:\/\/skeletor.org.ua\/index.php?rest_route=\/wp\/v2\/posts\/5791","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/skeletor.org.ua\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/skeletor.org.ua\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/skeletor.org.ua\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/skeletor.org.ua\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=5791"}],"version-history":[{"count":2,"href":"https:\/\/skeletor.org.ua\/index.php?rest_route=\/wp\/v2\/posts\/5791\/revisions"}],"predecessor-version":[{"id":5794,"href":"https:\/\/skeletor.org.ua\/index.php?rest_route=\/wp\/v2\/posts\/5791\/revisions\/5794"}],"wp:attachment":[{"href":"https:\/\/skeletor.org.ua\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=5791"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/skeletor.org.ua\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=5791"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/skeletor.org.ua\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=5791"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}