Why do I get a connection error using qBittorrentAPI? - python

I'm trying to run some code from this website but I don't understand why I get this error:
qbittorrentapi.exceptions.APIConnectionError: Failed to connect to qBittorrent. Connection Error: ConnectionError(MaxRetryError("HTTPConnectionPool(host='localhost', port=8080): Max retries exceeded with url: /api/v2/auth/login (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x000001FA519F5840>: Failed to establish a new connection: [WinError 10061] No connection could be made because the target machine actively refused it'))"))
The code in question:
import qbittorrentapi
# instantiate a Client using the appropriate WebUI configuration
qbt_client = qbittorrentapi.Client(
host='localhost',
port=8080,
username='admin',
password='adminadmin',
)
# the Client will automatically acquire/maintain a logged-in state
# in line with any request. therefore, this is not strictly necessary;
# however, you may want to test the provided login credentials.
try:
qbt_client.auth_log_in()
except qbittorrentapi.LoginFailed as e:
print(e)
# display qBittorrent info
print(f'qBittorrent: {qbt_client.app.version}')
print(f'qBittorrent Web API: {qbt_client.app.web_api_version}')
for k,v in qbt_client.app.build_info.items(): print(f'{k}: {v}')
# retrieve and show all torrents
for torrent in qbt_client.torrents_info():
print(f'{torrent.hash[-6:]}: {torrent.name} ({torrent.state})')
# pause all torrents
qbt_client.torrents.pause.all()
I'd really appreciate some help with this, thanks ahead :)

Related

Why is my simple firebase program trying to connect to the auth emulator?

im getting the following error when running the simple python program:
firebase_admin.exceptions.UnavailableError: Failed to establish a connection: HTTPConnectionPool(host='localhost', port=9099): Max retries exceeded with url: /identitytoolkit.googleapis.com/v1/projects/fir-api-test2-72710/accounts:lookup (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x000001B28FC6C4F0>: Failed to establish a new connection: [WinError 10061] No connection could be made because the target machine actively refused it'))
The python program I'm running that creates this error is very basic:
import json
# Firestore database
db = None
if __name__ == "__main__":
# FIRESTORE INITIALISATION
load_dotenv()
firebase_permisisions = json.loads(os.getenv('FIREBASE_CREDS'))
cred = credentials.Certificate(firebase_permisisions)
firebase_app = firebase_admin.initialize_app(cred)
db = firestore.client()
print('getting user')
# fails here
user = auth.get_user('1234')
print(user)
If my colleague runs this program on his machine it works.
Not sure why the connection pool is looking for the locahost? If I run the auth emulator on my machine it will work but picks up emulator users.
Ive test straight after rebooting my machine, and reinstall firebase admin but issue persists.
I do use the firebase emulator for other firebase projects
If anyone has any ideas that would be great,
Richard
Worked out that for some reason i had 'FIREBASE_AUTH_EMULATOR_HOST' set as environment variable. Now it works as expected

Max retries exceeded > with url when attempting to use the Confluence rest API in python

I trying to use the Confluence api with this code, its just a test to see if I can script creating a page in my confluence space in python.
from atlassian import Confluence
confluence = Confluence(
url='http://localhost:8090',
username='admin',
password='admin')
status = confluence.create_page(
space='DEMO',
title='This is the title',
body='This is the body. You can use <strong>HTML tags</strong>!')
print(status)
For some reason I keep getting the error below. Any information is helpful. Google wasn't much help.
HTTPConnectionPool(host='localhost', port=8090): Max retries exceeded
with url: /rest/api/content (Caused by
NewConnectionError('<urllib3.connection.HTTPConnection object at
0x0000028908E62A60>: Failed to establish a new connection: [WinError
10061] No connection could be made because the target machine actively
refused it'))
The solution to my problem was to drop the port at the end. Once this was done the code exicuted.

How can I get passed Connection error in pywebhfds?

I have a locally single-node hosted hadoop. my name and datanode are same.
I'm trying to create a file using python library.
self.hdfs = PyWebHdfsClient(host='192.168.231.130', port='9870', user_name='kush',
base_uri_pattern="http://192.168.231.130:9870/webhdfs/v1/", timeout=1)
if not self.hdfs.exists_file_dir(path):
self.hdfs.make_dir(path)
error-->self.hdfs.create_file("{}/results_{}.csv".format(path, name),
'word,negative,neutral,positive,compound\n')
the file exist and make_dir work correctly. But my create file keeps throwing an error
The exception I got is this:
requests.exceptions.ConnectionError: HTTPConnectionPool(host='kush', port=9864): Max retries exceeded with url: /webhdfs/v1/user/kush/data/results_4104.csv?op=CREATE&user.name=kush&namenoderpcaddress=192.168.231.130:9000&createflag=&createparent=true&overwrite=false (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x000001F8C3FB1C40>: Failed to establish a new connection: [WinError 10061] No connection could be made because the target machine actively refused it'))
I have already allowed firewall for 9000 , 9870 & 9864.
Thanks in advance. Help will be greatly appreciated
apparently i just needed to add 'kush' to /etc/hosts but one issue was my hostname and machine name was same
so i changed my machine name and then added it to my /etc/hosts both windows and linux
and voila!

For While loop keeps running

The script bellow is supposed to send the data to the url when the Google Compute Engine instance (using Container-Optimized OS image) is started and the dockerized app working.
Unfortunately, even if it fails to post the data, the data is received when the app is working.
The output is:
('Error',
ConnectionError(MaxRetryError("HTTPConnectionPool(host='34.7.8.8',
port=12345): Max retries exceeded with url: /didi.json (Caused by
NewConnectionError(': Failed to establish a new connection: [Errno 111]
Connection refused',))",),))
Does it come from GCE ?
Here is the python code:
for i in range(0,100):
while True:
try:
response = requests.post('http://%s:12345/didi.json' % ip_of_instance, data=data)
except requests.exceptions.RequestException as err:
print ("Error",err)
time.sleep(2)
continue
break
Edit - here are the parameters of the post request:
data = {
'url': 'www.website.com',
'project': 'webCrawl',
'spider': 'indexer',
'setting': 'ELASTICSEARCH_SERVERS=92.xx.xx.xx',
'protocol': 'https',
'scraper': 'light'
}
What I see is that you are using a while true loop, when it exceeds maximum retrys you get an error because you are being banned by the server but this status does not long forever, and when the banning is removed you start to get more data because the while still running.
If my theory is not right you can take a look at this other thread.
Max retries exceeded with URL

Django can't make external connections with requests or urllib2 on development server

Everytime I make an external request (including to google.com) I get this response:
HTTPConnectionPool(host='EXTERNALHOSTSITE', port=8080): Max retries exceeded with url: EXTERNALHOSTPARAMS (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x105d8d6d0>: Failed to establish a new connection: [Errno 8] nodename nor servname provided, or not known',))
It does seem that your server cannot resolve the hostname into IP, this is probably not Django nor Python problem but your server network setup issue.
Try to reach the same URL with ping tool / wget/curl or troubleshoot DNS with nslookup.

Categories