question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot create Firefox browser - protocol error / Browser closed

See original GitHub issue

I get an error trying to invoke LaunchAsync on Firefox browser on production Windows Server 2019 (machine 1) while it’s working fine on developer station Windows 10 Pro (machine 2). It’s working OK with Chromium on Windows Server 2019.

Running PlaywrightSharp Version="0.170.2" on .NET Core 3.1.11

Simplyfied code:

await PlaywrightSharp.Playwright.InstallAsync();

var server = await PlaywrightSharp.Playwright.CreateAsync(new NLogLoggerFactory(new NLogProviderOptions()));

var options = new LaunchOptions()
{
	Headless = true,
	IgnoreHTTPSErrors = true,
	options.Proxy = new ProxySettings() { Server = ... };
};
var browser = await server.Firefox.LaunchAsync(options);

var contextOptions = new BrowserContextOptions();
contextOptions.Locale = "en-US";
contextOptions.Geolocation = new Geolocation { Longitude = 12.492507m, Latitude = 41.889938m };
contextOptions.Permissions = new[] { ContextPermission.Geolocation };
contextOptions.IgnoreHTTPSErrors = true;
var context = await browser.NewContextAsync(contextOptions);
await context.ClearCookiesAsync();

var page = await context.NewPageAsync();
page.DefaultNavigationTimeout = 15000;
page.DefaultTimeout = 15000;
var response = await _page.GoToAsync(..., LifecycleEvent.Load, 15000);

Error:

PlaywrightSharp.TargetClosedException: Protocol error (Browser.enable): Browser closed.
==================== Browser output: ====================
<launching> C:\Users\abc\AppData\Local\ms-playwright\firefox-1221\firefox\firefox.exe -no-remote -headless -profile C:\Users\abc\AppData\Local\Temp\playwright_firefoxdev_profile-M08Ucd -juggler-pipe -silent
<launched> pid=52144
[err] *** You are running in headless mode.
[out] 
[out] Juggler listening to the pipe
[out] console.warn: SearchSettings: "get: No settings file exists, new profile?" (new Error("", "(unknown module)"))
[err] JavaScript error: resource://gre/modules/XULStore.jsm, line 66: Error: Can't find profile directory.
[err] 
[err] ###!!! [Child][MessageChannel] Error: (msgtype=0x3A0147,name=PContent::Msg_AsyncMessage) Channel closing: too late to send/recv, messages will be lost
[err] 
[err] JavaScript error: resource://activity-stream/lib/ASRouterNewTabHook.jsm, line 61: TypeError: this._router is null
[out] console.error: Region.jsm: "Error fetching region" (new TypeError("NetworkError when attempting to fetch resource.", "chrome://juggler/content/NetworkObserver.js", 421))
[out] console.error: Region.jsm: "Failed to fetch region" (new Error("NO_RESULT", "resource://gre/modules/Region.jsm", 376))
<process did exit: exitCode=0, signal=null>
=========================== logs ===========================
<launching> C:\Users\abc\AppData\Local\ms-playwright\firefox-1221\firefox\firefox.exe -no-remote -headless -profile C:\Users\abc\AppData\Local\Temp\playwright_firefoxdev_profile-M08Ucd -juggler-pipe -silent
<launched> pid=52144
[err] *** You are running in headless mode.
[out] 
[out] Juggler listening to the pipe
[out] console.warn: SearchSettings: "get: No settings file exists, new profile?" (new Error("", "(unknown module)"))
[err] JavaScript error: resource://gre/modules/XULStore.jsm, line 66: Error: Can't find profile directory.
[err] 
[err] ###!!! [Child][MessageChannel] Error: (msgtype=0x3A0147,name=PContent::Msg_AsyncMessage) Channel closing: too late to send/recv, messages will be lost
[err] 
[err] JavaScript error: resource://activity-stream/lib/ASRouterNewTabHook.jsm, line 61: TypeError: this._router is null
[out] console.error: Region.jsm: "Error fetching region" (new TypeError("NetworkError when attempting to fetch resource.", "chrome://juggler/content/NetworkObserver.js", 421))
[out] console.error: Region.jsm: "Failed to fetch region" (new Error("NO_RESULT", "resource://gre/modules/Region.jsm", 376))
<process did exit: exitCode=0, signal=null>
============================================================
Note: use DEBUG=pw:api environment variable and rerun to capture Playwright logs.
   at PlaywrightSharp.Transport.Connection.SendMessageToServerAsync[T](String guid, String method, Object args, Boolean ignoreNullValues, JsonSerializerOptions serializerOptions, Boolean treatErrorPropertyAsError) in /home/runner/work/playwright-sharp/playwright-sharp/src/PlaywrightSharp/Transport/Connection.cs:line 163
   at PlaywrightSharp.BrowserType.LaunchAsync(LaunchOptions options) in /home/runner/work/playwright-sharp/playwright-sharp/src/PlaywrightSharp/BrowserType.cs:line 102

machine 1:

OS Name             : Microsoft Windows Server 2019 Standard
OS Version          : 10.0.17763 N/A Build 17763
OS Manufacturer     : Microsoft Corporation
OS Configuration    : Standalone Server
OS Build Type       : Multiprocessor Free
System Boot Time    : 1/13/2021, 5:06:02 PM
System Manufacturer : Supermicro
System Model        : Super Server
System Type         : x64-based PC
System Directory    : C:\Windows\system32
System Locale       : en-us;English (United States)

machine 2:

OS Name             : Microsoft Windows 10 Pro
OS Version          : 10.0.19042 N/A Build 19042
OS Manufacturer     : Microsoft Corporation
OS Configuration    : Standalone Workstation
OS Build Type       : Multiprocessor Free
System Boot Time    : 2021-01-13, 02:05:39
System Manufacturer : Dell Inc.
System Model        : XPS 15 9560
System Type         : x64-based PC
System Directory    : C:\WINDOWS\system32
System Locale       : pl;Polish

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:11 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
pavelfeldmancommented, Jun 5, 2021

Could you please verify that it works in https://www.nuget.org/packages/Microsoft.Playwright/1.12.0-alpha-4 and file an issue + link this one if it does not?

1reaction
MaxBexcommented, Feb 6, 2021

Getting exact same error. Is there any resolution?

I’ve solved by come back at the V. 0.170.2, is working as usual for me.

Read more comments on GitHub >

github_iconTop Results From Across the Web

protocol error / Browser closed · Issue #1101 · microsoft ...
I get an error trying to invoke LaunchAsync on Firefox browser on production Windows Server 2019 (machine 1) while it's working fine on ......
Read more >
How To Fix "Network Protocol Error" On Mozilla Firefox
Method 1: To fix "Network Protocol Error" or "Corrupted Content Error", you need to reload the webpage while bypassing the cache. To do...
Read more >
firefox browser does not start in playwright
I discovered this when I downgraded playwright to version 1.9 and ran the the code then this was the error msg:
Read more >
Fix Firefox Network Protocol Error on Windows PC [Tutorial]
Your browser can't play this video. Learn more.
Read more >
Firefox has experienced a network protocol violation that ...
Firefox has experienced a network protocol violation that cannot be repaired. The page you are trying to view cannot be shown because an...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found