namecoin / nmcontrol

Namecoin Control. This repo is deprecated in favor of https://github.com/namecoin/ncdns
136 stars 38 forks source link

OS X: error: [Errno 49] Can't assign requested address #116

Closed rinchen closed 9 years ago

rinchen commented 9 years ago
$ sudo ./nmcontrol.py --daemon=0
2015-11-10 20:50:16,036 - __main__ - INFO - #######################################################
Bottle v0.12.9 server starting up (using WSGIRefServer())...
Listening on http://127.0.0.2:8080/
Hit Ctrl-C to quit.

2015-11-10 20:50:16,076 - __main__ - INFO - Plugins started : domain, http, dns, systray
2015-11-10 20:50:16,076 - pluginSystray - INFO - pluginSystray: Sorry, the systray icon is only available on Windows so far.
Exception in thread http:
Traceback (most recent call last):
  File "/usr/local/Cellar/python/2.7.10_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py", line 810, in __bootstrap_inner
    self.run()
  File "/Users/joey/nmcontrol/lib/plugin.py", line 49, in run
    self.start2()
  File "/Users/joey/nmcontrol/lib/plugin.py", line 68, in start2
    return self.pStart()
  File "/Users/joey/nmcontrol/plugin/pluginHttp.py", line 124, in pStart
    run(host=self.conf['host'], port=int(self.conf['port']))
  File "/usr/local/lib/python2.7/site-packages/bottle.py", line 3117, in run
    server.run(app)
  File "/usr/local/lib/python2.7/site-packages/bottle.py", line 2771, in run
    srv = make_server(self.host, self.port, app, server_cls, handler_cls)
  File "/usr/local/Cellar/python/2.7.10_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/wsgiref/simple_server.py", line 151, in make_server
    server = server_class((host, port), handler_class)
  File "/usr/local/Cellar/python/2.7.10_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/SocketServer.py", line 420, in __init__
    self.server_bind()
  File "/usr/local/Cellar/python/2.7.10_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/wsgiref/simple_server.py", line 48, in server_bind
    HTTPServer.server_bind(self)
  File "/usr/local/Cellar/python/2.7.10_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/BaseHTTPServer.py", line 108, in server_bind
    SocketServer.TCPServer.server_bind(self)
  File "/usr/local/Cellar/python/2.7.10_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/SocketServer.py", line 434, in server_bind
    self.socket.bind(self.server_address)
  File "/usr/local/Cellar/python/2.7.10_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/socket.py", line 228, in meth
    return getattr(self._sock,name)(*args)
error: [Errno 49] Can't assign requested address

^C2015-11-10 20:50:17,822 - plugin - INFO - Plugin domain stopped
2015-11-10 20:50:17,822 - pluginHttp - INFO - Plugin http stopped
2015-11-10 20:50:17,822 - plugin - INFO - Plugin dns stopped
2015-11-10 20:50:17,822 - plugin - INFO - Plugin data stopped
2015-11-10 20:50:17,823 - pluginRpc - INFO - Plugin rpc stopped
2015-11-10 20:50:17,823 - pluginMain - INFO - Plugin main stopped
rinchen commented 9 years ago

Here's the debug version

