wss:// requests forcing interceptor of selenium-wire into a infinite loop
See original GitHub issueI am trying to Intercept a specific request on a website. Once you’ve created a account on it and are browsing with that account; the website seems to launch a wss request (most likely for the onsite chat feature). This wss request is putting selenium-wire into a infinite loop, either constantly triggering it or triggering the couple requests that would come before or after it (but all those requests erroring out). This in return never allows the website to launch all requests in a normally successful order. To be honest, I am not too sure if it’s the wss request alone or the seemingly failing ssl certificate verification. I already tried doing verify=False
in selenium-wire options that didn’t change anything. Loading the website without my own user data dir / without a account on the website, the wss request seems to pass through, most likely because you can’t connect with the websocket request if you are not authenticated (have a user account on the website).
Here’s a visual representation of said issue: https://youtu.be/glnykmuG-cw
Please help me out 🙏 @wkeeling
import seleniumwire.undetected_chromedriver as uc
import re, os
chrome_options = uc.ChromeOptions()
# after creating a account on the website I am copying local data from browser here;
# so that I can browse the website with a authenticated selenium session
for e in ['--disable-extensions', fr'--user-data-dir={os.getenv("localappdata")}\Google\Chrome\User Data']:
chrome_options.add_argument(e)
chrome_options.headless = False
driver = uc.Chrome(options=chrome_options, use_subprocess=True)
def interceptor(request):
print(request.url)
driver.request_interceptor = interceptor
driver.get('https://fansly.com/')
input()
Selenium-wire version 4.6.3 | UC version 3.1.5.post4 | Python version 3.10.4 | Windows 10
Issue Analytics
- State:
- Created a year ago
- Reactions:1
- Comments:6 (4 by maintainers)
@randolfvalerija
Yes this isn’t currently possible for websocket messages. You’ll need to wait for the request/response to fully complete, then access the messages via the
ws_messages
attribute.@Avnsx sorry for the delay coming back on this. I’ve tried reproducing by creating a fansly.com account, signing in manually and then pointing Selenium Wire/undetected chromedriver at the user data folder. Chrome opens fansly.com up straight into the logged in session as expected. Checking the network panel and all looks well - there seems to be no errors relating to any requests as far as I can see. I tried clicking around and it seems OK.
The only difference is that I’m running on Linux and it looks as though you’re using Windows. The user data folder on Linux lives in
~/.config/google-chrome/
My code is pretty much the same as yours: