Openshift python requests proxy permission denied - python

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.

Related

Connect to Apache Phoenix Docker Container Using 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?

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.

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)

MQTT (Mosquitto) over TLS - certificate error in some programs

I set up a Mosquitto server a few days ago using https://www.digitalocean.com/community/tutorials/how-to-install-and-secure-the-mosquitto-mqtt-messaging-broker-on-debian-8.
Playing around with it, everything seemd to be working like I wanted. I am able to connect an android client and MQTTSpy to my own server.
Yesterday I had the great idea of looking for a Kodi plugin that would push status and info to MQTT: https://github.com/owagner/kodi2mqtt
It is able to find the server as I see changes in the Mosquitto log file, however I keep getting the same error:
1492549927: New connection from 81.240.134.64 on port 8883.
1492549927: OpenSSL Error: error:140760FC:SSL routines:SSL23_GET_CLIENT_HELLO:unknown protocol
1492549927: Socket error on client <unknown>, disconnecting.
1492549932: New connection from 81.240.134.64 on port 8883.
1492549933: OpenSSL Error: error:140780E5:SSL routines:SSL23_READ:ssl handshake failure
1492549933: Socket error on client <unknown>, disconnecting.
1492549934: New connection from 81.240.134.64 on port 8883.
1492549934: OpenSSL Error: error:140760FC:SSL routines:SSL23_GET_CLIENT_HELLO:unknown protocol
1492549934: Socket error on client <unknown>, disconnecting.
1492549939: New connection from 81.240.134.64 on port 8883.
1492549939: OpenSSL Error: error:140780E5:SSL routines:SSL23_READ:ssl handshake failure
1492549939: Socket error on client <unknown>, disconnecting.
From what I understand there are some issues with certificates but I am not 100% sure what is missing. In the other applications I do not need to provide my own certificates, so I don't see what is missing. I tried using the generated certificates in the Kodi addon, however they seem not to work and I get a different error:
1492541859: New connection from 81.240.134.64 on port 8883.
1492541860: OpenSSL Error: error:14094418:SSL routines:SSL3_READ_BYTES:tlsv1 alert unknown ca
1492541860: OpenSSL Error: error:140940E5:SSL routines:SSL3_READ_BYTES:ssl handshake failure
1492541860: Socket error on client <unknown>, disconnecting.
1492541862: New connection from 81.240.134.64 on port 8883.
1492541862: OpenSSL Error: error:14094418:SSL routines:SSL3_READ_BYTES:tlsv1 alert unknown ca
1492541862: OpenSSL Error: error:140940E5:SSL routines:SSL3_READ_BYTES:ssl handshake failure
1492541862: Socket error on client <unknown>, disconnecting.
I'm not sure in what direction I should check. Is something wrong with my server/certificates (seems unlikely since other clients are working) or is something wrong with the python code of the Kodi addon? If so, could anyone shed some light on what is missing (I know my way around coding, just not really around certificate things).
Thanks for the help!
Joren C.
Your python client will need access to the trusted certificate authority. Copy the signed public certificate The browser clients don't need that because they already come loaded with trusted certificate authorities.
If the kodi addon is using the paho mqtt client library , then the following should fix it..
client.tls_set('$your server's public cert$.crt')
Try ssl connection:
openssl s_client -connect 81.240.134.xxx:8883 -CAfile /etc/certs/file.crt -debug

Categories