$ sudo ./nmcontrol.py --daemon=0 --debug=1
Password:
2015-11-10 20:56:43,476 - __main__ - INFO - #######################################################
2015-11-10 20:56:43,476 - __main__ - DEBUG - DEBUG MODE 1 (set from console)
2015-11-10 20:56:43,480 - __main__ - DEBUG - launching service serviceDNS
2015-11-10 20:56:43,489 - __main__ - DEBUG - launching plugin pluginData
2015-11-10 20:56:43,490 - __main__ - DEBUG - launching plugin pluginDns
2015-11-10 20:56:43,491 - __main__ - DEBUG - launching plugin pluginHttp
2015-11-10 20:56:43,512 - __main__ - DEBUG - launching plugin pluginNamespaceDomain
2015-11-10 20:56:43,513 - __main__ - DEBUG - launching plugin pluginRpc
2015-11-10 20:56:43,514 - __main__ - DEBUG - launching plugin pluginSystray
2015-11-10 20:56:43,515 - plugin - DEBUG - Plugin domain parent starting
2015-11-10 20:56:43,515 - plugin - DEBUG - Plugin http parent starting
2015-11-10 20:56:43,515 - plugin - DEBUG - Plugin data parent starting
2015-11-10 20:56:43,515 - pluginHttp - DEBUG - Starting HTTP server...
2015-11-10 20:56:43,515 - plugin - DEBUG - Plugin dns parent starting
Bottle v0.12.9 server starting up (using WSGIRefServer())...
Listening on http://127.0.0.2:8080/
2015-11-10 20:56:43,516 - plugin - DEBUG - Plugin dns parent start
2015-11-10 20:56:43,516 - __main__ - INFO - Plugins started : domain, http, dns, systray
2015-11-10 20:56:43,516 - plugin - DEBUG - Plugin systray parent starting
2015-11-10 20:56:43,516 - pluginSystray - DEBUG - Systray.py: Plugin systray parent start
Hit Ctrl-C to quit.

2015-11-10 20:56:43,516 - plugin - DEBUG - Plugin dns parent starting
2015-11-10 20:56:43,517 - pluginNamespaceDomain - DEBUG - Set up DNS handlers, len = 1
2015-11-10 20:56:43,520 - pluginSystray - INFO - pluginSystray: Sorry, the systray icon is only available on Windows so far.
2015-11-10 20:56:43,517 - plugin - DEBUG - Plugin main parent starting
2015-11-10 20:56:43,520 - plugin - DEBUG - Plugin rpc parent starting
2015-11-10 20:56:43,521 - serviceDNS - DEBUG - Service dns started
Exception in thread http:
Traceback (most recent call last):
  File "/usr/local/Cellar/python/2.7.10_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py", line 810, in __bootstrap_inner
    self.run()
  File "/Users/joey/nmcontrol/lib/plugin.py", line 49, in run
    self.start2()
  File "/Users/joey/nmcontrol/lib/plugin.py", line 68, in start2
    return self.pStart()
  File "/Users/joey/nmcontrol/plugin/pluginHttp.py", line 124, in pStart
    run(host=self.conf['host'], port=int(self.conf['port']))
  File "/usr/local/lib/python2.7/site-packages/bottle.py", line 3117, in run
    server.run(app)
  File "/usr/local/lib/python2.7/site-packages/bottle.py", line 2771, in run
    srv = make_server(self.host, self.port, app, server_cls, handler_cls)
  File "/usr/local/Cellar/python/2.7.10_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/wsgiref/simple_server.py", line 151, in make_server
    server = server_class((host, port), handler_class)
  File "/usr/local/Cellar/python/2.7.10_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/SocketServer.py", line 420, in __init__
    self.server_bind()
  File "/usr/local/Cellar/python/2.7.10_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/wsgiref/simple_server.py", line 48, in server_bind
    HTTPServer.server_bind(self)
  File "/usr/local/Cellar/python/2.7.10_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/BaseHTTPServer.py", line 108, in server_bind
    SocketServer.TCPServer.server_bind(self)
  File "/usr/local/Cellar/python/2.7.10_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/SocketServer.py", line 434, in server_bind
    self.socket.bind(self.server_address)
  File "/usr/local/Cellar/python/2.7.10_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/socket.py", line 228, in meth
    return getattr(self._sock,name)(*args)
error: [Errno 49] Can't assign requested address

