Connection refused on python

Hey, :wave: I’m new here… I entered this competition; using the python bot; I’ve followed all the setup steps… though when I try to run ‘python3 StartBot.py’; I get a connection refused error on … I tried allowing port 5000, by either adding a firewall rule, or just disable my firewall, on had on luck, so I came here seeking some solution(s), to this error, thats caused by StarterBot.py line 63… hub_connection.start()

unfortunately, this error prevents to get started, I’ve checked the net, and pypy for a solve to no avail … please look into this.

I’ve attempted to run the StarterBot.py on 2 Linux distributions; Ubuntu Mate for raspberry-pi 3 and on ElementaryOs 18.04… and both distros have the same issues mentioned on the above post. Which signalrcore module version must be installed to make to run? be default I’m given signalrcore that doesn’t specify the version number on requirements.txt file

Hi @sir.afrika, great to see you here! Good luck with the competition this year!

That “Connection refused” you are seeing - it means your bot cannot see the runner.

When you are running your bot, are you also already running the engine and runne somewhere?

You should have a terminal open, repeatedly printing “Waiting for all bots to connect”. Are you seeing that?

I’m not seeing the “Waiting for all bots to connect” message on the terminal, I initially see the

http://localhost:5000/runnerhub

then it crashes with the message -> “connection refused error 111” on line 63

I’ve committed, can please look into it on github

This maybe the issue…

check the known issues section

So we can’t actually see into your private repository, so unfortunately I won’t be able to take a look for you.

However, can you please try navigating to “http://localhost:5000/runnerhub” before starting your bot, in your browser?

You should see one line of text saying “Connection ID required”. Do you see this?

Hello, I am also having the same problem but with Javascript (when running ‘node javascript_StarterBot.js’ in the terminal).

I get the error message “Error: Failed to complete negotiation with the server: FetchError: request to http://localhost:5000/runnerhub/negotiate?negotiateVersion=1 failed, reason: connect ECONNREFUSED 127.0.0.1:5000

Disconnected”

When I navigate to http://localhost:5000/runnerhub on the address bar, I get the message “localhost refused to connect.”

What am I doing wrong?

Hi @itumel,

Could you please try https instead of http as I’ve seen this negotiation issue come up with the different protocols, also how are you starting the runner?

Please let us know if there are any further questions on this.

Hi @ibvs,

My apologies. It seems I am struggling to find the instructions on how to run the project properly.

I am not finding the runner.

I tried ‘node client.js’ under my /starter-pack/runner-publish/wwwroot/js, nothing happened. So I am assuming this is not the runner.

So how do I go about running the runner?

Also https doesn’t seem to make a difference over http.

No worries @itumel :slight_smile: ,

Please ensure you have the latest starter pack and follow the readme docs (You can start with the main readme file in the base folder and work your way through each component), please let us know if something needs to be clarified.

Thank you for your help.

I noticed that there are two zip files in the 2021-Galaxio github repo.

I downloaded starter-pack.zip and had trouble getting started.

I went back to download Source Code (zip).

I should have started with the README.md’s there instead. They explained everything (like how to get started, etc.) and better at that.

So now I am just waiting to install and run .NET Core SignalR Hub.

Will update as I go along.

It’s a pleasure @itumel,

Please feel free to reach out if anything is unclear.

Hi, i also have the same problem. I have tried disabling the firewall, running the docker image, using the exact python version specified. I get a connection error on the python StarterBot.py script. when i run it, i get “http://localhost:5000/runnerhub” for about 5 seconds and then i get an error

C:\Users\Rohan\Documents\ec-bot-2021>python38 StarterBot.py
http://localhost:5000/runnerhub`
Traceback (most recent call last):
  File "C:\Users\Rohan\AppData\Local\Programs\Python\Python38\lib\site-packages\urllib3\connection.py", line 169, in _new_conn
    conn = connection.create_connection(
  File "C:\Users\Rohan\AppData\Local\Programs\Python\Python38\lib\site-packages\urllib3\util\connection.py", line 96, in create_connection
    raise err
  File "C:\Users\Rohan\AppData\Local\Programs\Python\Python38\lib\site-packages\urllib3\util\connection.py", line 86, in create_connection
    sock.connect(sa)
ConnectionRefusedError: [WinError 10061] No connection could be made because the target machine actively refused it

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\Rohan\AppData\Local\Programs\Python\Python38\lib\site-packages\urllib3\connectionpool.py", line 699, in urlopen
    httplib_response = self._make_request(
  File "C:\Users\Rohan\AppData\Local\Programs\Python\Python38\lib\site-packages\urllib3\connectionpool.py", line 394, in _make_request
    conn.request(method, url, **httplib_request_kw)
  File "C:\Users\Rohan\AppData\Local\Programs\Python\Python38\lib\site-packages\urllib3\connection.py", line 234, in request
    super(HTTPConnection, self).request(method, url, body=body, headers=headers)
  File "C:\Users\Rohan\AppData\Local\Programs\Python\Python38\lib\http\client.py", line 1255, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "C:\Users\Rohan\AppData\Local\Programs\Python\Python38\lib\http\client.py", line 1301, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "C:\Users\Rohan\AppData\Local\Programs\Python\Python38\lib\http\client.py", line 1250, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "C:\Users\Rohan\AppData\Local\Programs\Python\Python38\lib\http\client.py", line 1010, in _send_output
    self.send(msg)
  File "C:\Users\Rohan\AppData\Local\Programs\Python\Python38\lib\http\client.py", line 950, in send
    self.connect()
  File "C:\Users\Rohan\AppData\Local\Programs\Python\Python38\lib\site-packages\urllib3\connection.py", line 200, in connect
    conn = self._new_conn()
  File "C:\Users\Rohan\AppData\Local\Programs\Python\Python38\lib\site-packages\urllib3\connection.py", line 181, in _new_conn
    raise NewConnectionError(
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPConnection object at 0x00000272CBCE2100>: Failed to establish a new connection: [WinError 10061] No connection could be made because the target machine actively refused it

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\Rohan\AppData\Local\Programs\Python\Python38\lib\site-packages\requests\adapters.py", line 439, in send
    resp = conn.urlopen(
  File "C:\Users\Rohan\AppData\Local\Programs\Python\Python38\lib\site-packages\urllib3\connectionpool.py", line 755, in urlopen
    retries = retries.increment(
  File "C:\Users\Rohan\AppData\Local\Programs\Python\Python38\lib\site-packages\urllib3\util\retry.py", line 574, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='localhost', port=5000): Max retries exceeded with url: /runnerhub/negotiate (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x00000272CBCE2100>: Failed to establish a new connection: [WinError 10061] No connection could be made because the target machine actively refused it'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "StarterBot.py", line 91, in <module>
    run_bot()
  File "StarterBot.py", line 65, in run_bot
    hub_connection.start()
  File "C:\Users\Rohan\AppData\Local\Programs\Python\Python38\lib\site-packages\signalrcore\hub\base_hub_connection.py", line 44, in start
    return self.transport.start()
  File "C:\Users\Rohan\AppData\Local\Programs\Python\Python38\lib\site-packages\signalrcore\transport\websockets\websocket_transport.py", line 62, in start
    self.negotiate()
  File "C:\Users\Rohan\AppData\Local\Programs\Python\Python38\lib\site-packages\signalrcore\transport\websockets\websocket_transport.py", line 93, in negotiate
    response = requests.post(
  File "C:\Users\Rohan\AppData\Local\Programs\Python\Python38\lib\site-packages\requests\api.py", line 119, in post
    return request('post', url, data=data, json=json, **kwargs)
  File "C:\Users\Rohan\AppData\Local\Programs\Python\Python38\lib\site-packages\requests\api.py", line 61, in request
    return session.request(method=method, url=url, **kwargs)
  File "C:\Users\Rohan\AppData\Local\Programs\Python\Python38\lib\site-packages\requests\sessions.py", line 542, in request
    resp = self.send(prep, **send_kwargs)
  File "C:\Users\Rohan\AppData\Local\Programs\Python\Python38\lib\site-packages\requests\sessions.py", line 655, in send
    r = adapter.send(request, **kwargs)
  File "C:\Users\Rohan\AppData\Local\Programs\Python\Python38\lib\site-packages\requests\adapters.py", line 516, in send
    raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPConnectionPool(host='localhost', port=5000): Max retries exceeded with url: /runnerhub/negotiate (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x00000272CBCE2100>: Failed to establish a new connection: [WinError 10061] No connection could be made because the target machine actively refused it'))

Hi @rohanday4 , thank you for reaching out and welcome to the Entelect Challenge.

Are you able to view the runner by just hitting that link in the browser? Also to check if this is not a connection issue to the docker container, please try to run everything in the same environment and make sure that the runner related config for all of the components are aligned.

Please let us know if this helped to identify the issue or if you require further assistance.

I tried the programs on my thin and light and it worked. It is definitely the run.sh that isnt working correctly on my main pc. I will try to reinstall all of the dotnet SDK stuffs and try again

Hi @rohanday4 , please let us know if you still have trouble with the connection after reinstalling.