mpcabete / bombcrypto-bot

This is a python bot that automatically logs in, clicks the new button, and sends heroes to work in the bombcrypto game. It is fully open source and free.
819 stars 536 forks source link

Problemas ao rodar o bot na VM Linux ubuntu 20.01(Google Cloud) #655

Closed martinsssgabriel closed 2 years ago

martinsssgabriel commented 2 years ago

Depois de instalar o Python e tentar rodar com o comando python3 index.py, ele me retorna o seguinte erro:

Traceback (most recent call last): File "/home/ubuntu/.local/lib/python3.8/site-packages/Xlib/support/unix_connect.py", line 119, in get_socket s = _get_unix_socket(address) File "/home/ubuntu/.local/lib/python3.8/site-packages/Xlib/support/unix_connect.py", line 98, in _get_unix_socket s.connect(address) ConnectionRefusedError: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/home/ubuntu/.local/lib/python3.8/site-packages/Xlib/support/unix_connect.py", line 123, in get_socket s = _get_tcp_socket(host, dno) File "/home/ubuntu/.local/lib/python3.8/site-packages/Xlib/support/unix_connect.py", line 93, in _get_tcp_socket s.connect((host, 6000 + dno)) ConnectionRefusedError: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "index.py", line 9, in import pyautogui File "/home/ubuntu/.local/lib/python3.8/site-packages/pyautogui/init.py", line 249, in import mouseinfo File "/home/ubuntu/.local/lib/python3.8/site-packages/mouseinfo/init.py", line 223, in _display = Display(os.environ['DISPLAY']) File "/home/ubuntu/.local/lib/python3.8/site-packages/Xlib/display.py", line 89, in init self.display = _BaseDisplay(display) File "/home/ubuntu/.local/lib/python3.8/site-packages/Xlib/display.py", line 71, in init protocol_display.Display.init(self, *args, **keys) File "/home/ubuntu/.local/lib/python3.8/site-packages/Xlib/protocol/display.py", line 89, in init self.socket = connect.get_socket(name, protocol, host, displayno) File "/home/ubuntu/.local/lib/python3.8/site-packages/Xlib/support/connect.py", line 87, in get_socket return mod.get_socket(dname, protocol, host, dno) File "/home/ubuntu/.local/lib/python3.8/site-packages/Xlib/support/unix_connect.py", line 127, in get_socket raise error.DisplayConnectionError(dname, str(val)) Xlib.error.DisplayConnectionError: Can't connect to display ":10.0": [Errno 111] Connection refused

A VM é hospedada na Google Cloud, tem um Intel Cascade Lake.

fguide commented 2 years ago

Você criou o display na VM?

image

martinsssgabriel commented 2 years ago

Faltou a permissão, vou habilitar e testar

martinsssgabriel commented 2 years ago

Fiz a liberação e ao rodar, estourou outro:

Traceback (most recent call last): File "/home/ubuntu/.local/lib/python3.8/site-packages/Xlib/support/unix_connect.py", line 76, in get_socket s.connect('/tmp/.X11-unix/X%d' % dno) FileNotFoundError: [Errno 2] No such file or directory

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "index.py", line 9, in import pyautogui File "/home/ubuntu/.local/lib/python3.8/site-packages/pyautogui/init.py", line 249, in import mouseinfo File "/home/ubuntu/.local/lib/python3.8/site-packages/mouseinfo/init.py", line 223, in _display = Display(os.environ['DISPLAY']) File "/home/ubuntu/.local/lib/python3.8/site-packages/Xlib/display.py", line 80, in init self.display = _BaseDisplay(display) File "/home/ubuntu/.local/lib/python3.8/site-packages/Xlib/display.py", line 62, in init display.Display.init(*(self, ) + args, **keys) File "/home/ubuntu/.local/lib/python3.8/site-packages/Xlib/protocol/display.py", line 58, in init self.socket = connect.get_socket(name, host, displayno) File "/home/ubuntu/.local/lib/python3.8/site-packages/Xlib/support/connect.py", line 76, in get_socket return mod.get_socket(dname, host, dno) File "/home/ubuntu/.local/lib/python3.8/site-packages/Xlib/support/unix_connect.py", line 78, in get_socket raise error.DisplayConnectionError(dname, str(val)) Xlib.error.DisplayConnectionError: Can't connect to display ":10.0": [Errno 2] No such file or directory

fguide commented 2 years ago

Xlib.error.DisplayConnectionError: Can't connect to display ":10.0": [Errno 2] No such file or directory

Nao achou display, você esta executando "dentro" da interface grafica ou via SSH? Se for via SSH precisa exportar o display primeiro:

export DISPLAY=:1 (:1 é o padrao, tem que ver se a sua sessao X esta rodando nesse display, parece pelo erro que é :10.0)

