Last active
March 7, 2023 21:49
-
-
Save kylegallatin/cb6212b669fbc19a05cb45351fbc68a4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
import grpc | |
def get_grpc_connection(host_port: str, secure: bool): | |
if secure: | |
credentials = grpc.ssl_channel_credentials() | |
channel = grpc.secure_channel(host_port, credentials) | |
else: | |
channel = grpc.insecure_channel(host_port) | |
return channel | |
def check_grpc_connection(host_port: str, secure: bool): | |
channel = get_grpc_connection(host_port, secure) | |
try: | |
grpc.channel_ready_future(channel).result(timeout=5) | |
return f"Successfully established secure:{secure} channel to {host_port}" | |
except: | |
return f"Timeout. Failed to establish secure:{secure} channel to {host_port}. Check your ingress/proxy configuration." | |
print(check_grpc_connection(sys.argv[1], True)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment