Zeronet: Cannot watch more than 1024 sockets

Created on 27 Sep 2018  路  11Comments  路  Source: HelloZeroNet/ZeroNet

rev 3611
win10

[2018-09-27 21:05:53,911] ERROR    - Unhandled exception
Traceback (most recent call last):
  File "site-packages\gevent\baseserver.py", line 197, in _do_read
  File "site-packages\gevent\server.py", line 158, in do_read
  File "site-packages\gevent\_socket2.py", line 198, in accept
  File "site-packages\gevent\_socket2.py", line 124, in __init__
  File "gevent.libev.corecext.pyx", line 487, in gevent.libev.corecext.loop.io (src/gevent/libev/gevent.corecext.c:6680)
  File "gevent.libev.corecext.pyx", line 835, in gevent.libev.corecext.io.__init__ (src/gevent/libev/gevent.corecext.c:11088)
IOError: cannot watch more than 1024 sockets
[2018-09-27 21:05:54,029] ERROR    - Unhandled exception
Traceback (most recent call last):
  File "site-packages\gevent\baseserver.py", line 197, in _do_read
  File "site-packages\gevent\server.py", line 158, in do_read
  File "site-packages\gevent\_socket2.py", line 198, in accept
  File "site-packages\gevent\_socket2.py", line 124, in __init__
  File "gevent.libev.corecext.pyx", line 487, in gevent.libev.corecext.loop.io (src/gevent/libev/gevent.corecext.c:6680)
  File "gevent.libev.corecext.pyx", line 835, in gevent.libev.corecext.io.__init__ (src/gevent/libev/gevent.corecext.c:11088)
IOError: cannot watch more than 1024 sockets
[2018-09-27 21:05:54,505] ERROR    TorManager Tor controller connect error: error: [Errno 10061] [Error 10061] 目芫薹印 in TorManager.py line 190 > _socket2.py line 231
[2018-09-27 21:05:56,549] ERROR    TorManager Error starting Tor client: IOError: cannot watch more than 1024 sockets in TorManager.py line 107 > TorManager.py line 179 > TorManager.py line 185 > _socket2.py line 124 > gevent.libev.corecext.pyx line 487 > gevent.libev.corecext.pyx line 835
[2018-09-27 21:05:57,075] ERROR    - Unhandled exception
Traceback (most recent call last):
  File "site-packages\gevent\baseserver.py", line 197, in _do_read
  File "site-packages\gevent\server.py", line 158, in do_read
  File "site-packages\gevent\_socket2.py", line 198, in accept
  File "site-packages\gevent\_socket2.py", line 124, in __init__
  File "gevent.libev.corecext.pyx", line 487, in gevent.libev.corecext.loop.io (src/gevent/libev/gevent.corecext.c:6680)
  File "gevent.libev.corecext.pyx", line 835, in gevent.libev.corecext.io.__init__ (src/gevent/libev/gevent.corecext.c:11088)
IOError: cannot watch more than 1024 sockets

Restarting zeronet doesn't help me.

All 11 comments

@shortcutme

How many connections do you see on the /Stats page?

Btw, the 1024 max sockets is a libev restriction on Windows.

I've switched to ubuntu recently.So i don't know will this bug occurs again or not

Here on this page of Gevent docs:

Note: On Windows using the libev backend, gevent is limited to a maximum of 1024 open sockets due to limitations in libev. This limitation should not exist with the default libuv backend.

That leads me to believe it's Windows-only.

So we should not run a zeronet spider on Windows.

Bad idea.

Probably it's fixed by moving to Python3 (tested on windows 10):

> py -3 test_limit.py
Max stdio: 512
Testing files...
Error: [Errno 24] Too many open files: 'test_limit.py'
Max: 8189
Testing sockets...
Error: [Errno 10055] [WinError 10055] An operation on a socket could not be performed because the system lacked sufficient buffer space or because a queue was full.
Max: 16363

Python2 results:

> py -2 test_limit.py
Max stdio: 512
Testing files...
Error: [Errno 24] Too many open files: 'test_limit.py'
Max: 509
Testing sockets..
Error: cannot watch more than 1024 sockets
Max: 1021

So based on this testing Python2 process was limited to open 509 files and serve 1021 sockets at the same time, Python3 process can open 8189 files and serve 16363 sockets.

The script I used to test: https://gist.github.com/HelloZeroNet/d1f2d5424f4026def8558cc11ed2fa68

Soon after following error ZeroNet crashed. No error crash message, no error.log.

ERROR - Unhandled exception: OSError: cannot watch more than 1024 sockets in lib/gevent/baseserver.py line 199 > ... > corecext.pyx line 640 > 1006

  • ZeroNet version: 0.7.1 r4496, Python 3.7.3
  • Operating system: W10 64bit
  • Web browser: FF beta
  • Tor status: available
  • Opened port: yes/no
  • Special configuration: more (up to 10) threads read/write/db

I can confirm that it drops this error when using gevent.config.loop = "libev-cext"

It was changed from libuv to libev, because it had multiple issues with multi-threading + gevent libuv.
https://github.com/HelloZeroNet/ZeroNet/commit/51f49cd45aa0677427683828a15d23316c91a9bd
I will check if we can switch back to default libev with latest gevent.

I see this error repeatedly when i try to start ZN. ZN run for a few minutes and then there is generic Windows 10 message with only option to terminate app.

[2020-10-13 00:39:47,388] INFO     - Libsecpk256k1 loaded: FFILibrary_U:\ZeroNet-win-dist-win64\lib\coincurve\libsecp256k1.dll in 0.246s
[2020-10-13 00:39:49,886] INFO     - Version: 0.7.2 r4538, Python 3.7.3 (v3.7.3:ef4ec6ed12, Mar 25 2019, 22:22:05) [MSC v.1916 64 bit (AMD64)], Gevent: 1.4.0
...
[2020-10-13 00:49:43,359] INFO     Site:1abc.def [OK] someIPv4:0: Thanks, file data/users/siteaddresshere/content.json updated! 1/1
[2020-10-13 00:50:28,319] ERROR    - Unhandled exception: OSError: cannot watch more than 1024 sockets in lib/gevent/baseserver.py line 199 > ... > corecext.pyx line 640 > 1006
[2020-10-13 00:50:28,690] ERROR    - Unhandled exception: OSError: cannot watch more than 1024 sockets in lib/gevent/baseserver.py line 199 > ... > corecext.pyx line 640 > 1006

that errors are only ones in file and last ones at the end of file. see no error log file of ZN.

In previous startup attempt i also see error #2537 but maybe not related. ZN was starting OK, but when i clicked to update on updater zite, then ZN shown after some minutes the terminate windows prompt and now it show it always after start.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

HelloZeroNet picture HelloZeroNet  路  45Comments

imachug picture imachug  路  92Comments

HelloZeroNet picture HelloZeroNet  路  36Comments

ZeroNetTickBot picture ZeroNetTickBot  路  586Comments

ghost picture ghost  路  53Comments