university-course
university-course copied to clipboard
Lab 03 getPeers fails when run from second node with address 0.0.0.0:5001
I run two nodes for Lab 03.
For the first node, the getPeers method returns null.
For the second node run with the command:
docker run --name "blockchain-node-2" -p "5001:5001" -e node_port=5001 -e miner_address="default_address-1" -e host="0.0.0.0" blockchain4students/blockchain-node:0.1
when I send the getPeers request I get a complex failure:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>requests.exceptions.ConnectionError: HTTPConnectionPool(host='0.0.0.0', port=5000): Max retries exceeded with url: /register/node (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f3c8f099b20>: Failed to establish a new connection: [Errno 111] Connection refused')) // Werkzeug Debugger</title>
<link rel="stylesheet" href="?__debugger__=yes&cmd=resource&f=style.css"
type="text/css">
<!-- We need to make sure this has a favicon so that the debugger does
not accidentally trigger a request to /favicon.ico which might
change the application's state. -->
<link rel="shortcut icon"
href="?__debugger__=yes&cmd=resource&f=console.png">
<script src="?__debugger__=yes&cmd=resource&f=debugger.js"></script>
<script type="text/javascript">
var TRACEBACK = 139898075212432,
CONSOLE_MODE = false,
EVALEX = true,
EVALEX_TRUSTED = false,
SECRET = "Zwlm3C3Ky48PLj75E573";
</script>
</head>
<body style="background-color: #fff">
<div class="debugger">
<h1>requests.exceptions.ConnectionError</h1>
<div class="detail">
<p class="errormsg">requests.exceptions.ConnectionError: HTTPConnectionPool(host='0.0.0.0', port=5000): Max retries exceeded with url: /register/node (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f3c8f099b20>: Failed to establish a new connection: [Errno 111] Connection refused'))</p>
</div>
<h2 class="traceback">Traceback <em>(most recent call last)</em></h2>
<div class="traceback">
<h3></h3>
<ul><li><div class="frame" id="frame-139898057339712">
<h4>File <cite class="filename">"/opt/venv/lib/python3.8/site-packages/urllib3/connection.py"</cite>,
line <em class="line">174</em>,
in <code class="function">_new_conn</code></h4>
<div class="source library"><pre class="line before"><span class="ws"></span> </pre>
<pre class="line before"><span class="ws"> </span>if self.socket_options:</pre>
<pre class="line before"><span class="ws"> </span>extra_kw["socket_options"] = self.socket_options</pre>
<pre class="line before"><span class="ws"></span> </pre>
<pre class="line before"><span class="ws"> </span>try:</pre>
<pre class="line current"><span class="ws"> </span>conn = connection.create_connection(</pre>
<pre class="line after"><span class="ws"> </span>(self._dns_host, self.port), self.timeout, **extra_kw</pre>
<pre class="line after"><span class="ws"> </span>)</pre>
<pre class="line after"><span class="ws"></span> </pre>
<pre class="line after"><span class="ws"> </span>except SocketTimeout:</pre>
<pre class="line after"><span class="ws"> </span>raise ConnectTimeoutError(</pre></div>
</div>
<li><div class="frame" id="frame-139898057339904">
<h4>File <cite class="filename">"/opt/venv/lib/python3.8/site-packages/urllib3/util/connection.py"</cite>,
line <em class="line">95</em>,
in <code class="function">create_connection</code></h4>
<div class="source library"><pre class="line before"><span class="ws"> </span>if sock is not None:</pre>
<pre class="line before"><span class="ws"> </span>sock.close()</pre>
<pre class="line before"><span class="ws"> </span>sock = None</pre>
<pre class="line before"><span class="ws"></span> </pre>
<pre class="line before"><span class="ws"> </span>if err is not None:</pre>
<pre class="line current"><span class="ws"> </span>raise err</pre>
<pre class="line after"><span class="ws"></span> </pre>
<pre class="line after"><span class="ws"> </span>raise socket.error("getaddrinfo returns an empty list")</pre>
<pre class="line after"><span class="ws"></span> </pre>
<pre class="line after"><span class="ws"></span> </pre>
<pre class="line after"><span class="ws"></span>def _set_socket_options(sock, options):</pre></div>
</div>
<li><div class="frame" id="frame-139898057340048">
<h4>File <cite class="filename">"/opt/venv/lib/python3.8/site-packages/urllib3/util/connection.py"</cite>,
line <em class="line">85</em>,
in <code class="function">create_connection</code></h4>
<div class="source library"><pre class="line before"><span class="ws"></span> </pre>
<pre class="line before"><span class="ws"> </span>if timeout is not socket._GLOBAL_DEFAULT_TIMEOUT:</pre>
<pre class="line before"><span class="ws"> </span>sock.settimeout(timeout)</pre>
<pre class="line before"><span class="ws"> </span>if source_address:</pre>
<pre class="line before"><span class="ws"> </span>sock.bind(source_address)</pre>
<pre class="line current"><span class="ws"> </span>sock.connect(sa)</pre>
<pre class="line after"><span class="ws"> </span>return sock</pre>
<pre class="line after"><span class="ws"></span> </pre>
<pre class="line after"><span class="ws"> </span>except socket.error as e:</pre>
<pre class="line after"><span class="ws"> </span>err = e</pre>
<pre class="line after"><span class="ws"> </span>if sock is not None:</pre></div>
</div>
<li><div class="exc-divider">During handling of the above exception, another exception occurred:</div>
<li><div class="frame" id="frame-139898057339184">
<h4>File <cite class="filename">"/opt/venv/lib/python3.8/site-packages/urllib3/connectionpool.py"</cite>,
line <em class="line">703</em>,
in <code class="function">urlopen</code></h4>
<div class="source library"><pre class="line before"><span class="ws"> </span>)</pre>
<pre class="line before"><span class="ws"> </span>if is_new_proxy_conn and http_tunnel_required:</pre>
<pre class="line before"><span class="ws"> </span>self._prepare_proxy(conn)</pre>
<pre class="line before"><span class="ws"></span> </pre>
<pre class="line before"><span class="ws"> </span># Make the request on the httplib connection object.</pre>
<pre class="line current"><span class="ws"> </span>httplib_response = self._make_request(</pre>
<pre class="line after"><span class="ws"> </span>conn,</pre>
<pre class="line after"><span class="ws"> </span>method,</pre>
<pre class="line after"><span class="ws"> </span>url,</pre>
<pre class="line after"><span class="ws"> </span>timeout=timeout_obj,</pre>
<pre class="line after"><span class="ws"> </span>body=body,</pre></div>
</div>
<li><div class="frame" id="frame-139898057339328">
<h4>File <cite class="filename">"/opt/venv/lib/python3.8/site-packages/urllib3/connectionpool.py"</cite>,
line <em class="line">398</em>,
in <code class="function">_make_request</code></h4>
<div class="source library"><pre class="line before"><span class="ws"> </span># urllib3.request. It also calls makefile (recv) on the socket.</pre>
<pre class="line before"><span class="ws"> </span>try:</pre>
<pre class="line before"><span class="ws"> </span>if chunked:</pre>
<pre class="line before"><span class="ws"> </span>conn.request_chunked(method, url, **httplib_request_kw)</pre>
<pre class="line before"><span class="ws"> </span>else:</pre>
<pre class="line current"><span class="ws"> </span>conn.request(method, url, **httplib_request_kw)</pre>
<pre class="line after"><span class="ws"></span> </pre>
<pre class="line after"><span class="ws"> </span># We are swallowing BrokenPipeError (errno.EPIPE) since the server is</pre>
<pre class="line after"><span class="ws"> </span># legitimately able to close the connection after sending a valid response.</pre>
<pre class="line after"><span class="ws"> </span># With this behaviour, the received response is still readable.</pre>
<pre class="line after"><span class="ws"> </span>except BrokenPipeError:</pre></div>
</div>
<li><div class="frame" id="frame-139898057339376">
<h4>File <cite class="filename">"/opt/venv/lib/python3.8/site-packages/urllib3/connection.py"</cite>,
line <em class="line">239</em>,
in <code class="function">request</code></h4>
<div class="source library"><pre class="line before"><span class="ws"> </span>else:</pre>
<pre class="line before"><span class="ws"> </span># Avoid modifying the headers passed into .request()</pre>
<pre class="line before"><span class="ws"> </span>headers = headers.copy()</pre>
<pre class="line before"><span class="ws"> </span>if "user-agent" not in (six.ensure_str(k.lower()) for k in headers):</pre>
<pre class="line before"><span class="ws"> </span>headers["User-Agent"] = _get_default_user_agent()</pre>
<pre class="line current"><span class="ws"> </span>super(HTTPConnection, self).request(method, url, body=body, headers=headers)</pre>
<pre class="line after"><span class="ws"></span> </pre>
<pre class="line after"><span class="ws"> </span>def request_chunked(self, method, url, body=None, headers=None):</pre>
<pre class="line after"><span class="ws"> </span>"""</pre>
<pre class="line after"><span class="ws"> </span>Alternative to the common request method, which sends the</pre>
<pre class="line after"><span class="ws"> </span>body with chunked encoding and not as one block</pre></div>
</div>
<li><div class="frame" id="frame-139898057339232">
<h4>File <cite class="filename">"/usr/local/lib/python3.8/http/client.py"</cite>,
line <em class="line">1255</em>,
in <code class="function">request</code></h4>
<div class="source library"><pre class="line before"><span class="ws"> </span>self._send_output(message_body, encode_chunked=encode_chunked)</pre>
<pre class="line before"><span class="ws"></span> </pre>
<pre class="line before"><span class="ws"> </span>def request(self, method, url, body=None, headers={}, *,</pre>
<pre class="line before"><span class="ws"> </span>encode_chunked=False):</pre>
<pre class="line before"><span class="ws"> </span>"""Send a complete request to the server."""</pre>
<pre class="line current"><span class="ws"> </span>self._send_request(method, url, body, headers, encode_chunked)</pre>
<pre class="line after"><span class="ws"></span> </pre>
<pre class="line after"><span class="ws"> </span>def _send_request(self, method, url, body, headers, encode_chunked):</pre>
<pre class="line after"><span class="ws"> </span># Honor explicitly requested Host: and Accept-Encoding: headers.</pre>
<pre class="line after"><span class="ws"> </span>header_names = frozenset(k.lower() for k in headers)</pre>
<pre class="line after"><span class="ws"> </span>skips = {}</pre></div>
</div>
<li><div class="frame" id="frame-139898057339088">
<h4>File <cite class="filename">"/usr/local/lib/python3.8/http/client.py"</cite>,
line <em class="line">1301</em>,
in <code class="function">_send_request</code></h4>
<div class="source library"><pre class="line before"><span class="ws"> </span>self.putheader(hdr, value)</pre>
<pre class="line before"><span class="ws"> </span>if isinstance(body, str):</pre>
<pre class="line before"><span class="ws"> </span># RFC 2616 Section 3.7.1 says that text default has a</pre>
<pre class="line before"><span class="ws"> </span># default charset of iso-8859-1.</pre>
<pre class="line before"><span class="ws"> </span>body = _encode(body, 'body')</pre>
<pre class="line current"><span class="ws"> </span>self.endheaders(body, encode_chunked=encode_chunked)</pre>
<pre class="line after"><span class="ws"></span> </pre>
<pre class="line after"><span class="ws"> </span>def getresponse(self):</pre>
<pre class="line after"><span class="ws"> </span>"""Get the response from the server.</pre>
<pre class="line after"><span class="ws"></span> </pre>
<pre class="line after"><span class="ws"> </span>If the HTTPConnection is in the correct state, returns an</pre></div>
</div>
<li><div class="frame" id="frame-139898057338992">
<h4>File <cite class="filename">"/usr/local/lib/python3.8/http/client.py"</cite>,
line <em class="line">1250</em>,
in <code class="function">endheaders</code></h4>
<div class="source library"><pre class="line before"><span class="ws"> </span>"""</pre>
<pre class="line before"><span class="ws"> </span>if self.__state == _CS_REQ_STARTED:</pre>
<pre class="line before"><span class="ws"> </span>self.__state = _CS_REQ_SENT</pre>
<pre class="line before"><span class="ws"> </span>else:</pre>
<pre class="line before"><span class="ws"> </span>raise CannotSendHeader()</pre>
<pre class="line current"><span class="ws"> </span>self._send_output(message_body, encode_chunked=encode_chunked)</pre>
<pre class="line after"><span class="ws"></span> </pre>
<pre class="line after"><span class="ws"> </span>def request(self, method, url, body=None, headers={}, *,</pre>
<pre class="line after"><span class="ws"> </span>encode_chunked=False):</pre>
<pre class="line after"><span class="ws"> </span>"""Send a complete request to the server."""</pre>
<pre class="line after"><span class="ws"> </span>self._send_request(method, url, body, headers, encode_chunked)</pre></div>
</div>
<li><div class="frame" id="frame-139898057339568">
<h4>File <cite class="filename">"/usr/local/lib/python3.8/http/client.py"</cite>,
line <em class="line">1010</em>,
in <code class="function">_send_output</code></h4>
<div class="source library"><pre class="line before"><span class="ws"> </span>A message_body may be specified, to be appended to the request.</pre>
<pre class="line before"><span class="ws"> </span>"""</pre>
<pre class="line before"><span class="ws"> </span>self._buffer.extend((b"", b""))</pre>
<pre class="line before"><span class="ws"> </span>msg = b"\r\n".join(self._buffer)</pre>
<pre class="line before"><span class="ws"> </span>del self._buffer[:]</pre>
<pre class="line current"><span class="ws"> </span>self.send(msg)</pre>
<pre class="line after"><span class="ws"></span> </pre>
<pre class="line after"><span class="ws"> </span>if message_body is not None:</pre>
<pre class="line after"><span class="ws"></span> </pre>
<pre class="line after"><span class="ws"> </span># create a consistent interface to message_body</pre>
<pre class="line after"><span class="ws"> </span>if hasattr(message_body, 'read'):</pre></div>
</div>
<li><div class="frame" id="frame-139898057339616">
<h4>File <cite class="filename">"/usr/local/lib/python3.8/http/client.py"</cite>,
line <em class="line">950</em>,
in <code class="function">send</code></h4>
<div class="source library"><pre class="line before"><span class="ws"> </span>file-like object that supports a .read() method, or an iterable object.</pre>
<pre class="line before"><span class="ws"> </span>"""</pre>
<pre class="line before"><span class="ws"></span> </pre>
<pre class="line before"><span class="ws"> </span>if self.sock is None:</pre>
<pre class="line before"><span class="ws"> </span>if self.auto_open:</pre>
<pre class="line current"><span class="ws"> </span>self.connect()</pre>
<pre class="line after"><span class="ws"> </span>else:</pre>
<pre class="line after"><span class="ws"> </span>raise NotConnected()</pre>
<pre class="line after"><span class="ws"></span> </pre>
<pre class="line after"><span class="ws"> </span>if self.debuglevel > 0:</pre>
<pre class="line after"><span class="ws"> </span>print("send:", repr(data))</pre></div>
</div>
<li><div class="frame" id="frame-139898057339664">
<h4>File <cite class="filename">"/opt/venv/lib/python3.8/site-packages/urllib3/connection.py"</cite>,
line <em class="line">205</em>,
in <code class="function">connect</code></h4>
<div class="source library"><pre class="line before"><span class="ws"> </span>self._tunnel()</pre>
<pre class="line before"><span class="ws"> </span># Mark this connection as not reusable</pre>
<pre class="line before"><span class="ws"> </span>self.auto_open = 0</pre>
<pre class="line before"><span class="ws"></span> </pre>
<pre class="line before"><span class="ws"> </span>def connect(self):</pre>
<pre class="line current"><span class="ws"> </span>conn = self._new_conn()</pre>
<pre class="line after"><span class="ws"> </span>self._prepare_conn(conn)</pre>
<pre class="line after"><span class="ws"></span> </pre>
<pre class="line after"><span class="ws"> </span>def putrequest(self, method, url, *args, **kwargs):</pre>
<pre class="line after"><span class="ws"> </span>""" """</pre>
<pre class="line after"><span class="ws"> </span># Empty docstring because the indentation of CPython's implementation</pre></div>
</div>
<li><div class="frame" id="frame-139898057339520">
<h4>File <cite class="filename">"/opt/venv/lib/python3.8/site-packages/urllib3/connection.py"</cite>,
line <em class="line">186</em>,
in <code class="function">_new_conn</code></h4>
<div class="source library"><pre class="line before"><span class="ws"> </span>"Connection to %s timed out. (connect timeout=%s)"</pre>
<pre class="line before"><span class="ws"> </span>% (self.host, self.timeout),</pre>
<pre class="line before"><span class="ws"> </span>)</pre>
<pre class="line before"><span class="ws"></span> </pre>
<pre class="line before"><span class="ws"> </span>except SocketError as e:</pre>
<pre class="line current"><span class="ws"> </span>raise NewConnectionError(</pre>
<pre class="line after"><span class="ws"> </span>self, "Failed to establish a new connection: %s" % e</pre>
<pre class="line after"><span class="ws"> </span>)</pre>
<pre class="line after"><span class="ws"></span> </pre>
<pre class="line after"><span class="ws"> </span>return conn</pre>
<pre class="line after"><span class="ws"></span> </pre></div>
</div>
<li><div class="exc-divider">During handling of the above exception, another exception occurred:</div>
<li><div class="frame" id="frame-139898074537456">
<h4>File <cite class="filename">"/opt/venv/lib/python3.8/site-packages/requests/adapters.py"</cite>,
line <em class="line">440</em>,
in <code class="function">send</code></h4>
<div class="source library"><pre class="line before"><span class="ws"> </span>else:</pre>
<pre class="line before"><span class="ws"> </span>timeout = TimeoutSauce(connect=timeout, read=timeout)</pre>
<pre class="line before"><span class="ws"></span> </pre>
<pre class="line before"><span class="ws"> </span>try:</pre>
<pre class="line before"><span class="ws"> </span>if not chunked:</pre>
<pre class="line current"><span class="ws"> </span>resp = conn.urlopen(</pre>
<pre class="line after"><span class="ws"> </span>method=request.method,</pre>
<pre class="line after"><span class="ws"> </span>url=url,</pre>
<pre class="line after"><span class="ws"> </span>body=request.body,</pre>
<pre class="line after"><span class="ws"> </span>headers=request.headers,</pre>
<pre class="line after"><span class="ws"> </span>redirect=False,</pre></div>
</div>
<li><div class="frame" id="frame-139898057338944">
<h4>File <cite class="filename">"/opt/venv/lib/python3.8/site-packages/urllib3/connectionpool.py"</cite>,
line <em class="line">785</em>,
in <code class="function">urlopen</code></h4>
<div class="source library"><pre class="line before"><span class="ws"> </span>elif isinstance(e, (SocketError, NewConnectionError)) and self.proxy:</pre>
<pre class="line before"><span class="ws"> </span>e = ProxyError("Cannot connect to proxy.", e)</pre>
<pre class="line before"><span class="ws"> </span>elif isinstance(e, (SocketError, HTTPException)):</pre>
<pre class="line before"><span class="ws"> </span>e = ProtocolError("Connection aborted.", e)</pre>
<pre class="line before"><span class="ws"></span> </pre>
<pre class="line current"><span class="ws"> </span>retries = retries.increment(</pre>
<pre class="line after"><span class="ws"> </span>method, url, error=e, _pool=self, _stacktrace=sys.exc_info()[2]</pre>
<pre class="line after"><span class="ws"> </span>)</pre>
<pre class="line after"><span class="ws"> </span>retries.sleep()</pre>
<pre class="line after"><span class="ws"></span> </pre>
<pre class="line after"><span class="ws"> </span># Keep track of the error for the retry warning.</pre></div>
</div>
<li><div class="frame" id="frame-139898057339136">
<h4>File <cite class="filename">"/opt/venv/lib/python3.8/site-packages/urllib3/util/retry.py"</cite>,
line <em class="line">592</em>,
in <code class="function">increment</code></h4>
<div class="source library"><pre class="line before"><span class="ws"> </span>other=other,</pre>
<pre class="line before"><span class="ws"> </span>history=history,</pre>
<pre class="line before"><span class="ws"> </span>)</pre>
<pre class="line before"><span class="ws"></span> </pre>
<pre class="line before"><span class="ws"> </span>if new_retry.is_exhausted():</pre>
<pre class="line current"><span class="ws"> </span>raise MaxRetryError(_pool, url, error or ResponseError(cause))</pre>
<pre class="line after"><span class="ws"></span> </pre>
<pre class="line after"><span class="ws"> </span>log.debug("Incremented Retry for (url='%s'): %r", url, new_retry)</pre>
<pre class="line after"><span class="ws"></span> </pre>
<pre class="line after"><span class="ws"> </span>return new_retry</pre>
<pre class="line after"><span class="ws"></span> </pre></div>
</div>
<li><div class="exc-divider">During handling of the above exception, another exception occurred:</div>
<li><div class="frame" id="frame-139898074535776">
<h4>File <cite class="filename">"/opt/venv/lib/python3.8/site-packages/flask/app.py"</cite>,
line <em class="line">2091</em>,
in <code class="function">__call__</code></h4>
<div class="source library"><pre class="line before"><span class="ws"> </span>def __call__(self, environ: dict, start_response: t.Callable) -> t.Any:</pre>
<pre class="line before"><span class="ws"> </span>"""The WSGI server calls the Flask application object as the</pre>
<pre class="line before"><span class="ws"> </span>WSGI application. This calls :meth:`wsgi_app`, which can be</pre>
<pre class="line before"><span class="ws"> </span>wrapped to apply middleware.</pre>
<pre class="line before"><span class="ws"> </span>"""</pre>
<pre class="line current"><span class="ws"> </span>return self.wsgi_app(environ, start_response)</pre></div>
</div>
<li><div class="frame" id="frame-139898074535872">
<h4>File <cite class="filename">"/opt/venv/lib/python3.8/site-packages/flask/app.py"</cite>,
line <em class="line">2076</em>,
in <code class="function">wsgi_app</code></h4>
<div class="source library"><pre class="line before"><span class="ws"> </span>try:</pre>
<pre class="line before"><span class="ws"> </span>ctx.push()</pre>
<pre class="line before"><span class="ws"> </span>response = self.full_dispatch_request()</pre>
<pre class="line before"><span class="ws"> </span>except Exception as e:</pre>
<pre class="line before"><span class="ws"> </span>error = e</pre>
<pre class="line current"><span class="ws"> </span>response = self.handle_exception(e)</pre>
<pre class="line after"><span class="ws"> </span>except: # noqa: B001</pre>
<pre class="line after"><span class="ws"> </span>error = sys.exc_info()[1]</pre>
<pre class="line after"><span class="ws"> </span>raise</pre>
<pre class="line after"><span class="ws"> </span>return response(environ, start_response)</pre>
<pre class="line after"><span class="ws"> </span>finally:</pre></div>
</div>
<li><div class="frame" id="frame-139898074537552">
<h4>File <cite class="filename">"/opt/venv/lib/python3.8/site-packages/flask/app.py"</cite>,
line <em class="line">2073</em>,
in <code class="function">wsgi_app</code></h4>
<div class="source library"><pre class="line before"><span class="ws"> </span>ctx = self.request_context(environ)</pre>
<pre class="line before"><span class="ws"> </span>error: t.Optional[BaseException] = None</pre>
<pre class="line before"><span class="ws"> </span>try:</pre>
<pre class="line before"><span class="ws"> </span>try:</pre>
<pre class="line before"><span class="ws"> </span>ctx.push()</pre>
<pre class="line current"><span class="ws"> </span>response = self.full_dispatch_request()</pre>
<pre class="line after"><span class="ws"> </span>except Exception as e:</pre>
<pre class="line after"><span class="ws"> </span>error = e</pre>
<pre class="line after"><span class="ws"> </span>response = self.handle_exception(e)</pre>
<pre class="line after"><span class="ws"> </span>except: # noqa: B001</pre>
<pre class="line after"><span class="ws"> </span>error = sys.exc_info()[1]</pre></div>
</div>
<li><div class="frame" id="frame-139898074537504">
<h4>File <cite class="filename">"/opt/venv/lib/python3.8/site-packages/flask/app.py"</cite>,
line <em class="line">1518</em>,
in <code class="function">full_dispatch_request</code></h4>
<div class="source library"><pre class="line before"><span class="ws"> </span>request_started.send(self)</pre>
<pre class="line before"><span class="ws"> </span>rv = self.preprocess_request()</pre>
<pre class="line before"><span class="ws"> </span>if rv is None:</pre>
<pre class="line before"><span class="ws"> </span>rv = self.dispatch_request()</pre>
<pre class="line before"><span class="ws"> </span>except Exception as e:</pre>
<pre class="line current"><span class="ws"> </span>rv = self.handle_user_exception(e)</pre>
<pre class="line after"><span class="ws"> </span>return self.finalize_request(rv)</pre>
<pre class="line after"><span class="ws"></span> </pre>
<pre class="line after"><span class="ws"> </span>def finalize_request(</pre>
<pre class="line after"><span class="ws"> </span>self,</pre>
<pre class="line after"><span class="ws"> </span>rv: t.Union[ResponseReturnValue, HTTPException],</pre></div>
</div>
<li><div class="frame" id="frame-139898074535296">
<h4>File <cite class="filename">"/opt/venv/lib/python3.8/site-packages/flask/app.py"</cite>,
line <em class="line">1516</em>,
in <code class="function">full_dispatch_request</code></h4>
<div class="source library"><pre class="line before"><span class="ws"> </span>self.try_trigger_before_first_request_functions()</pre>
<pre class="line before"><span class="ws"> </span>try:</pre>
<pre class="line before"><span class="ws"> </span>request_started.send(self)</pre>
<pre class="line before"><span class="ws"> </span>rv = self.preprocess_request()</pre>
<pre class="line before"><span class="ws"> </span>if rv is None:</pre>
<pre class="line current"><span class="ws"> </span>rv = self.dispatch_request()</pre>
<pre class="line after"><span class="ws"> </span>except Exception as e:</pre>
<pre class="line after"><span class="ws"> </span>rv = self.handle_user_exception(e)</pre>
<pre class="line after"><span class="ws"> </span>return self.finalize_request(rv)</pre>
<pre class="line after"><span class="ws"></span> </pre>
<pre class="line after"><span class="ws"> </span>def finalize_request(</pre></div>
</div>
<li><div class="frame" id="frame-139898074537408">
<h4>File <cite class="filename">"/opt/venv/lib/python3.8/site-packages/flask/app.py"</cite>,
line <em class="line">1502</em>,
in <code class="function">dispatch_request</code></h4>
<div class="source library"><pre class="line before"><span class="ws"> </span>getattr(rule, "provide_automatic_options", False)</pre>
<pre class="line before"><span class="ws"> </span>and req.method == "OPTIONS"</pre>
<pre class="line before"><span class="ws"> </span>):</pre>
<pre class="line before"><span class="ws"> </span>return self.make_default_options_response()</pre>
<pre class="line before"><span class="ws"> </span># otherwise dispatch to the handler for that endpoint</pre>
<pre class="line current"><span class="ws"> </span>return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)</pre>
<pre class="line after"><span class="ws"></span> </pre>
<pre class="line after"><span class="ws"> </span>def full_dispatch_request(self) -> Response:</pre>
<pre class="line after"><span class="ws"> </span>"""Dispatches the request and on top of that performs request</pre>
<pre class="line after"><span class="ws"> </span>pre and postprocessing as well as HTTP exception catching and</pre>
<pre class="line after"><span class="ws"> </span>error handling.</pre></div>
</div>
<li><div class="frame" id="frame-139898074537600">
<h4>File <cite class="filename">"/app.py"</cite>,
line <em class="line">86</em>,
in <code class="function">get_peers</code></h4>
<div class="source "><pre class="line before"><span class="ws"></span> </pre>
<pre class="line before"><span class="ws"></span> </pre>
<pre class="line before"><span class="ws"></span>@app.route('/getPeers', methods=['GET'])</pre>
<pre class="line before"><span class="ws"></span>def get_peers():</pre>
<pre class="line before"><span class="ws"> </span>app.logger.info("Getting peers")</pre>
<pre class="line current"><span class="ws"> </span>return jsonpickle.encode(blockchain.obtain_peer_node()), 200</pre>
<pre class="line after"><span class="ws"></span> </pre>
<pre class="line after"><span class="ws"></span>@app.route('/getBalance', methods=['GET'])</pre>
<pre class="line after"><span class="ws"></span>def get_balance():</pre>
<pre class="line after"><span class="ws"> </span>address = request.args.get('address')</pre>
<pre class="line after"><span class="ws"> </span>balance = blockchain.get_balance(address)</pre></div>
</div>
<li><div class="frame" id="frame-139898074535824">
<h4>File <cite class="filename">"/blockchain/blockchain_data_structure.py"</cite>,
line <em class="line">264</em>,
in <code class="function">obtain_peer_node</code></h4>
<div class="source "><pre class="line before"><span class="ws"> </span>self.peer_nodes.add(address)</pre>
<pre class="line before"><span class="ws"></span> </pre>
<pre class="line before"><span class="ws"> </span>def obtain_peer_node(self):</pre>
<pre class="line before"><span class="ws"> </span>if self.address != self.discovery_node_address:</pre>
<pre class="line before"><span class="ws"> </span>self.peer_nodes.add(self.discovery_node_address) # Assuming it never crashes</pre>
<pre class="line current"><span class="ws"> </span>response = requests.post('http://{}/register/node'.format(self.discovery_node_address),</pre>
<pre class="line after"><span class="ws"> </span>json={'node_address': '{}'.format(self.address)}).json()</pre>
<pre class="line after"><span class="ws"></span> </pre>
<pre class="line after"><span class="ws"> </span>for address in response['total_nodes']:</pre>
<pre class="line after"><span class="ws"> </span># Add and register all peers</pre>
<pre class="line after"><span class="ws"> </span>try:</pre></div>
</div>
<li><div class="frame" id="frame-139898074537648">
<h4>File <cite class="filename">"/opt/venv/lib/python3.8/site-packages/requests/api.py"</cite>,
line <em class="line">117</em>,
in <code class="function">post</code></h4>
<div class="source library"><pre class="line before"><span class="ws"> </span>:param \*\*kwargs: Optional arguments that ``request`` takes.</pre>
<pre class="line before"><span class="ws"> </span>:return: :class:`Response <Response>` object</pre>
<pre class="line before"><span class="ws"> </span>:rtype: requests.Response</pre>
<pre class="line before"><span class="ws"> </span>"""</pre>
<pre class="line before"><span class="ws"></span> </pre>
<pre class="line current"><span class="ws"> </span>return request('post', url, data=data, json=json, **kwargs)</pre>
<pre class="line after"><span class="ws"></span> </pre>
<pre class="line after"><span class="ws"></span> </pre>
<pre class="line after"><span class="ws"></span>def put(url, data=None, **kwargs):</pre>
<pre class="line after"><span class="ws"> </span>r"""Sends a PUT request.</pre>
<pre class="line after"><span class="ws"></span> </pre></div>
</div>
<li><div class="frame" id="frame-139898074537744">
<h4>File <cite class="filename">"/opt/venv/lib/python3.8/site-packages/requests/api.py"</cite>,
line <em class="line">61</em>,
in <code class="function">request</code></h4>
<div class="source library"><pre class="line before"><span class="ws"></span> </pre>
<pre class="line before"><span class="ws"> </span># By using the 'with' statement we are sure the session is closed, thus we</pre>
<pre class="line before"><span class="ws"> </span># avoid leaving sockets open which can trigger a ResourceWarning in some</pre>
<pre class="line before"><span class="ws"> </span># cases, and look like a memory leak in others.</pre>
<pre class="line before"><span class="ws"> </span>with sessions.Session() as session:</pre>
<pre class="line current"><span class="ws"> </span>return session.request(method=method, url=url, **kwargs)</pre>
<pre class="line after"><span class="ws"></span> </pre>
<pre class="line after"><span class="ws"></span> </pre>
<pre class="line after"><span class="ws"></span>def get(url, params=None, **kwargs):</pre>
<pre class="line after"><span class="ws"> </span>r"""Sends a GET request.</pre>
<pre class="line after"><span class="ws"></span> </pre></div>
</div>
<li><div class="frame" id="frame-139898074537792">
<h4>File <cite class="filename">"/opt/venv/lib/python3.8/site-packages/requests/sessions.py"</cite>,
line <em class="line">529</em>,
in <code class="function">request</code></h4>
<div class="source library"><pre class="line before"><span class="ws"> </span>send_kwargs = {</pre>
<pre class="line before"><span class="ws"> </span>'timeout': timeout,</pre>
<pre class="line before"><span class="ws"> </span>'allow_redirects': allow_redirects,</pre>
<pre class="line before"><span class="ws"> </span>}</pre>
<pre class="line before"><span class="ws"> </span>send_kwargs.update(settings)</pre>
<pre class="line current"><span class="ws"> </span>resp = self.send(prep, **send_kwargs)</pre>
<pre class="line after"><span class="ws"></span> </pre>
<pre class="line after"><span class="ws"> </span>return resp</pre>
<pre class="line after"><span class="ws"></span> </pre>
<pre class="line after"><span class="ws"> </span>def get(self, url, **kwargs):</pre>
<pre class="line after"><span class="ws"> </span>r"""Sends a GET request. Returns :class:`Response` object.</pre></div>
</div>
<li><div class="frame" id="frame-139898074537936">
<h4>File <cite class="filename">"/opt/venv/lib/python3.8/site-packages/requests/sessions.py"</cite>,
line <em class="line">645</em>,
in <code class="function">send</code></h4>
<div class="source library"><pre class="line before"><span class="ws"></span> </pre>
<pre class="line before"><span class="ws"> </span># Start time (approximately) of the request</pre>
<pre class="line before"><span class="ws"> </span>start = preferred_clock()</pre>
<pre class="line before"><span class="ws"></span> </pre>
<pre class="line before"><span class="ws"> </span># Send the request</pre>
<pre class="line current"><span class="ws"> </span>r = adapter.send(request, **kwargs)</pre>
<pre class="line after"><span class="ws"></span> </pre>
<pre class="line after"><span class="ws"> </span># Total elapsed time of the request (approximately)</pre>
<pre class="line after"><span class="ws"> </span>elapsed = preferred_clock() - start</pre>
<pre class="line after"><span class="ws"> </span>r.elapsed = timedelta(seconds=elapsed)</pre>
<pre class="line after"><span class="ws"></span> </pre></div>
</div>
<li><div class="frame" id="frame-139898074537840">
<h4>File <cite class="filename">"/opt/venv/lib/python3.8/site-packages/requests/adapters.py"</cite>,
line <em class="line">519</em>,
in <code class="function">send</code></h4>
<div class="source library"><pre class="line before"><span class="ws"></span> </pre>
<pre class="line before"><span class="ws"> </span>if isinstance(e.reason, _SSLError):</pre>
<pre class="line before"><span class="ws"> </span># This branch is for urllib3 v1.22 and later.</pre>
<pre class="line before"><span class="ws"> </span>raise SSLError(e, request=request)</pre>
<pre class="line before"><span class="ws"></span> </pre>
<pre class="line current"><span class="ws"> </span>raise ConnectionError(e, request=request)</pre>
<pre class="line after"><span class="ws"></span> </pre>
<pre class="line after"><span class="ws"> </span>except ClosedPoolError as e:</pre>
<pre class="line after"><span class="ws"> </span>raise ConnectionError(e, request=request)</pre>
<pre class="line after"><span class="ws"></span> </pre>
<pre class="line after"><span class="ws"> </span>except _ProxyError as e:</pre></div>
</div>
</ul>
<blockquote>requests.exceptions.ConnectionError: HTTPConnectionPool(host='0.0.0.0', port=5000): Max retries exceeded with url: /register/node (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f3c8f099b20>: Failed to establish a new connection: [Errno 111] Connection refused'))</blockquote>
</div>
<div class="plain">
<p>
This is the Copy/Paste friendly version of the traceback.
</p>
<textarea cols="50" rows="10" name="code" readonly>Traceback (most recent call last):
File "/opt/venv/lib/python3.8/site-packages/urllib3/connection.py", line 174, in _new_conn
conn = connection.create_connection(
File "/opt/venv/lib/python3.8/site-packages/urllib3/util/connection.py", line 95, in create_connection
raise err
File "/opt/venv/lib/python3.8/site-packages/urllib3/util/connection.py", line 85, in create_connection
sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/opt/venv/lib/python3.8/site-packages/urllib3/connectionpool.py", line 703, in urlopen
httplib_response = self._make_request(
File "/opt/venv/lib/python3.8/site-packages/urllib3/connectionpool.py", line 398, in _make_request
conn.request(method, url, **httplib_request_kw)
File "/opt/venv/lib/python3.8/site-packages/urllib3/connection.py", line 239, in request
super(HTTPConnection, self).request(method, url, body=body, headers=headers)
File "/usr/local/lib/python3.8/http/client.py", line 1255, in request
self._send_request(method, url, body, headers, encode_chunked)
File "/usr/local/lib/python3.8/http/client.py", line 1301, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "/usr/local/lib/python3.8/http/client.py", line 1250, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "/usr/local/lib/python3.8/http/client.py", line 1010, in _send_output
self.send(msg)
File "/usr/local/lib/python3.8/http/client.py", line 950, in send
self.connect()
File "/opt/venv/lib/python3.8/site-packages/urllib3/connection.py", line 205, in connect
conn = self._new_conn()
File "/opt/venv/lib/python3.8/site-packages/urllib3/connection.py", line 186, in _new_conn
raise NewConnectionError(
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPConnection object at 0x7f3c8f099b20>: Failed to establish a new connection: [Errno 111] Connection refused
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/opt/venv/lib/python3.8/site-packages/requests/adapters.py", line 440, in send
resp = conn.urlopen(
File "/opt/venv/lib/python3.8/site-packages/urllib3/connectionpool.py", line 785, in urlopen
retries = retries.increment(
File "/opt/venv/lib/python3.8/site-packages/urllib3/util/retry.py", line 592, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='0.0.0.0', port=5000): Max retries exceeded with url: /register/node (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f3c8f099b20>: Failed to establish a new connection: [Errno 111] Connection refused'))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/opt/venv/lib/python3.8/site-packages/flask/app.py", line 2091, in __call__
return self.wsgi_app(environ, start_response)
File "/opt/venv/lib/python3.8/site-packages/flask/app.py", line 2076, in wsgi_app
response = self.handle_exception(e)
File "/opt/venv/lib/python3.8/site-packages/flask/app.py", line 2073, in wsgi_app
response = self.full_dispatch_request()
File "/opt/venv/lib/python3.8/site-packages/flask/app.py", line 1518, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/opt/venv/lib/python3.8/site-packages/flask/app.py", line 1516, in full_dispatch_request
rv = self.dispatch_request()
File "/opt/venv/lib/python3.8/site-packages/flask/app.py", line 1502, in dispatch_request
return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)
File "/app.py", line 86, in get_peers
return jsonpickle.encode(blockchain.obtain_peer_node()), 200
File "/blockchain/blockchain_data_structure.py", line 264, in obtain_peer_node
response = requests.post('http://{}/register/node'.format(self.discovery_node_address),
File "/opt/venv/lib/python3.8/site-packages/requests/api.py", line 117, in post
return request('post', url, data=data, json=json, **kwargs)
File "/opt/venv/lib/python3.8/site-packages/requests/api.py", line 61, in request
return session.request(method=method, url=url, **kwargs)
File "/opt/venv/lib/python3.8/site-packages/requests/sessions.py", line 529, in request
resp = self.send(prep, **send_kwargs)
File "/opt/venv/lib/python3.8/site-packages/requests/sessions.py", line 645, in send
r = adapter.send(request, **kwargs)
File "/opt/venv/lib/python3.8/site-packages/requests/adapters.py", line 519, in send
raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPConnectionPool(host='0.0.0.0', port=5000): Max retries exceeded with url: /register/node (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f3c8f099b20>: Failed to establish a new connection: [Errno 111] Connection refused'))</textarea>
</div>
<div class="explanation">
The debugger caught an exception in your WSGI application. You can now
look at the traceback which led to the error. <span class="nojavascript">
If you enable JavaScript you can also use additional features such as code
execution (if the evalex feature is enabled), automatic pasting of the
exceptions and much more.</span>
</div>
<div class="footer">
Brought to you by <strong class="arthur">DON'T PANIC</strong>, your
friendly Werkzeug powered traceback interpreter.
</div>
</div>
<div class="pin-prompt">
<div class="inner">
<h3>Console Locked</h3>
<p>
The console is locked and needs to be unlocked by entering the PIN.
You can find the PIN printed out on the standard output of your
shell that runs the server.
<form>
<p>PIN:
<input type=text name=pin size=14>
<input type=submit name=btn value="Confirm Pin">
</form>
</div>
</div>
</body>
</html>
<!--
Traceback (most recent call last):
File "/opt/venv/lib/python3.8/site-packages/urllib3/connection.py", line 174, in _new_conn
conn = connection.create_connection(
File "/opt/venv/lib/python3.8/site-packages/urllib3/util/connection.py", line 95, in create_connection
raise err
File "/opt/venv/lib/python3.8/site-packages/urllib3/util/connection.py", line 85, in create_connection
sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/opt/venv/lib/python3.8/site-packages/urllib3/connectionpool.py", line 703, in urlopen
httplib_response = self._make_request(
File "/opt/venv/lib/python3.8/site-packages/urllib3/connectionpool.py", line 398, in _make_request
conn.request(method, url, **httplib_request_kw)
File "/opt/venv/lib/python3.8/site-packages/urllib3/connection.py", line 239, in request
super(HTTPConnection, self).request(method, url, body=body, headers=headers)
File "/usr/local/lib/python3.8/http/client.py", line 1255, in request
self._send_request(method, url, body, headers, encode_chunked)
File "/usr/local/lib/python3.8/http/client.py", line 1301, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "/usr/local/lib/python3.8/http/client.py", line 1250, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "/usr/local/lib/python3.8/http/client.py", line 1010, in _send_output
self.send(msg)
File "/usr/local/lib/python3.8/http/client.py", line 950, in send
self.connect()
File "/opt/venv/lib/python3.8/site-packages/urllib3/connection.py", line 205, in connect
conn = self._new_conn()
File "/opt/venv/lib/python3.8/site-packages/urllib3/connection.py", line 186, in _new_conn
raise NewConnectionError(
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPConnection object at 0x7f3c8f099b20>: Failed to establish a new connection: [Errno 111] Connection refused
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/opt/venv/lib/python3.8/site-packages/requests/adapters.py", line 440, in send
resp = conn.urlopen(
File "/opt/venv/lib/python3.8/site-packages/urllib3/connectionpool.py", line 785, in urlopen
retries = retries.increment(
File "/opt/venv/lib/python3.8/site-packages/urllib3/util/retry.py", line 592, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='0.0.0.0', port=5000): Max retries exceeded with url: /register/node (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f3c8f099b20>: Failed to establish a new connection: [Errno 111] Connection refused'))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/opt/venv/lib/python3.8/site-packages/flask/app.py", line 2091, in __call__
return self.wsgi_app(environ, start_response)
File "/opt/venv/lib/python3.8/site-packages/flask/app.py", line 2076, in wsgi_app
response = self.handle_exception(e)
File "/opt/venv/lib/python3.8/site-packages/flask/app.py", line 2073, in wsgi_app
response = self.full_dispatch_request()
File "/opt/venv/lib/python3.8/site-packages/flask/app.py", line 1518, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/opt/venv/lib/python3.8/site-packages/flask/app.py", line 1516, in full_dispatch_request
rv = self.dispatch_request()
File "/opt/venv/lib/python3.8/site-packages/flask/app.py", line 1502, in dispatch_request
return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)
File "/app.py", line 86, in get_peers
return jsonpickle.encode(blockchain.obtain_peer_node()), 200
File "/blockchain/blockchain_data_structure.py", line 264, in obtain_peer_node
response = requests.post('http://{}/register/node'.format(self.discovery_node_address),
File "/opt/venv/lib/python3.8/site-packages/requests/api.py", line 117, in post
return request('post', url, data=data, json=json, **kwargs)
File "/opt/venv/lib/python3.8/site-packages/requests/api.py", line 61, in request
return session.request(method=method, url=url, **kwargs)
File "/opt/venv/lib/python3.8/site-packages/requests/sessions.py", line 529, in request
resp = self.send(prep, **send_kwargs)
File "/opt/venv/lib/python3.8/site-packages/requests/sessions.py", line 645, in send
r = adapter.send(request, **kwargs)
File "/opt/venv/lib/python3.8/site-packages/requests/adapters.py", line 519, in send
raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPConnectionPool(host='0.0.0.0', port=5000): Max retries exceeded with url: /register/node (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f3c8f099b20>: Failed to establish a new connection: [Errno 111] Connection refused'))
-->
Seems like for the version of docker I am running the address 0.0.0.0:5001 cannot invoke the register node method at 0.0.0.0:5000. Do I need to setup a network specification with a docker compose file to allow this to happen?