Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 22 additions & 6 deletions vast.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from time import sleep
from subprocess import PIPE
import urllib3
import ssl
import atexit
from contextlib import redirect_stdout, redirect_stderr
from io import StringIO
Expand Down Expand Up @@ -7580,16 +7581,31 @@ def is_instance(instance_id):
return False, reason

# Attempt to connect to the progress endpoint
# Use a fresh session with custom SSL adapter to avoid state pollution
try:
if args.debugging:
debug_print(args, f"Sending GET request to https://{ip_address}:{port}/progress")
response = requests.get(f'https://{ip_address}:{port}/progress', verify=False, timeout=10)

if response.status_code == 200 and not first_connection_established:
progress_print(args, "Successfully established HTTPS connection to the server.")
first_connection_established = True

message = response.text.strip()
from requests.adapters import HTTPAdapter
from urllib3.util.ssl_ import create_urllib3_context

class FreshSSLAdapter(HTTPAdapter):
def init_poolmanager(self, *args, **kwargs):
ctx = create_urllib3_context()
ctx.check_hostname = False
ctx.verify_mode = ssl.CERT_NONE
kwargs['ssl_context'] = ctx
return super().init_poolmanager(*args, **kwargs)

with requests.Session() as session:
session.mount('https://', FreshSSLAdapter())
response = session.get(f'https://{ip_address}:{port}/progress', verify=False, timeout=10)

if response.status_code == 200 and not first_connection_established:
progress_print(args, "Successfully established HTTPS connection to the server.")
first_connection_established = True

message = response.text.strip()
if args.debugging:
debug_print(args, f"Received message: '{message}'")
except requests.exceptions.RequestException as e:
Expand Down