Cant connect to Firebase from my Raspberry pi - python

I'm having some issues with my raspberry setup.
The test:
# -*- coding: utf-8 -*-
import requests
import json
firebase_url = 'https://myDb.firebaseio.com'
name = 'db_name'
test = {}
print(firebase_url + '/' + name + '/setup.json')
test = requests.get(firebase_url + '/' + name + '/setup.json')
test = test.json()
print(test)
Runs on my laptop with no problems. On the Raspberry Pi I get this:
https://myDb.firebaseio.com/db_name/setup.json
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 516, in urlopen
body=body, headers=headers)
File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 304, in _make_request
self._validate_conn(conn)
File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 724, in _validate_conn
conn.connect()
File "/usr/lib/python3/dist-packages/urllib3/connection.py", line 203, in connect
conn = self._new_conn()
File "/usr/lib/python3/dist-packages/urllib3/connection.py", line 133, in _new_conn
(self.host, self.port), self.timeout, **extra_kw)
File "/usr/lib/python3/dist-packages/urllib3/util/connection.py", line 64, in create_connection
for res in socket.getaddrinfo(host, port, 0, socket.SOCK_STREAM):
File "/usr/lib/python3.4/socket.py", line 530, in getaddrinfo
for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -2] Name or service not known
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/requests/adapters.py", line 362, in send
timeout=timeout
File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 559, in urlopen
_pool=self, _stacktrace=stacktrace)
File "/usr/lib/python3/dist-packages/urllib3/util/retry.py", line 245, in increment
raise six.reraise(type(error), error, _stacktrace)
File "/usr/lib/python3/dist-packages/six.py", line 624, in reraise
raise value.with_traceback(tb)
File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 516, in urlopen
body=body, headers=headers)
File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 304, in _make_request
self._validate_conn(conn)
File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 724, in _validate_conn
conn.connect()
File "/usr/lib/python3/dist-packages/urllib3/connection.py", line 203, in connect
conn = self._new_conn()
File "/usr/lib/python3/dist-packages/urllib3/connection.py", line 133, in _new_conn
(self.host, self.port), self.timeout, **extra_kw)
File "/usr/lib/python3/dist-packages/urllib3/util/connection.py", line 64, in create_connection
for res in socket.getaddrinfo(host, port, 0, socket.SOCK_STREAM):
File "/usr/lib/python3.4/socket.py", line 530, in getaddrinfo
for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
urllib3.exceptions.ProtocolError: ('Connection aborted.', gaierror(-2, 'Name or service not known'))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "test_fire.py", line 11, in <module>
test = requests.get(firebase_url + '/' + name + '/setup.json')
File "/usr/lib/python3/dist-packages/requests/api.py", line 60, in get
return request('get', url, **kwargs)
File "/usr/lib/python3/dist-packages/requests/api.py", line 49, in request
return session.request(method=method, url=url, **kwargs)
File "/usr/lib/python3/dist-packages/requests/sessions.py", line 457, in request
resp = self.send(prep, **send_kwargs)
File "/usr/lib/python3/dist-packages/requests/sessions.py", line 569, in send
r = adapter.send(request, **kwargs)
File "/usr/lib/python3/dist-packages/requests/adapters.py", line 407, in send
raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', gaierror(-2, 'Name or service not known'))
I get that it means that it can't connect. Why it can't connect is another question though. I'm running this test while logged in over SSH with weaved. So internet is up and running without any problems. I feel like I'm missing something obvious but I just don't know where to look.
Thanks!

It was a DNS problem and everything was fixed by adding nameserver 8.8.8.8 to /etc/resolv.conf...
Case closed.

Related

Failed to generate list of vault tokens

Looking for a solution to the problem to identify the vault root tokens, I found the following documentation
https://www.greenreedtech.com/identifying-active-hashicorp-vault-root-tokens/
The script related in this link worked in a vault instance that I have in version 1.5.4, but i have a problem listing the vault tokens in version 1.6.1
Traceback (most recent call last):
File "/home/vault/tokenlist-prod.py", line 31, in <module>
output = client.lookup_token(key, accessor=True)
File "/usr/local/lib/python3.10/dist-packages/hvac/v1/__init__.py", line 444, in lookup_token
return self._adapter.post(path, json=accessor_param, wrap_ttl=wrap_ttl)
File "/usr/local/lib/python3.10/dist-packages/hvac/adapters.py", line 126, in post
return self.request("post", url, **kwargs)
File "/usr/local/lib/python3.10/dist-packages/hvac/adapters.py", line 364, in request
response = super(JSONAdapter, self).request(*args, **kwargs)
File "/usr/local/lib/python3.10/dist-packages/hvac/adapters.py", line 330, in request
utils.raise_for_error(
File "/usr/local/lib/python3.10/dist-packages/hvac/utils.py", line 41, in raise_for_error
raise exceptions.Forbidden(message, errors=errors, method=method, url=url)
hvac.exceptions.Forbidden: 1 error occurred:
* permission denied
, on post https://mydomain/v1/auth/token/lookup-accessor
python3 tokenlist-alter.py
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/urllib3/connection.py", line 174, in _new_conn
conn = connection.create_connection(
File "/usr/lib/python3/dist-packages/urllib3/util/connection.py", line 96, in create_connection
raise err
File "/usr/lib/python3/dist-packages/urllib3/util/connection.py", line 86, in create_connection
sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 704, in urlopen
httplib_response = self._make_request(
File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 399, in _make_request
conn.request(method, url, **httplib_request_kw)
File "/usr/lib/python3/dist-packages/urllib3/connection.py", line 239, in request
super(HTTPConnection, self).request(method, url, body=body, headers=headers)
File "/usr/lib/python3.10/http/client.py", line 1282, in request
self._send_request(method, url, body, headers, encode_chunked)
File "/usr/lib/python3.10/http/client.py", line 1328, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "/usr/lib/python3.10/http/client.py", line 1277, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "/usr/lib/python3.10/http/client.py", line 1037, in _send_output
self.send(msg)
File "/usr/lib/python3.10/http/client.py", line 975, in send
self.connect()
File "/usr/lib/python3/dist-packages/urllib3/connection.py", line 205, in connect
conn = self._new_conn()
File "/usr/lib/python3/dist-packages/urllib3/connection.py", line 186, in _new_conn
raise NewConnectionError(
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPConnection object at 0x7f398c14cd60>: Failed to establish a new connection: [Errno 111] Connection refused
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/requests/adapters.py", line 440, in send
resp = conn.urlopen(
File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 786, in urlopen
retries = retries.increment(
File "/usr/lib/python3/dist-packages/urllib3/util/retry.py", line 592, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='localhost', port=54453): Max retries exceeded with url: /v1/auth/token/accessors?list=True (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f398c14cd60>: Failed to establish a new connection: [Errno 111] Connection refused'))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/vault/tokenlist-alter.py", line 25, in <module>
payload = client.list('auth/token/accessors')
File "/usr/local/lib/python3.10/dist-packages/hvac/v1/__init__.py", line 253, in list
return self._adapter.get("/v1/{0}".format(path), params=payload)
File "/usr/local/lib/python3.10/dist-packages/hvac/adapters.py", line 113, in get
return self.request("get", url, **kwargs)
File "/usr/local/lib/python3.10/dist-packages/hvac/adapters.py", line 364, in request
response = super(JSONAdapter, self).request(*args, **kwargs)
File "/usr/local/lib/python3.10/dist-packages/hvac/adapters.py", line 313, in request
response = self.session.request(
File "/usr/lib/python3/dist-packages/requests/sessions.py", line 529, in request
resp = self.send(prep, **send_kwargs)
File "/usr/lib/python3/dist-packages/requests/sessions.py", line 645, in send
r = adapter.send(request, **kwargs)
File "/usr/lib/python3/dist-packages/requests/adapters.py", line 519, in send
raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPConnectionPool(host='localhost', port=54453): Max retries exceeded with url: /v1/auth/token/accessors?list=True (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f398c14cd60>: Failed to establish a new connection: [Errno 111] Connection refused'))
The token I use to run the script is a root token
the urls i use have ssl certificate
Could someone help me with this problem?
Share my Script Script Py
Share Script
#!/usr/local/bin/python3
import os
import time
import hvac
import urllib3
from prettytable import PrettyTable
urllib3.disable_warnings()
try:
os.environ["VAULT_ADDR"] = "https://vault.test.com"
except Exception:
print("The VAULT_ADDR environment must be set.")
os._exit(1)
try:
os.environ["VAULT_TOKEN"] = "lalala"
except Exception:
print("The VAULT_TOKEN environment must be set.")
os._exit(1)
client = hvac.Client(url=os.environ['VAULT_ADDR'], verify=False, token=os.environ["VAULT_TOKEN"])
payload = client.list('auth/token/accessors')
keys = payload['data']['keys']
x = PrettyTable()
x.field_names = ["Display Name", "Creation Time", "Expiration Time", "Policies", "Token Accessor"]
for key in keys:
output = client.lookup_token(key, accessor=True)
display_name = output['data']['display_name']
creation_date = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(output['data']['creation_time']))
expire_time = output['data']['expire_time']
policies = output['data']['policies']
accessor = key
if "root" in policies:
x.add_row([display_name, creation_date, expire_time, policies, accessor])
print(x)

Unable to create ec2 instance using python boto3 in vs code

import boto3
aws_mag_con = boto3.session.Session(aws_access_key_id='xxxxxxxxxxxxxx',aws_secret_access_key='xxxxxxxxxxxxxx')
newec2 = aws_mag_con.client('ec2','us-east-1c',aws_access_key_id='xxxxxxxxxxxxxx',aws_secret_access_key='xxxxxxxxxxx')
conn = newec2.run_instances(InstanceType="t2.micro",MaxCount=1,MinCount=1,ImageId="ami-0e1d30f2c40c4c701")
Tried to create instance by running the above boto3 script. It is failing with below error. Any help on this?
Traceback (most recent call last):
File "C:\Users\va20054093\AppData\Local\Programs\Python\Python39\lib\site-packages\urllib3\connection.py", line 174, in _new_conn
conn = connection.create_connection(
File "C:\Users\va20054093\AppData\Local\Programs\Python\Python39\lib\site-packages\urllib3\util\connection.py", line 72, in create_connection
for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM):
File "C:\Users\va20054093\AppData\Local\Programs\Python\Python39\lib\socket.py", line 953, in getaddrinfo
for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno 11001] getaddrinfo failed
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\va20054093\AppData\Local\Programs\Python\Python39\lib\site-packages\botocore\httpsession.py", line 403,
in send
urllib_response = conn.urlopen(
File "C:\Users\va20054093\AppData\Local\Programs\Python\Python39\lib\site-packages\urllib3\connectionpool.py", line 785, in urlopen
retries = retries.increment(
File "C:\Users\va20054093\AppData\Local\Programs\Python\Python39\lib\site-packages\urllib3\util\retry.py", line 525, in increment
raise six.reraise(type(error), error, _stacktrace)
File "C:\Users\va20054093\AppData\Local\Programs\Python\Python39\lib\site-packages\urllib3\packages\six.py", line 770,
in reraise
raise value
File "C:\Users\va20054093\AppData\Local\Programs\Python\Python39\lib\site-packages\urllib3\connectionpool.py", line 703, in urlopen
httplib_response = self._make_request(
File "C:\Users\va20054093\AppData\Local\Programs\Python\Python39\lib\site-packages\urllib3\connectionpool.py", line 386, in _make_request
self._validate_conn(conn)
File "C:\Users\va20054093\AppData\Local\Programs\Python\Python39\lib\site-packages\urllib3\connectionpool.py", line 1040, in _validate_conn
conn.connect()
File "C:\Users\va20054093\AppData\Local\Programs\Python\Python39\lib\site-packages\urllib3\connection.py", line 358, in connect
conn = self._new_conn()
File "C:\Users\va20054093\AppData\Local\Programs\Python\Python39\lib\site-packages\urllib3\connection.py", line 186, in _new_conn
raise NewConnectionError(
urllib3.exceptions.NewConnectionError: <botocore.awsrequest.AWSHTTPSConnection object at 0x000001AEE1E48E80>: Failed to establish a new connection: [Errno 11001] getaddrinfo failed
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "c:\Users\va20054093\Desktop\Stud\Python\.vscode\.vscode\runinstance.py", line 9, in <module>
conn = newec2.run_instances(InstanceType="t2.micro",MaxCount=1,MinCount=1,ImageId="ami-0e1d30f2c40c4c701")
File "C:\Users\va20054093\AppData\Local\Programs\Python\Python39\lib\site-packages\botocore\client.py", line 391, in _api_call
return self._make_api_call(operation_name, kwargs)
File "C:\Users\va20054093\AppData\Local\Programs\Python\Python39\lib\site-packages\botocore\client.py", line 705, in _make_api_call
http, parsed_response = self._make_request(
File "C:\Users\va20054093\AppData\Local\Programs\Python\Python39\lib\site-packages\botocore\client.py", line 725, in _make_request
return self._endpoint.make_request(operation_model, request_dict)
File "C:\Users\va20054093\AppData\Local\Programs\Python\Python39\lib\site-packages\botocore\endpoint.py", line 104, in
make_request
return self._send_request(request_dict, operation_model)
File "C:\Users\va20054093\AppData\Local\Programs\Python\Python39\lib\site-packages\botocore\endpoint.py", line 138, in
_send_request
while self._needs_retry(attempts, operation_model, request_dict,
File "C:\Users\va20054093\AppData\Local\Programs\Python\Python39\lib\site-packages\botocore\endpoint.py", line 254, in
_needs_retry
responses = self._event_emitter.emit(
File "C:\Users\va20054093\AppData\Local\Programs\Python\Python39\lib\site-packages\botocore\hooks.py", line 357, in emit
return self._emitter.emit(aliased_event_name, **kwargs)
File "C:\Users\va20054093\AppData\Local\Programs\Python\Python39\lib\site-packages\botocore\hooks.py", line 228, in emit
return self._emit(event_name, kwargs)
File "C:\Users\va20054093\AppData\Local\Programs\Python\Python39\lib\site-packages\botocore\hooks.py", line 211, in _emit
response = handler(**kwargs)
File "C:\Users\va20054093\AppData\Local\Programs\Python\Python39\lib\site-packages\botocore\retryhandler.py", line 183, in __call__
if self._checker(attempts, response, caught_exception):
File "C:\Users\va20054093\AppData\Local\Programs\Python\Python39\lib\site-packages\botocore\retryhandler.py", line 250, in __call__
should_retry = self._should_retry(attempt_number, response,
File "C:\Users\va20054093\AppData\Local\Programs\Python\Python39\lib\site-packages\botocore\retryhandler.py", line 277, in _should_retry
return self._checker(attempt_number, response, caught_exception)
File "C:\Users\va20054093\AppData\Local\Programs\Python\Python39\lib\site-packages\botocore\retryhandler.py", line 316, in __call__
checker_response = checker(attempt_number, response,
File "C:\Users\va20054093\AppData\Local\Programs\Python\Python39\lib\site-packages\botocore\retryhandler.py", line 222, in __call__
return self._check_caught_exception(
File "C:\Users\va20054093\AppData\Local\Programs\Python\Python39\lib\site-packages\botocore\retryhandler.py", line 359, in _check_caught_exceptionexception
raise caught_exception
File "C:\Users\va20054093\AppData\Local\Programs\Python\Python39\lib\site-packages\botocore\endpoint.py", line 201, in _do_get_response
http_response = self._send(request)
File "C:\Users\va20054093\AppData\Local\Programs\Python\Python39\lib\site-packages\botocore\endpoint.py", line 270, in _send
return self.http_session.send(request)
File "C:\Users\va20054093\AppData\Local\Programs\Python\Python39\lib\site-packages\botocore\httpsession.py", line 432, in send
raise EndpointConnectionError(endpoint_url=request.url, error=e)
botocore.exceptions.EndpointConnectionError: Could not connect to the endpoint URL: "https://ec2.us-east-1c.amazonaws.com/"
The error says:
Could not connect to the endpoint URL: "https://ec2.us-east-1c.amazonaws.com/"
The region is named us-east-1, while an AZ is named us-east-1c.
The error is in this line:
newec2 = aws_mag_con.client('ec2','us-east-1c',aws_access_key_id='xxxxxxxxxxxxxx',aws_secret_access_key='xxxxxxxxxxx')
Change us-east-1c into us-east-1.

yfinance api not working - receiving thread error

I was trying to run some code that I was able to run in the past with the following error. I tried to uninstalling yfinance and installing it again, upgrading yfinance, and the solution in the following link:
Exception in thread Thread-6:
Traceback (most recent call last):
File "C:\Users\limon\Anaconda3\lib\site-packages\urllib3\connectionpool.py", line 699, in urlopen
httplib_response = self._make_request(
File "C:\Users\limon\Anaconda3\lib\site-packages\urllib3\connectionpool.py", line 382, in _make_request
self._validate_conn(conn)
File "C:\Users\limon\Anaconda3\lib\site-packages\urllib3\connectionpool.py", line 1010, in _validate_conn
conn.connect()
File "C:\Users\limon\Anaconda3\lib\site-packages\urllib3\connection.py", line 411, in connect
self.sock = ssl_wrap_socket(
File "C:\Users\limon\Anaconda3\lib\site-packages\urllib3\util\ssl_.py", line 428, in ssl_wrap_socket
ssl_sock = _ssl_wrap_socket_impl(
File "C:\Users\limon\Anaconda3\lib\site-packages\urllib3\util\ssl_.py", line 472, in _ssl_wrap_socket_impl
return ssl_context.wrap_socket(sock, server_hostname=server_hostname)
File "C:\Users\limon\Anaconda3\lib\ssl.py", line 500, in wrap_socket
return self.sslsocket_class._create(
File "C:\Users\limon\Anaconda3\lib\ssl.py", line 1040, in _create
self.do_handshake()
File "C:\Users\limon\Anaconda3\lib\ssl.py", line 1309, in do_handshake
self._sslobj.do_handshake()
TimeoutError: [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
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\limon\Anaconda3\lib\site-packages\requests\adapters.py", line 439, in send
resp = conn.urlopen(
File "C:\Users\limon\Anaconda3\lib\site-packages\urllib3\connectionpool.py", line 755, in urlopen
retries = retries.increment(
File "C:\Users\limon\Anaconda3\lib\site-packages\urllib3\util\retry.py", line 532, in increment
raise six.reraise(type(error), error, _stacktrace)
File "C:\Users\limon\Anaconda3\lib\site-packages\urllib3\packages\six.py", line 734, in reraise
raise value.with_traceback(tb)
File "C:\Users\limon\Anaconda3\lib\site-packages\urllib3\connectionpool.py", line 699, in urlopen
httplib_response = self._make_request(
File "C:\Users\limon\Anaconda3\lib\site-packages\urllib3\connectionpool.py", line 382, in _make_request
self._validate_conn(conn)
File "C:\Users\limon\Anaconda3\lib\site-packages\urllib3\connectionpool.py", line 1010, in _validate_conn
conn.connect()
File "C:\Users\limon\Anaconda3\lib\site-packages\urllib3\connection.py", line 411, in connect
self.sock = ssl_wrap_socket(
File "C:\Users\limon\Anaconda3\lib\site-packages\urllib3\util\ssl_.py", line 428, in ssl_wrap_socket
ssl_sock = _ssl_wrap_socket_impl(
File "C:\Users\limon\Anaconda3\lib\site-packages\urllib3\util\ssl_.py", line 472, in _ssl_wrap_socket_impl
return ssl_context.wrap_socket(sock, server_hostname=server_hostname)
File "C:\Users\limon\Anaconda3\lib\ssl.py", line 500, in wrap_socket
return self.sslsocket_class._create(
File "C:\Users\limon\Anaconda3\lib\ssl.py", line 1040, in _create
self.do_handshake()
File "C:\Users\limon\Anaconda3\lib\ssl.py", line 1309, in do_handshake
self._sslobj.do_handshake()
urllib3.exceptions.ProtocolError: ('Connection aborted.', TimeoutError(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', None, 10060, None))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\limon\Anaconda3\lib\threading.py", line 932, in _bootstrap_inner
self.run()
File "C:\Users\limon\Anaconda3\lib\threading.py", line 870, in run
self._target(*self._args, **self._kwargs)
File "C:\Users\limon\Anaconda3\lib\site-packages\multitasking\__init__.py", line 102, in _run_via_pool
return callee(*args, **kwargs)
File "C:\Users\limon\Anaconda3\lib\site-packages\yfinance\multi.py", line 169, in _download_one_threaded
data = _download_one(ticker, start, end, auto_adjust, back_adjust,
File "C:\Users\limon\Anaconda3\lib\site-packages\yfinance\multi.py", line 181, in _download_one
return Ticker(ticker).history(period=period, interval=interval,
File "C:\Users\limon\Anaconda3\lib\site-packages\yfinance\base.py", line 152, in history
data = self.session.get(
File "C:\Users\limon\Anaconda3\lib\site-packages\requests\api.py", line 76, in get
return request('get', url, params=params, **kwargs)
File "C:\Users\limon\Anaconda3\lib\site-packages\requests\api.py", line 61, in request
return session.request(method=method, url=url, **kwargs)
File "C:\Users\limon\Anaconda3\lib\site-packages\requests\sessions.py", line 542, in request
resp = self.send(prep, **send_kwargs)
File "C:\Users\limon\Anaconda3\lib\site-packages\requests\sessions.py", line 655, in send
r = adapter.send(request, **kwargs)
File "C:\Users\limon\Anaconda3\lib\site-packages\requests\adapters.py", line 498, in send
raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', TimeoutError(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', None, 10060, None))
Already tried this solutions as well:
sudo python3 -m pip install --upgrade yfinance
As well as solution from this link:
https://pypi.org/project/fix-yahoo-finance/

Unable to run script through selenium grid. Got timeout error

Here is the log for Hub creation
Here is the log for Node creation
Here is Grid console output
Driver folder
This is the Python Script I wrote
import time
import unittest
from selenium import webdriver
class SearchProducts(unittest.TestCase):
def setUp(self):
desired_caps = {}
desired_caps['platform'] = 'WINDOWS'
desired_caps['browserName'] = 'chrome'
self.driver = webdriver.Remote('http://192.168.43.250:4444/wd/hub', desired_caps)
self.driver.get('http://demo.magentocommerce.com/')
self.driver.implicitly_wait(30)
self.driver.maximize_window()
def testSearchByCategory(self):
time.sleep(5)
# get the search textbox
self.search_icon = self.driver.find_element_by_xpath("//span[contains(., 'Search')]/preceding::span/div")
self.search_icon.click()
time.sleep(5)
self.search_field = self.driver.find_element_by_xpath("//div[#class='inputWrapper']//input[#id='edit-keys']")
self.search_field.click()
self.search_field.clear()
# enter search keyword and submit
self.search_field.send_keys('phones')
self.search_field.submit()
time.sleep(5)
def tearDown(self):
# close the browser window
self.driver.quit()
When ran script I got below log at Console
Error
Traceback (most recent call last):
File "C:\Users\jyothi\PycharmProjects\apautomationpython\venv\lib\site-packages\urllib3\connection.py", line 159, in _new_conn
conn = connection.create_connection(
File "C:\Users\jyothi\PycharmProjects\apautomationpython\venv\lib\site-packages\urllib3\util\connection.py", line 84, in create_connection
raise err
File "C:\Users\jyothi\PycharmProjects\apautomationpython\venv\lib\site-packages\urllib3\util\connection.py", line 74, in create_connection
sock.connect(sa)
TimeoutError: [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
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\PycharmProjects\apautomationpython\venv\lib\site-packages\urllib3\connectionpool.py", line 670, in urlopen
httplib_response = self._make_request(
File "C:\Users\PycharmProjects\apautomationpython\venv\lib\site-packages\urllib3\connectionpool.py", line 392, in _make_request
conn.request(method, url, **httplib_request_kw)
File "C:\Users\AppData\Local\Programs\Python\Python38\lib\http\client.py", line 1230, in request
self._send_request(method, url, body, headers, encode_chunked)
File "C:\Users\AppData\Local\Programs\Python\Python38\lib\http\client.py", line 1276, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "C:\Users\AppData\Local\Programs\Python\Python38\lib\http\client.py", line 1225, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "C:\Users\AppData\Local\Programs\Python\Python38\lib\http\client.py", line 1004, in _send_output
self.send(msg)
File "C:\Users\AppData\Local\Programs\Python\Python38\lib\http\client.py", line 944, in send
self.connect()
File "C:\Users\PycharmProjects\apautomationpython\venv\lib\site-packages\urllib3\connection.py", line 187, in connect
conn = self._new_conn()
File "C:\Users\PycharmProjects\apautomationpython\venv\lib\site-packages\urllib3\connection.py", line 171, in _new_conn
raise NewConnectionError(
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPConnection object at 0x000001A30BD477C0>: 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
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\AppData\Local\Programs\Python\Python38\lib\unittest\case.py", line 60, in testPartExecutor
yield
File "C:\Users\AppData\Local\Programs\Python\Python38\lib\unittest\case.py", line 672, in run
self._callSetUp()
File "C:\Users\AppData\Local\Programs\Python\Python38\lib\unittest\case.py", line 630, in _callSetUp
self.setUp()
File "C:\Users\PycharmProjects\apautomationpython\src\test\automation\web\test.py", line 12, in setUp
self.driver = webdriver.Remote('http://192.168.43.250:4444/wd/hub', desired_caps)
File "C:\Users\PycharmProjects\apautomationpython\venv\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 157, in __init__
self.start_session(capabilities, browser_profile)
File "C:\Users\PycharmProjects\apautomationpython\venv\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 252, in start_session
response = self.execute(Command.NEW_SESSION, parameters)
File "C:\Users\PycharmProjects\apautomationpython\venv\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 319, in execute
response = self.command_executor.execute(driver_command, params)
File "C:\Users\PycharmProjects\apautomationpython\venv\lib\site-packages\selenium\webdriver\remote\remote_connection.py", line 374, in execute
return self._request(command_info[0], url, body=data)
File "C:\Users\PycharmProjects\apautomationpython\venv\lib\site-packages\selenium\webdriver\remote\remote_connection.py", line 402, in _request
resp = http.request(method, url, body=body, headers=headers)
File "C:\Users\PycharmProjects\apautomationpython\venv\lib\site-packages\urllib3\request.py", line 79, in request
return self.request_encode_body(
File "C:\Users\PycharmProjects\apautomationpython\venv\lib\site-packages\urllib3\request.py", line 171, in request_encode_body
return self.urlopen(method, url, **extra_kw)
File "C:\Users\PycharmProjects\apautomationpython\venv\lib\site-packages\urllib3\poolmanager.py", line 336, in urlopen
response = conn.urlopen(method, u.request_uri, **kw)
File "C:\Users\PycharmProjects\apautomationpython\venv\lib\site-packages\urllib3\connectionpool.py", line 752, in urlopen
return self.urlopen(
File "C:\Users\PycharmProjects\apautomationpython\venv\lib\site-packages\urllib3\connectionpool.py", line 752, in urlopen
return self.urlopen(
File "C:\Users\PycharmProjects\apautomationpython\venv\lib\site-packages\urllib3\connectionpool.py", line 752, in urlopen
return self.urlopen(
File "C:\Users\PycharmProjects\apautomationpython\venv\lib\site-packages\urllib3\connectionpool.py", line 724, in urlopen
retries = retries.increment(
File "C:\Users\PycharmProjects\apautomationpython\venv\lib\site-packages\urllib3\util\retry.py", line 439, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='192.168.43.250', port=4444): Max retries exceeded with url: /wd/hub/session (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x000001A30BD477C0>: 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'))
Everything seems fine to me but Whats going wrong? How to resolve this error? Please help

Tweepy connection error 10053 after running for a while

I have been using Tweepy with Python 3 and needed to get the followers list of some famous handles for my learning.
Here is my code:
import tweepy
from tweepy import OAuthHandler
import time
consumer_key = 'x
consumer_secret = 'y'
access_token = 'a'
access_secret = 'b'
auth = OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_secret)
api = tweepy.API(auth)
users = tweepy.Cursor(api.followers, screen_name='realmadrid', count=200).items()
while True:
try:
user = next(users)
except tweepy.TweepError:
time.sleep(60 * 15)
user = next(users)
except StopIteration:
break
with open('BJP_Followers3.txt', 'a') as f:
f.write(user.screen_name)
f.write('\n')
print(user.screen_name)
Now, as we know I can get at most 3000 followers in given 15 mins time so I make it to sleep for 15 mins and then it runs and fetches another 3000 followers.
Now after this I got the following error:
Traceback (most recent call last):
File "C:\Python34\lib\site-packages\requests\packages\urllib3\connectionpool.py", line 594, in urlopen
chunked=chunked)
File "C:\Python34\lib\site-packages\requests\packages\urllib3\connectionpool.py", line 391, in _make_request
six.raise_from(e, None)
File "<string>", line 2, in raise_from
File "C:\Python34\lib\site-packages\requests\packages\urllib3\connectionpool.py", line 387, in _make_request
httplib_response = conn.getresponse()
File "C:\Python34\lib\http\client.py", line 1171, in getresponse
response.begin()
File "C:\Python34\lib\http\client.py", line 351, in begin
version, status, reason = self._read_status()
File "C:\Python34\lib\http\client.py", line 313, in _read_status
line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
File "C:\Python34\lib\socket.py", line 374, in readinto
return self._sock.recv_into(b)
File "C:\Python34\lib\ssl.py", line 751, in recv_into
return self.read(nbytes, buffer)
File "C:\Python34\lib\ssl.py", line 623, in read
v = self._sslobj.read(len, buffer)
ConnectionAbortedError: [WinError 10053] An established connection was aborted by the software in your host machine
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Python34\lib\site-packages\requests\adapters.py", line 423, in send
timeout=timeout
File "C:\Python34\lib\site-packages\requests\packages\urllib3\connectionpool.py", line 643, in urlopen
_stacktrace=sys.exc_info()[2])
File "C:\Python34\lib\site-packages\requests\packages\urllib3\util\retry.py", line 334, in increment
raise six.reraise(type(error), error, _stacktrace)
File "C:\Python34\lib\site-packages\requests\packages\urllib3\packages\six.py", line 685, in reraise
raise value.with_traceback(tb)
File "C:\Python34\lib\site-packages\requests\packages\urllib3\connectionpool.py", line 594, in urlopen
chunked=chunked)
File "C:\Python34\lib\site-packages\requests\packages\urllib3\connectionpool.py", line 391, in _make_request
six.raise_from(e, None)
File "<string>", line 2, in raise_from
File "C:\Python34\lib\site-packages\requests\packages\urllib3\connectionpool.py", line 387, in _make_request
httplib_response = conn.getresponse()
File "C:\Python34\lib\http\client.py", line 1171, in getresponse
response.begin()
File "C:\Python34\lib\http\client.py", line 351, in begin
version, status, reason = self._read_status()
File "C:\Python34\lib\http\client.py", line 313, in _read_status
line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
File "C:\Python34\lib\socket.py", line 374, in readinto
return self._sock.recv_into(b)
File "C:\Python34\lib\ssl.py", line 751, in recv_into
return self.read(nbytes, buffer)
File "C:\Python34\lib\ssl.py", line 623, in read
v = self._sslobj.read(len, buffer)
requests.packages.urllib3.exceptions.ProtocolError: ('Connection aborted.', ConnectionAbortedError(10053,
'An established connection was aborted by the software in your host machine', None, 10053, None))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Python34\lib\site-packages\tweepy-3.6.0-py3.4.egg\tweepy\binder.py", line 187, in execute
proxies=self.api.proxy)
File "C:\Python34\lib\site-packages\requests\sessions.py", line 488, in request
resp = self.send(prep, **send_kwargs)
File "C:\Python34\lib\site-packages\requests\sessions.py", line 609, in send
r = adapter.send(request, **kwargs)
File "C:\Python34\lib\site-packages\requests\adapters.py", line 473, in send
raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', ConnectionAbortedError(10053,
'An established connection was aborted by the software in your host machine', None, 10053, None))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "E:\python\MB\Data Mining\timeline.py", line 21, in <module>
user = next(users)
File "C:\Python34\lib\site-packages\tweepy-3.6.0-py3.4.egg\tweepy\cursor.py", line 49, in __next__
return self.next()
File "C:\Python34\lib\site-packages\tweepy-3.6.0-py3.4.egg\tweepy\cursor.py", line 197, in next
self.current_page = self.page_iterator.next()
File "C:\Python34\lib\site-packages\tweepy-3.6.0-py3.4.egg\tweepy\cursor.py", line 75, in next
**self.kargs)
File "C:\Python34\lib\site-packages\tweepy-3.6.0-py3.4.egg\tweepy\binder.py", line 245, in _call
return method.execute()
File "C:\Python34\lib\site-packages\tweepy-3.6.0-py3.4.egg\tweepy\binder.py", line 189, in execute
raise TweepError('Failed to send request: %s' % e)
tweepy.error.TweepError: Failed to send request: ('Connection aborted.', ConnectionAbortedError(10053,
'An established connection was aborted by the software in your host machine', None, 10053, None))
Now, I want to know the reason as well as a solution for this problem I am facing.

Categories