-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[REGRESSION]: chromium.connect does not work with vanilla CDP servers anymore #4054
Comments
Hi @berstend! The underlying protocol has indeed changed in 1.4, and we are aware that this usecase is not supported anymore. However, it was never a goal for Playwright to work against CDP-based remote websockets. Playwright supports multiple browsers, and we try for all features to be equally supported by all of them. Our new protocol is the same for all browsers we support. I'd suggest to use Playwright
There is no API to connect to CDP websocket directly. A translation layer would be equivalent to ~50% of Playwright code base, so it does not look feasible. |
@dgozman Thanks a lot for the quick response on that matter. :-) Oh wow, that's unfortunate to hear. The CDP websocket has always felt like the underlying and unifying standard or common denominator that all CDP based automation frameworks could interface with. Note: I really appreciate the efforts of the Playwright team and the project contributors and can understand why switching to a custom wire protocol was desired. Having that said, I wonder what the best course of action would be if someone would be determined enough to develop a custom websocket server compatible with Playwright wire protocol and vanilla CDP clients. In my scenario I have full control over the websocket server consumed by pptr/pw clients but the server itself has to connect to existing browsers through vanilla CDP (playwright cannot be used to launch them). Would this be feasible:
Thanks a lot for your time and input, much appreciated. :-) |
Could you share why this is the case? We assumed you would simply run
Since we are more than just Chromium, it does not really work for us. Having said that, you can modify |
Btw, if you join #rpc channel on our Slack (link in our main README.md), we can discuss this and other topics there! |
We landed support for this in browserless/browserless#1018. There's a new You can see the change in behavior here: https://github.com/browserless/chrome/blob/master/src/puppeteer-provider.ts#L400 |
@pavelfeldman Not OP, but I want to highlight that there are various reasons to connect to existing Chrome CDP websockets that are not launched by Playwright. For example, if you have a scalable Chrome (e.g. k8s) cluster that already works with Puppeteer/Playwright. Or if you use Playwright with a third party infra solution like Browserless (see comment above of @joelgriffith) or HeadlessTesting. It would be awesome if there would be a way to call |
This all makes sense. When we are reasoning about it internally, we refer to the model where the k8s cluster includes Playwright Server and uses it to launch the browser. I believe Selenoid is now doing that already. This enables us (and you, cloud providers) operate much more efficiently:
So putting Playwright server into the cloud sounds like a clear win to us, by good margin. If there is some code that you are using to manage the executed instances that is missing from the Playwright Server, we would be happy to consider adding it upstream. We understand that it isn't free: solutions that support both Puppeteer and Playwright would need to maintain different code paths to support both. We also realize that it isn't feature complete ( |
@pavelfeldman thanks for going over this. I think the things you've outlined make a lot of sense, in particular the network traffic (an almost 10x drop in network chatter is huge). This is a big one for us. For us, the problem is maintenance burden as we support playwright, puppeteer, selenium as well as our own REST APIs. Adding the new playwright server was quick, but over the long term the cost does add up, so it's not a trivial change. As much as the change was a bit of a shock, I think it's worth the burden given what you've said. A few things that would be nice:
|
@joelgriffith congrats on your very fast fix :-) My use-case differs a bit from browserless, in the sense that I can run playwright on the server but I cannot use the current
@pavelfeldman Would the Playwright project be open to upstream patches for the following:
Happy to work on those changes (they should be side-effect free) and implement them in a way that fits the Playwright code style & naming preferences. edit, just to visualize what those changes would allow me to do 😄:
|
Do you mind sharing the usecase for this one? IIUC, the user data dir won't be accessible to any remote client, because it lives on the server, so how is it intended to be used? Also note that Playwright assumes exclusive access to the browser context to implement all kinds of context-wide method, e.g. routes. Since there is just a single persistent context that makes use of the user data dir, perhaps there is/should be a separate mechanism that ensures exclusive access to this persistent context between clients?
Are you talking about something like |
I think we'll be open to something like that. I'd prefer
Are you talking about sending this header when connecting to the new CDP webscoket from the |
Haha, no worries - no strong opinions on the naming here (hence me asking in advance) 😄
Yup, I'll be also checking with the puppeteer team to add a similar patch to their CDP websocket client. Great, I'm gonna get familiar with the playwright build/test setup and submit a draft PR once I find an elegant way to add Thanks for the feedback! |
Hi, We're in the same boat as @berstend and are eagerly awaiting the possibility for a People using HeadlessTesting.com can not use Playwright v1.4.0 with our service due to this change. |
We are also advising our users to not use version v1.4.0 or higher at 0browser.com. Please let us know if we can help with anything. Otherwise similar to browserless we have to create a dedicated endpoint for Playwright. Thanks! |
Closing, since there is now BrowserType.connectOverCDP since a few releases: https://playwright.dev/docs/api/class-browsertype#browsertypeconnectovercdpparams |
Hi there,
apologies if this has been asked before but I didn't find anything.
Up until
v1.3.0
it was possible to.connect
to a vanilla browser websocket URL (either created through launching Chrome with--remote-debugging
) or using Puppeteer).v1.4.0
introduced the new "New Client / Server Wire protocol", since then it's not possible to use.connect
with other original CDP websocket servers anymore (it will hang here). I also noticed through logging that the new wire protocol looks much different from the regular CDP chatter.My question would be if there's still a way to use
chromium.connect
with the traditional CDP websocket URLs or if there are pointers on how to best write a translation layer to accomplish that.My use-case is to have a single websocket url which exposes a fleet of chromium browsers by proxying the websocket connections (similar to browserless.io) and both puppeteer & playwright being able to
connect
to it and control the browsers.The following worked prior to
v1.4.0
:The text was updated successfully, but these errors were encountered: