Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Having more incomming connections than MAX_SESSIONS #795

Closed
Talkless opened this issue Apr 13, 2019 · 2 comments

Comments

@Talkless
Copy link

commented Apr 13, 2019

# electrumx_rpc getinfo | fgrep version
    "version": "ElectrumX 1.10.1"
# /opt/python3.6/bin/python3 --version
Python 3.6.8
# /opt/python3.6/bin/pip3 freeze
aiohttp==4.0.0a0
aiorpcX==0.13.5
async-timeout==3.0.1
attrs==19.1.0
chardet==3.0.4
electrumX==1.10.1
idna==2.8
idna-ssl==1.1.0
multidict==4.5.2
plyvel==0.9
pylru==1.2.0
typing-extensions==3.7.2
yarl==1.3.0
# uname -a
Linux odroid-hc1 4.9.0-8-armmp-lpae #1 SMP Debian 4.9.144-3.1 (2019-02-19) armv7l GNU/Linux
# cat /etc/electrumx.conf
COIN=BitcoinSegwit
DB_DIRECTORY=/home/electrumx/.electrumx
DAEMON_URL=http://...=@127.0.0.1:8332/
TCP_PORT=50001
SSL_PORT=50002
HOST=0.0.0.0
SSL_CERTFILE=/etc/electrumx/server.crt
SSL_KEYFILE=/etc/electrumx/server.key
CACHE_MB=256
REPORT_HOST_TOR=....onion
REPORT_HOST=...
MAX_SESSIONS=32
MAX_SUBS=3200
MAX_SESSION_SUBS=500

I see in the logs that connections keeps rising above MAX_SESSION limit even after "closing" TCP SSL ports.

Apr 14 00:04:03 odroid-hc1 electrumx[4190]: INFO:ElectrumX:[1588] SSL 201.216.157.208:21091, 78 total
Apr 14 00:04:03 odroid-hc1 electrumx[4190]: INFO:ElectrumX:[1589] SSL 179.210.129.219:58094, 79 total
Apr 14 00:04:04 odroid-hc1 electrumx[4190]: INFO:ElectrumX:[1590] SSL 139.47.117.208:2382, 63 total
Apr 14 00:04:44 odroid-hc1 electrumx[4190]: INFO:SessionManager:resuming listening for incoming connections
Apr 14 00:04:46 odroid-hc1 electrumx[4190]: INFO:SessionManager:TCP server listening on 0.0.0.0:50001
Apr 14 00:04:46 odroid-hc1 electrumx[4190]: INFO:SessionManager:SSL server listening on 0.0.0.0:50002
Apr 14 00:04:49 odroid-hc1 electrumx[4190]: INFO:ElectrumX:[1591] SSL 88.114.200.59:59372, 28 total
Apr 14 00:04:49 odroid-hc1 electrumx[4190]: INFO:ElectrumX:[1592] SSL 212.253.163.137:64532, 29 total
Apr 14 00:04:49 odroid-hc1 electrumx[4190]: INFO:ElectrumX:[1593] SSL 88.249.31.149:60356, 30 total
Apr 14 00:04:49 odroid-hc1 electrumx[4190]: INFO:ElectrumX:[1594] SSL 188.2.192.251:52745, 31 total
Apr 14 00:04:49 odroid-hc1 electrumx[4190]: INFO:ElectrumX:[1595] SSL 31.182.173.6:15432, 32 total
Apr 14 00:04:49 odroid-hc1 electrumx[4190]: INFO:ElectrumX:[1596] SSL 88.115.116.18:59478, 33 total
Apr 14 00:04:49 odroid-hc1 electrumx[4190]: INFO:ElectrumX:[1597] SSL 78.88.180.187:56471, 34 total
Apr 14 00:04:49 odroid-hc1 electrumx[4190]: INFO:ElectrumX:[1598] SSL 86.57.131.106:53905, 35 total
Apr 14 00:04:49 odroid-hc1 electrumx[4190]: INFO:ElectrumX:[1599] SSL 94.21.198.20:58390, 36 total
Apr 14 00:04:49 odroid-hc1 electrumx[4190]: INFO:ElectrumX:[1600] SSL 90.162.113.140:54207, 37 total
Apr 14 00:04:49 odroid-hc1 electrumx[4190]: INFO:ElectrumX:[1601] SSL 178.79.36.87:55007, 38 total
Apr 14 00:04:49 odroid-hc1 electrumx[4190]: INFO:ElectrumX:[1602] SSL 89.26.68.32:62896, 39 total
Apr 14 00:04:50 odroid-hc1 electrumx[4190]: INFO:ElectrumX:[1603] TCP 188.245.236.165:61533, 40 total
Apr 14 00:04:50 odroid-hc1 electrumx[4190]: INFO:SessionManager:maximum sessions 32 reached, stopping new connections until count drops to 30
Apr 14 00:04:50 odroid-hc1 electrumx[4190]: INFO:SessionManager:closing down TCP, SSL listening servers
Apr 14 00:04:50 odroid-hc1 electrumx[4190]: INFO:ElectrumX:[1604] SSL 185.51.26.241:55539, 41 total
Apr 14 00:04:50 odroid-hc1 electrumx[4190]: INFO:ElectrumX:[1605] SSL 95.10.224.80:20555, 42 total
Apr 14 00:04:50 odroid-hc1 electrumx[4190]: INFO:ElectrumX:[1606] SSL 186.86.32.46:9330, 43 total
Apr 14 00:04:50 odroid-hc1 electrumx[4190]: INFO:ElectrumX:[1607] SSL 181.176.118.138:56927, 44 total
Apr 14 00:04:50 odroid-hc1 electrumx[4190]: INFO:ElectrumX:[1608] SSL 178.221.75.145:54400, 45 total
Apr 14 00:04:50 odroid-hc1 electrumx[4190]: INFO:ElectrumX:[1609] SSL 94.60.183.234:65507, 46 total
Apr 14 00:04:50 odroid-hc1 electrumx[4190]: INFO:ElectrumX:[1610] SSL 85.138.116.61:52802, 47 total
Apr 14 00:04:50 odroid-hc1 electrumx[4190]: INFO:ElectrumX:[1611] SSL 156.200.227.62:58493, 48 total
Apr 14 00:04:50 odroid-hc1 electrumx[4190]: INFO:ElectrumX:[1612] SSL 189.149.182.138:51455, 49 total
Apr 14 00:04:50 odroid-hc1 electrumx[4190]: INFO:ElectrumX:[1613] SSL 188.6.200.69:60089, 50 total
Apr 14 00:04:50 odroid-hc1 electrumx[4190]: INFO:ElectrumX:[1614] SSL 71.197.250.253:59799, 51 total
Apr 14 00:04:50 odroid-hc1 electrumx[4190]: INFO:ElectrumX:[1615] SSL 87.116.179.248:39526, 52 total
Apr 14 00:04:50 odroid-hc1 electrumx[4190]: INFO:ElectrumX:[1616] SSL 180.253.135.235:62823, 53 total
Apr 14 00:04:50 odroid-hc1 electrumx[4190]: INFO:ElectrumX:[1617] SSL 190.237.237.155:60576, 54 total
Apr 14 00:04:50 odroid-hc1 electrumx[4190]: INFO:ElectrumX:[1618] SSL 103.60.209.136:34048, 55 total
Apr 14 00:04:50 odroid-hc1 electrumx[4190]: INFO:ElectrumX:[1619] SSL 186.106.182.5:64867, 56 total
Apr 14 00:04:50 odroid-hc1 electrumx[4190]: INFO:ElectrumX:[1620] SSL 78.35.62.172:55714, 57 total
Apr 14 00:04:50 odroid-hc1 electrumx[4190]: INFO:ElectrumX:[1621] SSL 82.77.220.148:65274, 58 total
Apr 14 00:04:50 odroid-hc1 electrumx[4190]: INFO:ElectrumX:[1622] SSL 177.239.41.186:31091, 59 total
Apr 14 00:04:50 odroid-hc1 electrumx[4190]: INFO:ElectrumX:[1623] SSL 45.72.174.209:63799, 60 total
Apr 14 00:04:50 odroid-hc1 electrumx[4190]: INFO:ElectrumX:[1624] SSL 186.113.119.249:59032, 61 total
Apr 14 00:04:50 odroid-hc1 electrumx[4190]: INFO:ElectrumX:[1625] SSL 36.234.89.77:59858, 62 total
Apr 14 00:04:50 odroid-hc1 electrumx[4190]: INFO:ElectrumX:[1626] SSL 95.138.117.250:60900, 63 total
Apr 14 00:04:50 odroid-hc1 electrumx[4190]: INFO:ElectrumX:[1627] SSL 180.243.140.71:5461, 64 total
Apr 14 00:04:50 odroid-hc1 electrumx[4190]: INFO:ElectrumX:[1628] SSL 203.153.21.6:64370, 65 total
Apr 14 00:04:50 odroid-hc1 electrumx[4190]: INFO:ElectrumX:[1629] SSL 179.179.251.238:54594, 66 total
Apr 14 00:04:50 odroid-hc1 electrumx[4190]: INFO:ElectrumX:[1630] SSL 90.90.19.76:49203, 67 total
Apr 14 00:04:50 odroid-hc1 electrumx[4190]: INFO:ElectrumX:[1631] SSL 41.101.81.95:64612, 68 total
Apr 14 00:04:50 odroid-hc1 electrumx[4190]: INFO:ElectrumX:[1632] SSL 201.119.219.193:50933, 69 total
Apr 14 00:04:50 odroid-hc1 electrumx[4190]: INFO:ElectrumX:[1633] SSL 88.229.241.195:56584, 70 total
Apr 14 00:04:50 odroid-hc1 electrumx[4190]: INFO:ElectrumX:[1634] SSL 41.142.151.235:63361, 71 total
Apr 14 00:04:50 odroid-hc1 electrumx[4190]: INFO:ElectrumX:[1635] SSL 80.89.72.56:57008, 72 total
Apr 14 00:04:50 odroid-hc1 electrumx[4190]: INFO:ElectrumX:[1636] SSL 14.207.64.161:59321, 73 total
Apr 14 00:04:50 odroid-hc1 electrumx[4190]: INFO:ElectrumX:[1637] SSL 190.203.249.99:41380, 74 total
Apr 14 00:04:50 odroid-hc1 electrumx[4190]: INFO:ElectrumX:[1638] SSL 77.235.150.128:54017, 75 total
Apr 14 00:04:52 odroid-hc1 electrumx[4190]: INFO:ElectrumX:[1639] SSL 186.71.176.189:59590, 76 total
Apr 14 00:04:52 odroid-hc1 electrumx[4190]: INFO:ElectrumX:[1640] SSL 181.198.166.52:51809, 77 total
Apr 14 00:04:52 odroid-hc1 electrumx[4190]: INFO:ElectrumX:[1641] SSL 177.3.33.175:59988, 78 total
Apr 14 00:04:52 odroid-hc1 electrumx[4190]: INFO:ElectrumX:[1642] SSL 62.248.6.223:60446, 79 total
Apr 14 00:04:52 odroid-hc1 electrumx[4190]: INFO:ElectrumX:[1643] SSL 83.171.151.212:53828, 80 total
Apr 14 00:04:52 odroid-hc1 electrumx[4190]: INFO:ElectrumX:[1644] SSL 189.217.107.58:23682, 81 total
Apr 14 00:04:52 odroid-hc1 electrumx[4190]: INFO:ElectrumX:[1645] SSL 176.104.104.102:47201, 82 total
Apr 14 00:04:52 odroid-hc1 electrumx[4190]: INFO:ElectrumX:[1646] SSL 89.78.32.124:61196, 83 total
Apr 14 00:04:52 odroid-hc1 electrumx[4190]: INFO:ElectrumX:[1647] SSL 158.140.173.63:58541, 84 total
Apr 14 00:04:52 odroid-hc1 electrumx[4190]: INFO:ElectrumX:[1648] SSL 36.72.238.182:50258, 85 total
Apr 14 00:04:52 odroid-hc1 electrumx[4190]: INFO:ElectrumX:[1649] SSL 78.175.165.116:60626, 86 total
Apr 14 00:04:52 odroid-hc1 electrumx[4190]: INFO:ElectrumX:[1650] SSL 103.2.133.1:12454, 87 total
Apr 14 00:04:52 odroid-hc1 electrumx[4190]: INFO:ElectrumX:[1651] SSL 46.252.55.212:52119, 88 total
Apr 14 00:04:52 odroid-hc1 electrumx[4190]: INFO:ElectrumX:[1652] SSL 189.216.164.158:31942, 89 total
Apr 14 00:04:52 odroid-hc1 electrumx[4190]: INFO:ElectrumX:[1653] SSL 102.250.4.72:25265, 90 total
Apr 14 00:04:52 odroid-hc1 electrumx[4190]: INFO:ElectrumX:[1654] SSL 190.160.113.76:60485, 91 total
Apr 14 00:04:52 odroid-hc1 electrumx[4190]: INFO:ElectrumX:[1655] SSL 200.0.56.59:2447, 92 total
Apr 14 00:04:52 odroid-hc1 electrumx[4190]: INFO:ElectrumX:[1656] SSL 112.205.24.116:49728, 93 total
Apr 14 00:04:52 odroid-hc1 electrumx[4190]: INFO:ElectrumX:[1657] SSL 190.202.213.0:62940, 94 total
Apr 14 00:04:52 odroid-hc1 electrumx[4190]: INFO:ElectrumX:[1658] SSL 36.90.32.109:61896, 95 total
Apr 14 00:04:52 odroid-hc1 electrumx[4190]: INFO:ElectrumX:[1659] SSL 78.190.151.247:59182, 96 total
Apr 14 00:04:52 odroid-hc1 electrumx[4190]: INFO:ElectrumX:[1660] SSL 77.124.25.188:52681, 97 total
Apr 14 00:04:52 odroid-hc1 electrumx[4190]: INFO:ElectrumX:[1661] SSL 70.31.144.140:56731, 98 total
Apr 14 00:04:52 odroid-hc1 electrumx[4190]: INFO:ElectrumX:[1662] SSL 200.53.22.245:16484, 97 total
Apr 14 00:04:52 odroid-hc1 electrumx[4190]: INFO:ElectrumX:[1663] SSL 197.60.84.233:20455, 98 total
Apr 14 00:04:52 odroid-hc1 electrumx[4190]: INFO:ElectrumX:[1664] SSL 218.164.182.65:20469, 99 total
Apr 14 00:04:52 odroid-hc1 electrumx[4190]: INFO:ElectrumX:[1665] SSL 187.35.183.168:32177, 100 total
Apr 14 00:04:52 odroid-hc1 electrumx[4190]: INFO:ElectrumX:[1603] attempting to crash old client with version 3.2.2
Apr 14 00:04:53 odroid-hc1 electrumx[4190]: INFO:SessionManager:closing stale connections 39
Apr 14 00:05:03 odroid-hc1 electrumx[4190]: INFO:ElectrumX:[1666] SSL 105.111.129.13:52729, 67 total
Apr 14 00:05:07 odroid-hc1 electrumx[4190]: INFO:ElectrumX:[1667] SSL 62.122.22.130:61670, 68 total
Apr 14 00:05:20 odroid-hc1 electrumx[4190]: INFO:PeerManager:registering ourself with ndndword5lpb7eex.onion
Apr 14 00:05:30 odroid-hc1 electrumx[4190]: INFO:PeerManager:[ndndword5lpb7eex.onion:50001 TCP] verified in 48.5s
Apr 14 00:05:44 odroid-hc1 electrumx[4190]: INFO:ElectrumX:[1668] SSL 46.185.197.88:61599, 38 total
Apr 14 00:06:29 odroid-hc1 electrumx[4190]: INFO:SessionManager:closing stale connections 232
Apr 14 00:07:00 odroid-hc1 electrumx[4190]: INFO:Prefetcher:new block height 571,525 hash 000000000000000000044abb9e95f9bc66f0a73c52943675cedfce241fdbaa21
Apr 14 00:09:13 odroid-hc1 electrumx[4190]: ERROR:asyncio:Unclosed client session
Apr 14 00:09:13 odroid-hc1 electrumx[4190]: client_session: <aiohttp.client.ClientSession object at 0xaefcac60>
Apr 14 00:09:13 odroid-hc1 electrumx[4190]: INFO:PeerManager:blacklist from https://electrum.org/blacklist.json has 427 entries
Apr 14 00:09:13 odroid-hc1 electrumx[4190]: ERROR:PeerManager:[217.12.201.89:50002 SSL] marking bad: (blacklisted)
Apr 14 00:09:13 odroid-hc1 electrumx[4190]: INFO:PeerManager:forgetting bad peer: 217.12.201.89
Apr 14 00:09:42 odroid-hc1 electrumx[4190]: INFO:LocalRPC:[1669] RPC 127.0.0.1:38976, 33 total
Apr 14 00:09:51 odroid-hc1 electrumx[4190]: INFO:LocalRPC:[1670] RPC 127.0.0.1:39022, 33 total
@kyuupichan

This comment has been minimized.

Copy link
Owner

commented Apr 14, 2019

If a bunch of connections come in one or two cycles of the event loop it can overshoot. There is not much I can or want to do about that, it would just end up complicating the code for little benefit. Other than that the feature is working as intended.

@kyuupichan kyuupichan closed this Apr 14, 2019

kyuupichan added a commit that referenced this issue Apr 14, 2019

@kyuupichan

This comment has been minimized.

Copy link
Owner

commented Apr 14, 2019

Just want to add as a comment that SSL connections have a complex handshake, and asyncio only informs an app that a connection has happened after the handshake, so it's possible to get more connections appearing after the listening socket was closed because they actually initially connected before it was closed. There is nothing an app can do about that. So MAX_SESSIONS is necessarily a little approximate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.