^C2015-11-10 20:56:47,996 - pluginRpc - DEBUG - RPC stop listening
2015-11-10 20:56:47,996 - plugin - DEBUG - Plugin main parent stopping
2015-11-10 20:56:47,996 - pluginMain - DEBUG - Plugin main stopping
2015-11-10 20:56:47,996 - plugin - DEBUG - Plugin domain parent stopping
2015-11-10 20:56:47,997 - plugin - DEBUG - Plugin domain parent stop
2015-11-10 20:56:47,997 - plugin - INFO - Plugin domain stopped
2015-11-10 20:56:47,997 - plugin - DEBUG - Plugin http parent stopping
2015-11-10 20:56:47,997 - pluginHttp - DEBUG - Plugin stop : http
2015-11-10 20:56:47,997 - pluginHttp - INFO - Plugin http stopped
2015-11-10 20:56:47,997 - plugin - DEBUG - Plugin dns parent stopping
2015-11-10 20:56:47,997 - plugin - DEBUG - Plugin dns parent stop
2015-11-10 20:56:47,997 - plugin - INFO - Plugin dns stopped
2015-11-10 20:56:47,997 - plugin - DEBUG - Plugin systray parent stopping
2015-11-10 20:56:47,997 - pluginSystray - DEBUG - Plugin systray parent stop
2015-11-10 20:56:47,997 - plugin - DEBUG - Plugin data parent stopping
2015-11-10 20:56:47,997 - plugin - DEBUG - Plugin data parent stop
2015-11-10 20:56:47,997 - plugin - INFO - Plugin data stopped
2015-11-10 20:56:47,998 - plugin - DEBUG - Plugin rpc parent stopping
2015-11-10 20:56:47,998 - pluginRpc - DEBUG - Plugin stop : rpc
2015-11-10 20:56:47,998 - pluginRpc - DEBUG - RPC - sending cmd : ['exit']
2015-11-10 20:56:47,998 - pluginRpc - INFO - Plugin rpc stopped
2015-11-10 20:56:47,998 - pluginMain - INFO - Plugin main stopped
JeremyRand commented 9 years ago

I'm not certain, but maybe something else is already listening on the port that the REST API (Bottle) wants to listen on?

@phelix , any ideas?

phelixbtc commented 9 years ago

@rinchen As @JeremyRand said, make sure there is nothing else on the port, e.g. a daemon instance of nmcontrol (try python ./nmcontrol stop)

Any particular reason you are using 127.0.0.2 instead of 127.0.0.1 ?

rinchen commented 9 years ago

@phelixbtc good catch on 127.0.0.2. I am specifically NOT using that:

 1 [dns]
  2 ; Launch at startup
  3 ;start=1
  4
  5 ; Listen on ip
  6 host=127.0.0.1
  7
  8 ; Disable lookups for standard domains
  9 disable_standard_lookups=1
 10
 11 ; Listen on port
 12 ;port=53
 13
 14 ; Forward standard requests to
 15 resolver=127.0.0.54,10.10.10.1

127.0.0.54 is dnscrypt

rinchen commented 9 years ago

@JeremyRand I made sure nmcontrol was not running (ps ax | grep nmcontrol and then kill).

rinchen commented 9 years ago

I've also tried stopping dnscrypt with no improvement

rinchen commented 9 years ago

@phelixbtc if I comment out host=127.0.0.1 it still forces 127.0.0.2

phelixbtc commented 9 years ago

@rinchen Ah, I was too quick and mixed up the DNS address and the http (bottle) address. 127.0.0.2 is the default for the http server. To change the http server settings edit plugin-http.conf and maybe change ip address and/or port in there.

rinchen commented 9 years ago

@phelixbtc I don't get that error when I use --http.host=127.0.0.1 :-)

phelixbtc commented 9 years ago

@rinchen great maybe we need to change the default. @JeremyRand Was there any particular reason we chose 127.0.0.2?

phelixbtc commented 9 years ago

@rinchen And thanks for your feedback!

rinchen commented 9 years ago

in testing it works now, I think. I can do nslookup namecoin.org 127.0.0.1 and it works but nslookup nx.bit 127.0.0.1 fails. Namecoint.qt is still syncing so maybe that's at fault.

rinchen commented 9 years ago

I was mistaken:

2015-11-11 07:50:24,884 - pluginNamespaceDomain - DEBUG - Resolving : nx.bit getIp4
2015-11-11 07:50:24,885 - backendDataNamecoin - DEBUG - BackendDataNamecoin: ['name_show', 'd/nx']
2015-11-11 07:50:24,885 - dnsServer - ERROR - dnsServer: lookup failed
Traceback (most recent call last):
  File "/Users/joey/nmcontrol/lib/dnsServer/__init__.py", line 96, in serve
    rcode, an_resource_records = source_instance.get_response(query, ".".join(question), qtype, qclass, src_addr)
  File "/Users/joey/nmcontrol/lib/dnsServer/namecoindns.py", line 99, in get_response
    answers = app['services']['dns'].lookup({"query":query, "domain":domain, "qtype":qtype, "qclass":qclass, "src_addr":src_addr})
  File "/Users/joey/nmcontrol/service/serviceDNS.py", line 41, in lookup
    return app['plugins']['domain'].lookup(qdict)
  File "/Users/joey/nmcontrol/plugin/pluginNamespaceDomain.py", line 200, in lookup
    return self._bitLookup(qdict)
  File "/Users/joey/nmcontrol/plugin/pluginNamespaceDomain.py", line 227, in _bitLookup
    answers = app['plugins']['dns'].getIp4(qdict["domain"])
  File "/Users/joey/nmcontrol/plugin/pluginDns.py", line 132, in getIp4
    result = self._getRecordForRPC(domain, 'getIp4')
  File "/Users/joey/nmcontrol/plugin/pluginDns.py", line 126, in _getRecordForRPC
    self._resolve(domain, recType, result)
  File "/Users/joey/nmcontrol/plugin/pluginDns.py", line 88, in _resolve
    handler._resolve(domain, recType, result)
  File "/Users/joey/nmcontrol/plugin/pluginNamespaceDomain.py", line 58, in _resolve
    nameData = app['plugins']['data'].getValueProcessed(name)
  File "/Users/joey/nmcontrol/plugin/pluginData.py", line 151, in getValueProcessed
    data = self.getValue(name)
  File "/Users/joey/nmcontrol/plugin/pluginData.py", line 138, in getValue
    data = self.getData(name)
  File "/Users/joey/nmcontrol/plugin/pluginData.py", line 106, in getData
    error, data = self.update.getName(name)
  File "/Users/joey/nmcontrol/lib/backendDataNamecoin.py", line 43, in getName
    return self._rpcSend(["name_show", name])
  File "/Users/joey/nmcontrol/lib/backendDataNamecoin.py", line 48, in _rpcSend
    self._loadRPCConfig()
  File "/Users/joey/nmcontrol/lib/backendDataNamecoin.py", line 15, in _loadRPCConfig
    ini_str = '[r]\n' + open(self.conf).read()
IOError: [Errno 2] No such file or directory: '/Users/joey/Library/Application Support/Namecoin/namecoin.conf'
2015-11-11 07:50:24,886 - serviceDNS - DEBUG - Lookup: {'query': '', 'domain': 'nx.bit.stan4d.net', 'src_addr': ('127.0.0.1', 59245), 'qtype': 1, 'qclass': 1}
2015-11-11 07:50:24,886 - serviceDNS - DEBUG - Fetching IP Address for:  nx.bit.stan4d.net with NS Server: 127.0.0.54
2015-11-11 07:50:24,911 - serviceDNS - DEBUG - * result:  []
rinchen commented 9 years ago

~/Library/Application Support/Namecoin/ exists but namecoin.conf inside it does not.

rinchen commented 9 years ago

and that's a user error. Fixing now.

rinchen commented 9 years ago

Ok it's working now but I need you to update https://github.com/namecoin/nmcontrol#prerequisites

I got this:

   raise Exception( "Error reaching Namecoin client (make sure Namecoin client is running and accepting RPC connections): " + str(e) + ' - Unable to send command : ' + str(body) )
Exception: Error reaching Namecoin client (make sure Namecoin client is running and accepting RPC connections): [Errno 61] Connection refused - Unable to send command : {"params": ["d/nx"], "method": "name_show", "id": 1}

and that's because namecoin-qt needed to be restarted. Please add "a) scramble the password in the above example" and "b) restart namecoin-qt before continuing" or something to that effect. Thanks!

