puppeteer: chromium hangs on newPage(). Inspector.targetCrashed from php shell_exec() but fine from console cmd

When running puppeteer from the console command line it works fine, but if I run it from a shell_exec() in php (running as IUSR), puppeteer just hangs after calling browser.newPage(); The chromium instances just sit running in task manager and have to be killed manually to return control to the php page. The only common denominator seems to be the OS version being a server variety… on windows 10 pro x64, it runs fine from shell_exec() (also running as IUSR).

The debug output seems to show Inspector.targetCrashed message being received on the problematic system…

Windows Server 2008R2 (x64) IIS 6.1 PHP 7.0.21 (x86) nodejs 8.9.0 puppeteer 0.12

test.js const puppeteer = require('puppeteer'); (async () => { const browser = await puppeteer.launch(); const page = await browser.newPage(); await browser.close(); })(); test.php die(shell_exec('node test.js'));

debug output [0]Thu, 02 Nov 2017 18:57:08 GMT puppeteer:browser browser.newPage() [1]Thu, 02 Nov 2017 18:57:08 GMT puppeteer:protocol SEND ► {"id":1,"method":"Target.createTarget","params":{"url":"about:blank"}} [2]Thu, 02 Nov 2017 18:57:08 GMT puppeteer:protocol ◀ RECV {"id":1,"result":{"targetId":"(CD00D0CE54AB8E4CFB8A6F69108DA54B)"}} [3]Thu, 02 Nov 2017 18:57:08 GMT puppeteer:protocol SEND ► {"id":2,"method":"Target.attachToTarget","params":{"targetId":"(CD00D0CE54AB8E4CFB8A6F69108DA54B)"}} [4]Thu, 02 Nov 2017 18:57:08 GMT puppeteer:protocol ◀ RECV {"method":"Target.attachedToTarget","params":{"sessionId":"(CD00D0CE54AB8E4CFB8A6F69108DA54B):1","targetInfo":{"targetId":"(CD00D0CE54AB8E4CFB8A6F69108DA54B)","type":"page","title":"","url":"about:blank","attached":true},"waitingForDebugger":false}} [5]Thu, 02 Nov 2017 18:57:08 GMT puppeteer:protocol ◀ RECV {"id":2,"result":{"sessionId":"(CD00D0CE54AB8E4CFB8A6F69108DA54B):1"}} [6]Thu, 02 Nov 2017 18:57:08 GMT puppeteer:session SEND ► {"id":1,"method":"Network.enable","params":{}} [7]Thu, 02 Nov 2017 18:57:08 GMT puppeteer:protocol SEND ► {"id":3,"method":"Target.sendMessageToTarget","params":{"sessionId":"(CD00D0CE54AB8E4CFB8A6F69108DA54B):1","message":"{\"id\":1,\"method\":\"Network.enable\",\"params\":{}}"}} [8]Thu, 02 Nov 2017 18:57:08 GMT puppeteer:session SEND ► {"id":2,"method":"Page.enable","params":{}} [9]Thu, 02 Nov 2017 18:57:08 GMT puppeteer:protocol SEND ► {"id":4,"method":"Target.sendMessageToTarget","params":{"sessionId":"(CD00D0CE54AB8E4CFB8A6F69108DA54B):1","message":"{\"id\":2,\"method\":\"Page.enable\",\"params\":{}}"}} [10]Thu, 02 Nov 2017 18:57:08 GMT puppeteer:session SEND ► {"id":3,"method":"Runtime.enable","params":{}} [11]Thu, 02 Nov 2017 18:57:08 GMT puppeteer:protocol SEND ► {"id":5,"method":"Target.sendMessageToTarget","params":{"sessionId":"(CD00D0CE54AB8E4CFB8A6F69108DA54B):1","message":"{\"id\":3,\"method\":\"Runtime.enable\",\"params\":{}}"}} [12]Thu, 02 Nov 2017 18:57:08 GMT puppeteer:session SEND ► {"id":4,"method":"Security.enable","params":{}} [13]Thu, 02 Nov 2017 18:57:08 GMT puppeteer:protocol SEND ► {"id":6,"method":"Target.sendMessageToTarget","params":{"sessionId":"(CD00D0CE54AB8E4CFB8A6F69108DA54B):1","message":"{\"id\":4,\"method\":\"Security.enable\",\"params\":{}}"}} [14]Thu, 02 Nov 2017 18:57:08 GMT puppeteer:session SEND ► {"id":5,"method":"Performance.enable","params":{}} [15]Thu, 02 Nov 2017 18:57:08 GMT puppeteer:protocol SEND ► {"id":7,"method":"Target.sendMessageToTarget","params":{"sessionId":"(CD00D0CE54AB8E4CFB8A6F69108DA54B):1","message":"{\"id\":5,\"method\":\"Performance.enable\",\"params\":{}}"}} [16]Thu, 02 Nov 2017 18:57:08 GMT puppeteer:protocol ◀ RECV {"method":"Target.receivedMessageFromTarget","params":{"sessionId":"(CD00D0CE54AB8E4CFB8A6F69108DA54B):1","message":"{\"method\":\"Inspector.targetCrashed\",\"params\":{}}","targetId":"(CD00D0CE54AB8E4CFB8A6F69108DA54B)"}} [17]Thu, 02 Nov 2017 18:57:08 GMT puppeteer:session ◀ RECV {"method":"Inspector.targetCrashed","params":{}} [18]Thu, 02 Nov 2017 18:57:08 GMT puppeteer:protocol ◀ RECV {"id":3,"result":{}} [19]Thu, 02 Nov 2017 18:57:08 GMT puppeteer:protocol ◀ RECV {"id":4,"result":{}} [20]Thu, 02 Nov 2017 18:57:08 GMT puppeteer:protocol ◀ RECV {"id":5,"result":{}} [21]Thu, 02 Nov 2017 18:57:08 GMT puppeteer:protocol ◀ RECV {"method":"Target.receivedMessageFromTarget","params":{"sessionId":"(CD00D0CE54AB8E4CFB8A6F69108DA54B):1","message":"{\"method\":\"Security.securityStateChanged\",\"params\":{\"securityState\":\"neutral\",\"schemeIsCryptographic\":false,\"explanations\":[],\"insecureContentStatus\":{\"ranMixedContent\":false,\"displayedMixedContent\":false,\"containedMixedForm\":false,\"ranContentWithCertErrors\":false,\"displayedContentWithCertErrors\":false,\"ranInsecureContentStyle\":\"unknown\",\"displayedInsecureContentStyle\":\"unknown\"},\"summary\":\"\"}}","targetId":"(CD00D0CE54AB8E4CFB8A6F69108DA54B)"}} [22]Thu, 02 Nov 2017 18:57:08 GMT puppeteer:session ◀ RECV {"method":"Security.securityStateChanged","params":{"securityState":"neutral","schemeIsCryptographic":false,"explanations":[],"insecureContentStatus":{"ranMixedContent":false,"displayedMixedContent":false,"containedMixedForm":false,"ranContentWithCertErrors":false,"displayedContentWithCertErrors":false,"ranInsecureContentStyle":"unknown","displayedInsecureContentStyle":"unknown"},"summary":""}} [23]Thu, 02 Nov 2017 18:57:08 GMT puppeteer:protocol ◀ RECV {"method":"Target.receivedMessageFromTarget","params":{"sessionId":"(CD00D0CE54AB8E4CFB8A6F69108DA54B):1","message":"{\"id\":4,\"result\":{}}","targetId":"(CD00D0CE54AB8E4CFB8A6F69108DA54B)"}} [24]Thu, 02 Nov 2017 18:57:08 GMT puppeteer:session ◀ RECV {"id":4,"result":{}} [25]Thu, 02 Nov 2017 18:57:08 GMT puppeteer:protocol ◀ RECV {"id":6,"result":{}} [26]Thu, 02 Nov 2017 18:57:08 GMT puppeteer:protocol ◀ RECV {"id":7,"result":{}}

I’m so close to using this awesome node module to solve some project problems but i just have this last issue to figure out. Any help would be greatly appreciated.

Thanks!

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 21 (7 by maintainers)

Most upvoted comments

In case anyone is still working through this, another thing that might be worth trying is to set pipe: true in the puppeteer launch configuration. That forces puppeteer to communicate with the browser over a pipe connection rather than WebSocket. Given the lack of formal WebSocket support in IIS versions prior to 8, the IIS process seems to be limited in how it can connect to Chrome/Chromium.

Below is what a colleague and I had to do to avoid issues with browser.newPage() in a similar environment (IIS7 on Windows Server 2008R2; Node 8.11.0 with IISNode)

const browser = await puppeteer.launch({
  pipe: true, // connect to browser via pipe rather than WebSocket, per docs
  args: [
    '--disable-gpu',
    '--no-sandbox',
    '--disable-extensions'
  ]
})
const page = await browser.newPage()

Also, I’m no IIS expert beyond fairly standard configuration scenarios, so my mode of thinking regarding WebSocket support may not be entirely correct, but I do know that pipe: true did the trick in our case, so hopefully this provides some help.