why is tor not working on heroku? what am i doing wrong?

Viewed 20

i installed tor on heroku and i try to work with it but it doesn't work. I run it using the Procfile file with the following command:

worker: python test.py | bash create-torrc.sh

here's what's in the create-torrc.sh file:

tor -f torrc

in the file test test.py, I send a request to the site that shows the IP address and add proxies, in which I enter the standard proxy, namely 127.0.0.1:9050, and if they answer yes, then I send myself a telegram message with the IP address, and if not answers, then I send a message that the tor is not working. here is the test.py file code:

import telebot
import requests
import time
from python_socks.sync import Proxy
bot = telebot.TeleBot('my bot id')
while True:
    time.sleep(5)
    proxies = {'http': f'socks5://127.0.0.1:9050',
    'https': f'socks5://127.0.0.1:9050'}
    try:
        full_page = requests.get("http://httpbin.org/ip", proxies=proxies, timeout=10)
        bot.send_message("my telegram ID", str(full_page.text))
    except:
        bot.send_message("my telegram ID", "tor не працює")

in the requirements.txt file, I entered all the libraries that I use, this is what is in this file:

pyTelegramBotAPI
requests
python-socks

in the Aptfile I installed tor, this is what it says:

tor -y

in the torrc file I configure tor on ports 9001 to 9999, here is the file, but without all the SocksPort commands:

DataDirectory Tor
GeoIPFile geoip
GeoIPv6File geoip6
 
AvoidDiskWrites 1
SocksPort 9001
SocksPort 9002

then there are many lines where I connect ports from 9001 to 9999

SocksPort 9998
SocksPort 9999
 
ControlPort 9051
CookieAuthentication 0

all files are loaded on heroku without errors and the tor starts normally, here is the output from View logs where it says that the tor is already running:

2022-09-13T10:50:27.317522+00:00 app[worker.1]: Sep 13 10:50:27.000 [notice] Bootstrapped 85% (ap_conn_done): Connected to a relay to build circuits
2022-09-13T10:50:27.448153+00:00 app[worker.1]: Sep 13 10:50:27.000 [notice] Bootstrapped 89% (ap_handshake): Finishing handshake with a relay to build circuits
2022-09-13T10:50:27.841599+00:00 app[worker.1]: Sep 13 10:50:27.000 [notice] Bootstrapped 90% (ap_handshake_done): Handshake finished with a relay to build circuits
2022-09-13T10:50:27.841634+00:00 app[worker.1]: Sep 13 10:50:27.000 [notice] Bootstrapped 95% (circuit_create): Establishing a Tor circuit
2022-09-13T10:50:28.400197+00:00 app[worker.1]: Sep 13 10:50:28.000 [notice] Bootstrapped 100% (done): Done

but when the test.py file starts working, it tells me that tor is not working, on the local computer, when I start tor and run this script, everything works fine and it writes ip addresses to me in telegram, but on heroku, it sends a message that it does not it works, I tried to run tor without the torrc file and connected to the standard port 127.0.0.1:9050 and to various ports from 127.0.0.1:9001 to 127.0.0.1:9999 and the answer from tor does not work. What am I doing wrong? What needs to be changed? is it possible to connect to Tor in a different way on Heroku?

0 Answers
Related