rinchen commented 9 years ago

btw, when going to http://127.0.0.1:8080/ I get a 404 not found

127.0.0.1 - - [11/Nov/2015 08:00:38] "GET / HTTP/1.1" 404 720

rinchen commented 9 years ago

Another doc update, https://github.com/namecoin/nmcontrol#dns-config-on-linux--mac-os-x--manual-dns-config-windows-7-and-below needs to point out that there MUST be a comma after your DNS entry otherwise nmcontrol throws errors (better error handling there might be the correct solution)

phelixbtc commented 9 years ago

https://github.com/namecoin/nmcontrol/pull/117/files
The http server is only for RPC currently so that 404 is expected.

JeremyRand commented 9 years ago

-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256

@JeremyRand Was there any particular reason we chose |127.0.0.2|?

@phelixbtc I picked 127.0.0.2 because it was available on my machine. No other special reason. (I believe khal used 127.0.0.2 for NMControl-related things, but my memory is fuzzy.) Honestly any IP:port will be in use on someone's machine... possibly making a more clear error message and providing clear instructions to fix is more important than magically picking something that is rarely in use.

~/Library/Application Support/Namecoin/ exists but namecoin.conf inside it does not.

There are ways to access name data from Namecoin Core without setting a user/pass in namecoin.conf (either cookie authentication with RPC, or REST), but at the moment NMControl doesn't support them. It is also unlikely that they will be backported to the Namecoin 0.3.x branch. -----BEGIN PGP SIGNATURE----- Version: GnuPG v2

iQIcBAEBCAAGBQJWQ4G5AAoJEAHN/EbZ1y0668AQANTw5KXw5ZUbz5Z1EcozsGgA ZwUD3mDwTD1fY0rvzH1ouPdsirwkd7J5eGLoyvJOrx/H/aIL7hg5JNCA1IYhLujS Deqju4L7ZxK7ONr/rdftZOyzjDWl9rCrIojkKsYZdZ8L+XM0x0nyt16se0zvC4Kk vjencM9w/8SDHHtk5isW/f9p+S0j6oKLxjBqf3uIDYimxtAhIBwYVZVGvKcNtpOB i9CtODjefXGixf2hNGVVqroBzVPOcUvI0+CCeIg6uzc7irobjRnRdY9xUjr0Mafu jGavAwLk0/NniY2LOglQjoACdRD/2/aTtHc7Ze2Ekw9tnzjp33I2D4BuYGavhiaf qFNNvpQaVVl1jRnIF5PKyOWkWZU7cxkD5c1DsSZJ1ctdCzZPoF1w6GdpO5b2Ahkw 8Yg9EbWvNxmFnEfaLkK21peKg+Suu6JSszDp49tCdK7dJQCavRrVhXXe/HONIE/5 2BMxlS+wvb+hWDFXNUYsAQX3WgRRuOd0CxusvjM0OnffIgmtDy81pi/Uau2TKkgZ AFfJ9Q5RgTMqdDw5O5ZFVAbFxXu7psQsdeR44niC5N2w9mo5Jd2F5cmcQv/+HpJK Ct+FTmpX4A9kQOpEZAX5pQzVhJ9SQ8t+2trSHQnqkGAh2R5FZH7kfIH6oT9TCs7F y6m0rlwsRUbH0OAGWoee =bYEF -----END PGP SIGNATURE-----

allthingsgo commented 9 years ago

On my OSX10.9, I had a named running in the background... that's how I couldn't get nmcontrol up and running... Can nmcontrol.py be deployed where the machine is also running its own DNS service ? Once I stopped named process on OSX, nmcontrol seems to be working ...along with namecoin-Qt .

JeremyRand commented 9 years ago

@allthingsgo Can you make another issue for that question?

phelixbtc commented 9 years ago

@allthingsgo Maybe named was using one of the ports that nmcontrol is using by default. You can change ip addresses and ports in the nmcontrol conf files. Thanks for the feedback, if you there are still open questions please open a new issue as Jeremy suggested.

closing as solved