oxen-io / oxen-observer

Python based Oxen blockchain explorer
GNU General Public License v3.0
13 stars 28 forks source link

TypeError: connect_remote(): incompatible function arguments #17

Closed martin-braun closed 1 year ago

martin-braun commented 1 year ago

I try to run the debug server in my Debian guest OS, but running

FLASK_APP=observer flask run --reload --debugger --host=0.0.0.0

and accessing the website logs the following exception:

[2023-06-13 12:17:39,444] ERROR in app: Exception on / [GET]
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/flask/app.py", line 2447, in wsgi_app
    response = self.full_dispatch_request()
  File "/usr/lib/python3/dist-packages/flask/app.py", line 1952, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/usr/lib/python3/dist-packages/flask/app.py", line 1821, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/usr/lib/python3/dist-packages/flask/_compat.py", line 39, in reraise
    raise value
  File "/usr/lib/python3/dist-packages/flask/app.py", line 1950, in full_dispatch_request
    rv = self.dispatch_request()
  File "/usr/lib/python3/dist-packages/flask/app.py", line 1936, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/media/psf/Home/git/gh/oxen-io/oxen-observer/observer.py", line 271, in main
    omq, oxend = omq_connection()
  File "/media/psf/Home/git/gh/oxen-io/oxen-observer/lmq.py", line 15, in omq_connection
    oxend = omq.connect_remote(config.oxend_rpc)
TypeError: connect_remote(): incompatible function arguments. The following argument types are supported:
    1. (self: oxenmq.OxenMQ, remote: oxenmq.Address, on_success: Callable[[oxenmq.ConnectionID], None], on_failure: Callable[[oxenmq.ConnectionID, str], None], *, timeout: datetime.timedelta = datetime.timedelta(seconds=10), ephemeral_routing_id: Optional[bool] = None, auth_level: oxenmq.AuthLevel = <AuthLevel.none: 1>) -> oxenmq.ConnectionID
    2. (self: oxenmq.OxenMQ, remote: oxenmq.Address, timeout: datetime.timedelta = datetime.timedelta(seconds=10), *, ephemeral_routing_id: Optional[bool] = None, auth_level: oxenmq.AuthLevel = <AuthLevel.none: 1>) -> oxenmq.ConnectionID

Invoked with: <oxenmq.OxenMQ object at 0x7f50d02392b0>, None
10.211.55.2 - - [13/Jun/2023 12:17:39] "GET / HTTP/1.1" 500 -

My devnet-observer.ini contents are:

[uwsgi]
chdir = /media/psf/Home/git/gh/oxen-io/oxen-observer/
socket = devnet.wsgi
plugins = python3,logfile
processes = 6
manage-script-name = true
mount = /=observer:app

logger = file:logfile=/media/psf/Home/git/gh/oxen-io/oxen-observer/uwsgi.log,maxsize=1048576

No uwsgi.log gets created. I'm probably missing something here, so a better documentation would be helpful for new-comers.

majestrate commented 1 year ago

what are you using in your config for your rpc url?

martin-braun commented 1 year ago

@majestrate I kept it default (ipc://oxend/mainnet.sock). oxend is fully synced and running on the same system.

I kinda assumed that mainnet.py is only important when running uwsgi-emperor, since it's not mentioned in the debug section.

I kindly ask for some clearance, since I never setup a blockchain explorer in the past. How can I get this running in debug mode, please?

majestrate commented 1 year ago

On Sunday, 18 June 2023 08:35:28 EDT Martin Braun wrote:

@majestrate I kept it default (ipc://oxend/mainnet.sock). oxend is fully synced and running on the same system.

I kinda assumed that mainnet.py is only important when running uwsgi-emperor, since it's not mentioned in the debug section.

I kindly ask for some clearance, since I never setup a blockchain explorer in the past. How can I get this running, please?

the default socket file for oxend with the debian packages i believe is at / var/lib/oxen/oxend.sock

additionally, if i recall this will also require the uwsgi vassal running under the same group (not necessarily user) as the oxen daemon so it can read the socket file. this group i THINK is still called _loki

this means, given the above information is correct, (jason can correct me here on such information) the vassal needs to have "gid=_loki" added to the uwsgi section of the vassel and the rpc socket set in the ini config for the explorer be set to use ipc:///var/lib/oxen/oxend.sock

you could also run oxend as a "normal" user such that it uses $HOME/.oxen as the data dir for the node, then i believe it uses $HOME/.oxen/mainnet.sock (i think?). the url for rpc can then be symlinked into the directory that the explorer is running in like so:

cd where/ever/your/explorer/runs ln -s $HOME/.oxen/mainnet.sock

and you can then set rpc socket url to be ipc://mainnet.sock

-- ~jeff

martin-braun commented 1 year ago

Hi @majestrate this certainly helps me to get my head around. While the first part of your response is fairly documented (production use), the debug instructions in regards of the sock are missing. Big thanks for the clearance.

However, I wasn't able to fix the sock issue by following your instructions blindly. After fiddling around, I figured it out:

The sock is called oxend.sock and needs to be set in the local_config.py to be used in debug mode. Simply executing

echo config.oxend_rpc = oxenmq.Address('ipc://$HOME/.oxen/oxend.sock') >> local_config.py

will fix the problem, but there are more issues down the line, i.e. #18. I appreciate your support, maybe you have some further advice. 🙏