[Question] Is it possible to customize both user-data-dir and websocket port
See original GitHub issueUse case:
The goal is to launch a browser on server that’s always up. I want to ensure that I can sign in to that browser and it will retain my credentials. Even after I restart my VM, the browser will retain all the user preferences, cookies etc. The way to achieve this would be to use both wsEndpoint
and userDataDir
.
From what I have understood:
- use
launchPersistentContext
to launch withuserDataDir
but it doesn’t allowwsEndpoint
- use
launchServer
to launch withwsEndpoint
but it doesn’t allowuserDataDir
I tried using websocket port with launchPersistentContext
but the code crashes with following error log of timeout:
TimeoutError: Timeout 10000ms exceeded during browserType.launchPersistentContext.
[1] app: [browser] <launched> pid=75403
[1] app: [browser]
[1] app: [browser] DevTools listening on ws://127.0.0.1:45555/devtools/browser/f44a1f4d-ce74-4965-b8e3-bb0546bd46d2
[1] app: [browser] [75403:50179:0716/205303.955435:ERROR:ssl_client_socket_impl.cc(959)] handshake failed; returned -1, SSL error code 1, net_error -202
Is there a way to achieve my use case with Playwright?
Issue Analytics
- State:
- Created 3 years ago
- Reactions:7
- Comments:7 (2 by maintainers)
Top Results From Across the Web
Can WebSockets and HTTP server both run on the SAME port ...
To provide this question with an answer: Yes, they can. See also: Is it possible to enable tcp, http and websocket all using...
Read more >Rufaydium WebDriver 1.7.2 (no selenium/websocket) - Page 18
This works if I have no chrome window open. However if there are other Chrome windows open (not created by chromedriver.exe) it stops ......
Read more >Puppeteer documentation - DevDocs
Puppeteer 7.1.0 API documentation with instant search, offline support, keyboard shortcuts, mobile version, and more.
Read more >Writing WebSocket servers - Web APIs | MDN
A WebSocket server is nothing more than an application listening on any port of a TCP server that follows a specific protocol.
Read more >WebSockets support in ASP.NET Core - Microsoft Learn
The default is two minutes. AllowedOrigins - A list of allowed Origin header values for WebSocket requests. By default, all origins are allowed....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
After some more digging through the code I found this env variable
PLAYWRIGHT_CHROMIUM_DEBUG_PORT
. I can use it to set a port duringchromium.launchPersistentContext
and the browser does launch with websocket port as well asuserDataDirectory
.At this point, I can use the
webSocketDebuggerUrl
fromlocalhost:12345/json/version
to connect to the browser. But from this browser, I can’t get the existing contexts and can only create new incognito contexts.This defeats the use case that I am trying to achieve.
I have time to contribute a fix but I don’t fully understand why browser server instances don’t have access to the pre-existing contexts and why are they limited to just incognito contexts. These seems like design decisions and I am sure they are valid ones.
I am hoping that we can add another way to connect. Something like
chromium.launchPersistentContextServer
which:Any pointers on where to look for design docs or how to achieve this would be really helpful and much appreciated. Thanks folks!
You can now pass --remote-debugging-port as an argument and use connectOverCDP.