martinsssgabriel commented 2 years ago

Eu instalei a interface gráfica, esses comandos to rodando no terminal dentro da maquina.

fguide commented 2 years ago

Antes de executar o bot, tente rodar no terminal:

export DISPLAY=$(echo $DISPLAY)

martinsssgabriel commented 2 years ago

rodei, após o comando tentei rodar o bot dnv.

Traceback (most recent call last): File "/home/ubuntu/.local/lib/python3.8/site-packages/Xlib/support/unix_connect.py", line 119, in get_socket s = _get_unix_socket(address) File "/home/ubuntu/.local/lib/python3.8/site-packages/Xlib/support/unix_connect.py", line 98, in _get_unix_socket s.connect(address) ConnectionRefusedError: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/home/ubuntu/.local/lib/python3.8/site-packages/Xlib/support/unix_connect.py", line 123, in get_socket s = _get_tcp_socket(host, dno) File "/home/ubuntu/.local/lib/python3.8/site-packages/Xlib/support/unix_connect.py", line 93, in _get_tcp_socket s.connect((host, 6000 + dno)) ConnectionRefusedError: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "index.py", line 9, in import pyautogui File "/home/ubuntu/.local/lib/python3.8/site-packages/pyautogui/init.py", line 249, in import mouseinfo File "/home/ubuntu/.local/lib/python3.8/site-packages/mouseinfo/init.py", line 223, in _display = Display(os.environ['DISPLAY']) File "/home/ubuntu/.local/lib/python3.8/site-packages/Xlib/display.py", line 89, in init self.display = _BaseDisplay(display) File "/home/ubuntu/.local/lib/python3.8/site-packages/Xlib/display.py", line 71, in init protocol_display.Display.init(self, *args, **keys) File "/home/ubuntu/.local/lib/python3.8/site-packages/Xlib/protocol/display.py", line 89, in init self.socket = connect.get_socket(name, protocol, host, displayno) File "/home/ubuntu/.local/lib/python3.8/site-packages/Xlib/support/connect.py", line 87, in get_socket return mod.get_socket(dname, protocol, host, dno) File "/home/ubuntu/.local/lib/python3.8/site-packages/Xlib/support/unix_connect.py", line 127, in get_socket raise error.DisplayConnectionError(dname, str(val)) Xlib.error.DisplayConnectionError: Can't connect to display ":1": [Errno 111] Connection refused

fguide commented 2 years ago

Hum, achou o display certo, parece que é erro com xauth entao, qual o resultado de:

echo $XAUTHORITY

Deveria aparecer: /home/ubuntu/.Xauthority

Se nao aparecer nada, digite:

export $XAUTHORITY=~/.Xauthority

martinsssgabriel commented 2 years ago

Pior que apareceu, mas ele segue não está conseguindo conectar no display...

fguide commented 2 years ago

Opa, desculpe eu estive enrolado hoje. Já resolveu o problema? Você tinha dito que era algo sobre permissões, vc viu se as permissoes do Xauthority estao corretas? Tente ajustar conforme abaixo (estou assumindo que o user é ubuntu e o grupo é ubuntu tb)

chown ubuntu:ubuntu ~/.Xauthority chmod 0600 ~/.Xauthority

daniloricalmeida commented 2 years ago

@Hauntertierce, voce conseguiu resolver esse problema? Estou tentando rodar no debian e está dando o mesmo erro.

fguide commented 2 years ago

Com qual software vcs estao acessando a interface gráfica?

daniloricalmeida commented 2 years ago

estou rodando o debian em um VM com virtualBox... estou acessando direto na virtualização.

fguide commented 2 years ago

estou rodando o debian em um VM com virtualBox... estou acessando direto na virtualização.

Tem algo errado com a instalação gráfica entao, qual desktop manager? Você usa X ou wayland?

daniloricalmeida commented 2 years ago

Interface Gráfica é o GNOME e o manager wayland

fguide commented 2 years ago

Interface Gráfica é o GNOME e o manager wayland

Tente usar o Xorg entao, se nao me engano o wayland trata monitores de forma diferente, por isso o erro ao conectar no display.

@Hauntertierce

Seu caso deve ser o mesmo, talvez esteja usando wayland.

daniloricalmeida commented 2 years ago

Cara, era isso mesmo, alterei pra Xorg e rodou normal.... valeu @fguide, vc é o cara.. rsrs

martinsssgabriel commented 2 years ago

Uma coisa que notei só depois, tinha um terminal ssh conectado na maquina ao mesmo tempo que o RDP. Tentei hoje novamente apenas com o RDP aberto e deu bom, acho que era burrice mesmo.

Valeu pela ajuda @fguide. Se precisa de alguma coisa da um toque! Abraço