The dead simple 69-line proxy

in HiveDevs3 years ago (edited)

dead_simple_proxy_thumbnail.png

Introducing the dead simple hive JSON-RPC proxy that only consists of exactly 69 lines of NodeJS code, excluding empty lines and comments. It is as barebones as it can get such that it will work with most existing libraries and applications but lacks some features such as caching and batch requests which can be easily added later when needed.

Why does this even exist!?

Well this only exists because I'm having issues with Jussi ever since this happened. According to @fullnodeupdate, several Hive API nodes (including mine) have their uptime nosedived since the very beginning of October probably due to the same reason.

My logs were spammed with this even though the SSL certificates are actually valid (although not for all requests):

{"exception":"ClientConnectorSSLError(ConnectionKey(host='actual-api-host', port=443, is_ssl=True, ssl=None, proxy=None, proxy_auth=None, proxy_headers_hash=4978515757102267426), SSLError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:833)'))","message":"Internal Error","error_id":"cced2e93-6b4f-4124-99bf-5485bd745f6e","jrpc_request_id":1,"jussi_request_id":"000065322797678071","event":"Internal Error","logger":"jussi.errors","level":"error"}

where actual-api-host is the domain that points to the node that is actually serving the data which is kept private, or the redirected API endpoint during downtime.

I attempted to recompile the docker image but still getting the same exceptions. My guess at this point would be outdated dependencies.

I also experimented with Ecency rpc-proxy but was getting a lot of these errors for several important API methods (again, not all API methods):

module 'aioredis' has no attribute 'create_pool'

Tried to look it up but could not find a working solution or a fix. That leaves me with creating my own custom solution so that each call continues to get routed to the appropriate service while keeping it simple and easy to maintain.

Where to find?

This is just a small NodeJS app that does not deserve its own Git repository, hence you can find it in the proxy folder under my hiverpc-resources repo where all relevant files and notes regarding techcoderx.com RPC go to. Installation is relatively simple as well, the only dependency needed for it to run is NodeJS. The config file is the same as the one used in Ecency rpc-proxy.

Need multi-threading?

Due to its simplicity, it is easy to spin up a PM2 cluster that shares the same port that balances the server load across multiple threads with zero code modifications. As for techcoderx.com RPC, a single process is only using less than 10% of a CPU core during relatively busy times so this setup is not really needed here.


Hive witness footer 2.png

Sort:  

nice

nice.png

Couldn't you just have run Jussi outside the docker image? That's how we run it.

Haven't tried that, the installation docs only refer to running in a docker container hence will have to figure that out myself. But at least I have something that works even though it may have worse performance.

Congratulations @techcoderx! You received a personal badge!

You powered-up at least 10 HIVE on Hive Power Up Day!
Wait until the end of Power Up Day to find out the size of your Power-Bee.
May the Hive Power be with you!

You can view your badges on your board and compare yourself to others in the Ranking

Check out the last post from @hivebuzz:

Hive Power Up Day - November 1st 2021 - Hive Power Delegation
Bee ready for the 2nd Hive Power Up Month challenge!
Support the HiveBuzz project. Vote for our proposal!

Congratulations @techcoderx! You received a personal badge!

You powered-up at least 10 HIVE on Hive Power Up Day! This entitles you to a level 1 badge.
Participate in the next Power Up Day and try to power-up more HIVE to get a bigger Power-Bee.
May the Hive Power be with you!

You can view your badges on your board and compare yourself to others in the Ranking

Check out the last post from @hivebuzz:

Hive Power Up Day - November 1st 2021 - Hive Power Delegation
Support the HiveBuzz project. Vote for our proposal!