Getting 502 Bad Gateway Error with LunaProxy and Selenium Wire

26 views
Skip to first unread message

Austin Norman

unread,
Jun 29, 2025, 10:28:45 AMJun 29
to Selenium Users

I hope you're doing well. I'm trying to automate form submissions on "https://securelastexpense.com" using a Python script with Selenium Wire and LunaProxy, but I'm encountering a 502 Bad Gateway error. The error appears to be related to a TLS/SSL handshake failure, as shown in the browser logs (e.g., TlsProtocolException('Cannot establish TLS with securelastexpense.com:443...')). I've tried updating the cryptography library and setting verify_ssl=False in Selenium Wire options, but the issue persists.

I’d appreciate any help to resolve this. Thank you!

import random from seleniumwire import webdriver from selenium.webdriver.chrome.service import Service from selenium.webdriver.chrome.options import Options from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions as EC from selenium.webdriver.common.by import By from webdriver_manager.chrome import ChromeDriverManager import logging # Set up basic logging logging.basicConfig(level=logging.INFO, format="%(asctime)s - %(levelname)s - %(message)s") # LunaProxy credentials (placeholders) LUNAPROXY_USERNAME_BASE = "lu5715465" LUNAPROXY_PASSWORD = "k3fd84569H" LUNAPROXY_HOST = "pr.lunaproxy.com" LUNAPROXY_PORT = "12233" # Generate a sample proxy username def get_lunaproxy_username(city="losangeles", state="ca"): return f"user-{LUNAPROXY_USERNAME_BASE}-region-us-st-{state}-city-{city}" # Test proxy connection (simplified) def test_proxy(proxy_url): try: import requests test_url = "http://myip.lunaproxy.io" response = requests.get(test_url, proxies={"http": proxy_url, "https": proxy_url}, timeout=10, verify=False) if response.status_code == 200: logging.info("Proxy test successful") return True logging.error(f"Proxy test failed: {response.status_code}") return False except Exception as e: logging.error(f"Proxy test failed: {e}") return False def main(): proxy_username = get_lunaproxy_username() proxy_url = f"http://{proxy_username}:{LUNAPROXY_PASSWORD}@{LUNAPROXY_HOST}:{LUNAPROXY_PORT}" logging.info(f"Using proxy: {proxy_url}") # Test proxy if not test_proxy(proxy_url): logging.warning("Proxy test failed, proceeding without proxy") seleniumwire_options = {} else: seleniumwire_options = { "proxy": { "http": proxy_url, "https": proxy_url, "no_proxy": "localhost,127.0.0.1" }, "verify_ssl": False } # Set up Chrome options chrome_options = Options() chrome_options.add_argument("--log-level=3") # Initialize driver driver = webdriver.Chrome( service=Service(ChromeDriverManager().install()), options=chrome_options, seleniumwire_options=seleniumwire_options ) try: # Load the target page driver.get("https://securelastexpense.com") WebDriverWait(driver, 20).until( EC.presence_of_element_located((By.ID, "scroll-anchor")) ) logging.info("Page loaded successfully") except Exception as e: logging.error(f"Failed to load page: {e}") driver.save_screenshot("error_screenshot.png") finally: driver.quit() if __name__ == "__main__": main()```

Corey Goldberg

unread,
Jun 29, 2025, 10:36:40 AMJun 29
to seleniu...@googlegroups.com
Selenium Wire is outdated, unmaintained, and unaffiliated with the Selenium project. I'm not surprised it has issues, but you are sort of on your own with that.

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/selenium-users/772d25dd-9e10-4759-843b-9e575dfe0892n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages