Error 10054 when connecting google service - python

I tried to connect to google api and got this error
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='www.google.com', port=443): Max retries exceeded with url: /speech-api/v1/recognize?xjerr=1&client=chromium&lang=ru-RU (Caused by <class 'socket.error'>: [Errno 10054] An existing connection was forcibly closed by the remote host)
this is my code, i used library urllib3,urllib2,requests but it did not help
import requests
recording = 'C:/Users/sborovskiy/PycharmProjects/VoiceManager/com/work/voiceManager/output.flac'
url = 'https://www.google.com/speech-api/v1/recognize?xjerr=1&client=chromium&lang=ru-RU'
headers = {'Content-Type' : 'audio/x-flac; rate=16000', 'User-Agent': 'Netscape 6.0'}
files = {'output.flac' : open(recording, 'rb')}
response = requests.post(url = url, data = files, headers = headers)
internet not give a specific answer

Related

How to solve HTTPSConnectionPool(host='graph.facebook.com', port=443): Max retries exceeded with url

I am trying to post something on Facebook
def make_post():
caption = post_caption()
url = (
f"https://graph.facebook.com/{config.page_id}/photos?"
f"caption={caption}&access_token={config.token}"
)
files = {
'image': open(pimage, "rb")
}
if config.dry_run:
return dummy_response
response = requests.post(url, files=files)
return response.json()
but it gave me this error
HTTPSConnectionPool(host='graph.facebook.com', port=443): Max retries exceeded with url: (Caused by NewConnectionError('urllib3.connection.HTTPSConnection object at 0x000001AD174AA5B0>: Failed to establish a new connection: [WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond'))
I have searched here in stackoverflow but I didn't find anything that works sorry I am new to this site, if I did anything wrong.

Requests giving errors while using HTTP proxies

So, I was sending a request using the requests library in Python 3.9.1. The problem is, when I tried to use an HTTP proxy it gave me this error:
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='google.com', port=443): Max retries exceeded with url: / (Caused by ProxyError('Cannot connect to proxy.', NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x000002B08D6BC9A0>: Failed to establish a new connection:
[WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond')))
This my code, I would appreciate any help.:
import requests
for proxy in open('proxies.txt','r').readlines():
proxies = {
'http': f'http://{proxy}',
'https': f'http://{proxy}'
}
e = requests.get('https://google.com/robots.txt',proxies=proxies)
open('uwu.txt','a').write(e.text)
print(e.text)
I am pretty sure it is not problem with my proxies as they are really good private proxies with 100 gigs of bandwidth. (from zenum.io).

Cannot connect to proxy error requests.get (python)

I am trying to connect to a proxy with requests.get, and whenever I try, I get a cannot connect to proxy error. Here is my code:
import requests
proxies = {
"http": "181.113.68.196:8080",
"https": "181.113.68.196:8080",
}
r = requests.get("https://thewebsite.com", proxies=proxies)
That ouputs this error:
requests.exceptions.ProxyError: HTTPSConnectionPool(host='thewebsite.com', port=443): Max retries exceeded with url: /python-requests-proxy (Caused by ProxyError('Cannot connect to proxy.', ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None)))
Im just putting thewebsite.com because it does the same thing with all of the websites I input. Can anyone help me with this?

ElectrumX server jsonRPC authentication

Unable to connect to electrum server
Error:
HTTPConnectionPool(host='electrum.eff.ro', port=50002): Max retries exceeded with url: / (Caused by NewConnectionError(': Failed to establish a new connection: [WinError 10061] No connection could be made because the target machine actively refused it'))
Connection is done in python:
electrum wallet jsonRPC authentication
import requests
import json
def main():
url = "http://electrum.eff.ro:50002"
payload = json.dumps(
{
"id": 0,
"method": "server.version",
"params": ["1.9.5", "0.6"]
}
)
headers = {'content-type': "application/json", 'cache-control': "no-cache"}
try:
response = requests.request("POST", url, data=payload, headers=headers, auth=(rpc_user, rpc_password))
return json.loads(response.text)
except requests.exceptions.RequestException as e:
print(e)
except:
print('No response from Wallet, check Bitcoin is running on this machine')
rpc_user = 'foo'
rpc_password = 'bar'
if __name__ == "__main__":
answer = main()
Such an error is constantly displayed.
UPD:
Server:
url = "http://fortress.qtornado.com:443"
error:
('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))
if connect HTTPS:
url = "https://fortress.qtornado.com:443"
error:
HTTPSConnectionPool(host='fortress.qtornado.com', port=443): Max retries exceeded with url: / (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate (_ssl.c:1051)')))
How to connect using ssl certificate?
An example of a solution to a problem:
https://github.com/cluelessperson/grappler
Bitcoin Testnet
import grappler
from base58 import b58decode_check
from binascii import hexlify
from hashlib import sha256
import codecs
a = grappler.ElectrumXConnector(
# host="fortress.qtornado.com", # bitcoin mainnet
host='tn.not.fyi',
port=55002,
# port=443,
ssl=True,
timeout=5
)
OP_DUP = b'76'
OP_HASH160 = b'a9'
BYTES_TO_PUSH = b'14'
OP_EQUALVERIFY = b'88'
OP_CHECKSIG = b'ac'
DATA_TO_PUSH = lambda address: hexlify(b58decode_check(address)[1:])
sig_script_raw = lambda address: b''.join((OP_DUP, OP_HASH160, BYTES_TO_PUSH, DATA_TO_PUSH(address), OP_EQUALVERIFY, OP_CHECKSIG))
script_hash = lambda address: sha256(codecs.decode(sig_script_raw(address), 'hex_codec')).digest()[::-1].hex()
a.send("server.version")
a.send("server.banner")
a.send('blockchain.scripthash.get_balance', script_hash('mksHkTDsauAP1L79rLZUQA3u36J3ntLtJx'))
a.send('blockchain.scripthash.get_mempool', script_hash('mksHkTDsauAP1L79rLZUQA3u36J3ntLtJx'))
a.send('blockchain.scripthash.subscribe', script_hash('mksHkTDsauAP1L79rLZUQA3u36J3ntLtJx'))

Failed to establish a new connection error using Python requests Errno -2 Name or service unknown

I am trying to make a request to an API with Python. I am able to make the request with curl without issue but I have something wrong with my Python request.
Why does this code,
import requests
from requests.auth import HTTPBasicAuth
emailadd = 'user123#example.com'
domain = 'example.com'
spantoken = 'omitted'
def checkUserLicensed(useremail):
url = ('https://api.spannigbackup.com/v1/users/' + useremail)
print(url)
response = requests.get(url, auth=(domain,spantoken))
print(response)
checkUserLicensed(emailadd)
Return this error
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='api.spannigbackup.com', port=443): Max retries exceeded with url: /v1/users/user123#example.com
(Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7f73ca323748>: Failed to establish a new connection: [Errno -2] Name or service not known'))

Categories