Connect to Apache Phoenix Docker Container Using Python - python

I am running an Apache Phoenix container along with Hbase using the following command,
docker run -it --name phoenix -p 8765:8765 avapno/apache-phoenix
This is done as explained here,
https://hub.docker.com/r/avapno/apache-phoenix
The containers run without a problem.
Now, I want to connect to Phoenix using Python. This is the code I have used to do so,
import phoenixdb
database_url = 'http://localhost:8765/'
conn = phoenixdb.connect(database_url, autocommit=True)
This does not, however, seem to work. I keep getting the following error,
ConnectionError: HTTPConnectionPool(host='localhost', port=8765): Max retries exceeded with url: / (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7ffb03782080>: Failed to establish a new connection: [Errno 111] Connection refused'))
How exactly do I get this done correctly?
Also, is there a better way to get Hbase + Phoenix running?

Related

Getting "Failed to establish a new connection: [Errno -3] Temporary failure in name resolution" in Uvicorn server in Docker environment

I am getting the below exception while making a call from my project-
My code is deployed on Docker and inside it running python uvicorn server.
I have double check the URL, there is no error in that.
Below is the exception mentioned.
Exception raised HTTPSConnectionPool(host='XXXXXX', port=443): Max
retries exceeded with url:
/oauth2/auth?response_type=code&state=test_state&client_id=110438&redirect_uri=https://XXXXX.com/plugin/callback (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection
object at 0x7f0bd835a6d0>: Failed to establish a new connection:
[Errno -3] Temporary failure in name resolution'))
Could someone please help me?
Thanks

Can't send any request inside docker container

I am developing a Flask application with Docker setup. My Os is Linux Mint. Suddenly can't send any request from my application. It's showing error like this:
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='api.kickbox.io', port=443):
Max retries exceeded with url: /v2/verify?email=harun1393%40gmail.com&timeout=6000 (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7f71b5e89c90>:
Failed to establish a new connection: [Errno -3] Temporary failure in name resolution'))
ping google.com is working fine from my OS but showing Temporary failure in name resolution inside docker container.
docker exec -it web /bin/bash
root#b72e895be44a:/web# ping google.com
ping: google.com: Temporary failure in name resolution
/etc/resolve.conf from OS:
nameserver 192.168.0.1
/ect/resolve.conf inside docker container
nameserver 127.0.0.11
options ndots:0
cat /etc/docker/daemon.json
{
"dns": ["192.168.0.1", "8.8.8.8"]
}
I used host network in docker-compose.yml, but result is same.
website:
# network_mode: host
build:
context: .
network: host
container_name: web
I have tried a lot, but couldn't solve my problem.

Querying docker server in parallel raises connection error - python

In Python3, I am using get.requests() in a parallel loop to query a server that I have running in a docker container (specifically an OSRM server).
I get this error after it successfully queries a few:
requests.exceptions.ConnectionError: ('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer'))
I think the Docker container has a limit on the number of queries at a time or from a single IP, but I don't know how to fix it. I'm assuming it's in the Docker settings.
I initiate the docker container using: docker run --name osrm-nc -t -i -p 6002:5000 -v /homedirs/tml62/osm:/data osrm/osrm-backend osrm-routed --algorithm mld /data/north-carolina-latest.osrm, so noteably, I'm assigning the ports
I've set the retries so it can repeat and that sometimes fixes it, but it causes delays and sometimes will still break.

google-cloud-profiler metadata server WARNING

I am trying to use Google Cloud Profiler in a python script running locally. It seems it is having problems to connect with a metadata server:
WARNING:googlecloudprofiler.client:Failed to fetch instance/zone from GCE metadata server: HTTPConnectionPool(host='metadata', port=80): Max retries exceeded with url: /computeMetadata/v1/instance/zone (Caused by NewConnectionError(': Failed to establish a new connection: [Errno -2] Name or service not known',))
WARNING:googlecloudprofiler.client:Failed to fetch instance/name from
GCE metadata server: HTTPConnectionPool(host='metadata', port=80): Max
retries exceeded with url: /computeMetadata/v1/instance/name (Caused
by NewConnectionError(': Failed to establish a new connection: [Errno -2] Name
or service not known',))
Since the app seems to be running correctly and the profiler is collecting data successfully, is it OK if I just ignore the warnings or will I likely encounter some problems in the future?
If you're running locally (and haven't, for example, manually zone in the config), these warnings are expected, so ignoring them is definitely okay.
(Disclosure: I work at Google on Stackdriver Profiler)

Openshift python requests proxy permission denied

I'm trying to use a proxy with the python 'requests' package on an Openshift server. I am getting a permission denied error. See below.
Is Openshift blocking the connection or am I not configuring it correctly? Something else? Openshift doesn't want to let me connect to a proxy because the code works fine locally and on Heroku.
Code
from ssl import PROTOCOL_TLSv1
import ssladapter
proxies = {'https': 'http://{}:{}#96.44.147.34:6060'.format(CFG.proxy_username, CFG.proxy_password)}
url1 = 'https://reservaciones.volaris.com/Flight/DeepLinkSearch'
session = requests.Session()
session.mount('https://', ssladapter.SSLAdapter(ssl_version=PROTOCOL_TLSv1))
request1 = session.get(url1, proxies=proxies)
Traceback
requests.exceptions.ProxyError: HTTPSConnectionPool(host='reservaciones.volaris.com', port=443): Max retries exceeded with url: /Flight/DeepLinkSearch (Caused by ProxyError('Cannot connect to proxy.', NewConnectionError('<requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x7f4e78386ad0>: Failed to establish a new connection: [Errno 13] Permission denied',)))
Most probably OpenShift blocks uncommon outgoing ports for security reasons. your proxy is listening on 6060. You should try to ssh into your gear and try telnet
In my gear, post 6060 is blocked. See the attached screenshot. portquiz listens on all TCP ports.

Categories