algorand / auction-demo

An example smart contract NFT auction on Algorand
57 stars 51 forks source link

Connection refused when running example.py, tests #5

Closed stefanlenoach closed 2 years ago

stefanlenoach commented 2 years ago

Hello! Trying to follow the example project here: https://developer.algorand.org/docs/get-started/dapps/pyteal/

When I ran example.py (and pytest) I got the following issue. Any idea what might be happening? Thanks!


Traceback (most recent call last):
  File "/Users//opt/anaconda3/envs/algo/lib/python3.9/urllib/request.py", line 1346, in do_open
    h.request(req.get_method(), req.selector, req.data, headers,
  File "/Users//opt/anaconda3/envs/algo/lib/python3.9/http/client.py", line 1279, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/Users//opt/anaconda3/envs/algo/lib/python3.9/http/client.py", line 1325, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/Users//opt/anaconda3/envs/algo/lib/python3.9/http/client.py", line 1274, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/Users//opt/anaconda3/envs/algo/lib/python3.9/http/client.py", line 1034, in _send_output
    self.send(msg)
  File "/Users//opt/anaconda3/envs/algo/lib/python3.9/http/client.py", line 974, in send
    self.connect()
  File "/Users//opt/anaconda3/envs/algo/lib/python3.9/http/client.py", line 945, in connect
    self.sock = self._create_connection(
  File "/Users//opt/anaconda3/envs/algo/lib/python3.9/socket.py", line 844, in create_connection
    raise err
  File "/Users//opt/anaconda3/envs/algo/lib/python3.9/socket.py", line 832, in create_connection
    sock.connect(sa)
ConnectionRefusedError: [Errno 61] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users//Programming/algo/auction-demo/example.py", line 108, in <module>
    simple_auction()
  File "/Users//Programming/algo/auction-demo/example.py", line 23, in simple_auction
    creator = getTemporaryAccount(client)
  File "/Users//Programming/algo/auction-demo/auction/testing/resources.py", line 48, in getTemporaryAccount
    genesisAccounts = getGenesisAccounts()
  File "/Users//Programming/algo/auction-demo/auction/testing/setup.py", line 36, in getGenesisAccounts
    wallets = kmd.list_wallets()
  File "/Users//opt/anaconda3/envs/algo/lib/python3.9/site-packages/algosdk/kmd.py", line 88, in list_wallets
    res = self.kmd_request("GET", req)
  File "/Users//opt/anaconda3/envs/algo/lib/python3.9/site-packages/algosdk/kmd.py", line 61, in kmd_request
    resp = urlopen(req)
  File "/Users//opt/anaconda3/envs/algo/lib/python3.9/urllib/request.py", line 214, in urlopen
    return opener.open(url, data, timeout)
  File "/Users//opt/anaconda3/envs/algo/lib/python3.9/urllib/request.py", line 517, in open
    response = self._open(req, data)
  File "/Users//opt/anaconda3/envs/algo/lib/python3.9/urllib/request.py", line 534, in _open
    result = self._call_chain(self.handle_open, protocol, protocol +
  File "/Users//opt/anaconda3/envs/algo/lib/python3.9/urllib/request.py", line 494, in _call_chain
    result = func(*args)
  File "/Users/opt/anaconda3/envs/algo/lib/python3.9/urllib/request.py", line 1375, in http_open
    return self.do_open(http.client.HTTPConnection, req)
  File "/Users//opt/anaconda3/envs/algo/lib/python3.9/urllib/request.py", line 1349, in do_open
    raise URLError(err)
urllib.error.URLError: <urlopen error [Errno 61] Connection refused>
phoenix0508 commented 2 years ago

has same issue.

phoenix0508 commented 2 years ago

self = <urllib.request.HTTPHandler object at 0x10bdf22c0> http_class = <class 'http.client.HTTPConnection'> req = <urllib.request.Request object at 0x10be4ce50>, http_conn_args = {} host = 'localhost:4002', h = <http.client.HTTPConnection object at 0x10be4c0d0>

def do_open(self, http_class, req, **http_conn_args):
    """Return an HTTPResponse object for the request, using http_class.

    http_class must implement the HTTPConnection API from http.client.
    """
    host = req.host
    if not host:
        raise URLError('no host given')

    # will parse host:port
    h = http_class(host, timeout=req.timeout, **http_conn_args)
    h.set_debuglevel(self._debuglevel)

    headers = dict(req.unredirected_hdrs)
    headers.update({k: v for k, v in req.headers.items()
                    if k not in headers})

    # TODO(jhylton): Should this be redesigned to handle
    # persistent connections?

    # We want to make an HTTP/1.1 request, but the addinfourl
    # class isn't prepared to deal with a persistent connection.
    # It will try to read all remaining data from the socket,
    # which will block while the server waits for the next request.
    # So make sure the connection gets closed after the (only)
    # request.
    headers["Connection"] = "close"
    headers = {name.title(): val for name, val in headers.items()}

    if req._tunnel_host:
        tunnel_headers = {}
        proxy_auth_hdr = "Proxy-Authorization"
        if proxy_auth_hdr in headers:
            tunnel_headers[proxy_auth_hdr] = headers[proxy_auth_hdr]
            # Proxy-Authorization should not be sent to origin
            # server.
            del headers[proxy_auth_hdr]
        h.set_tunnel(req._tunnel_host, headers=tunnel_headers)

    try:
        try:
            h.request(req.get_method(), req.selector, req.data, headers,
                      encode_chunked=req.has_header('Transfer-encoding'))
        except OSError as err: # timeout error
          raise URLError(err)

E urllib.error.URLError: <urlopen error [Errno 61] Connection refused>

/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/urllib/request.py:1351: URLError =========================== short test summary info ============================ FAILED auction/operations_test.py::test_create - urllib.error.URLError: <urlo... FAILED auction/operations_test.py::test_setup - urllib.error.URLError: <urlop... FAILED auction/operations_test.py::test_first_bid_before_start - urllib.error... FAILED auction/operations_test.py::test_first_bid - urllib.error.URLError: <u... FAILED auction/operations_test.py::test_second_bid - urllib.error.URLError: <... FAILED auction/operations_test.py::test_close_before_start - urllib.error.URL... FAILED auction/operations_test.py::test_close_no_bids - urllib.error.URLError... FAILED auction/operations_test.py::test_close_reserve_not_met - urllib.error.... FAILED auction/operations_test.py::test_close_reserve_met - urllib.error.URLE... FAILED auction/testing/setup_test.py::test_getAlgodClient - urllib.error.URLE... FAILED auction/testing/setup_test.py::test_getKmdClient - urllib.error.URLErr... FAILED auction/testing/setup_test.py::test_getGenesisAccounts - urllib.error....

fabrice102 commented 2 years ago

Also on forum: https://forum.algorand.org/t/urllib-error-urlerror-urlopen-error-errno-61-connection-refused/5236/3

Is sandbox running as specified in https://developer.algorand.org/docs/get-started/dapps/pyteal/#install-sandbox?

If yes, can you show the output of ./sandbox up?

phoenix0508 commented 2 years ago

see sandbox.log for detailed progress, or use -v.

phoenix0508 commented 2 years ago

Screen Shot 2021-11-29 at 9 02 43 PM

phoenix0508 commented 2 years ago

image

phoenix0508 commented 2 years ago

I guess there is no kmd server in docker image.

fabrice102 commented 2 years ago

It looks like your sandbox did not start properly. You can see that because it does not display the algod version at the end. You can also look at sandbox.log and see the error at the end.

Most likely you are not using the latest version of sandbox.

Please try in the sandbox folder:

git pull

and then

./sandbox clean
./sandbox up nightly -v

If this does not work, please provide the content of sandbox.log and of the above commands.

KrSuma commented 2 years ago

just wanted to say thank you, I had a similar error for hours on m1 macOS and this solved my issue.