Skip to content
This repository has been archived by the owner on May 30, 2023. It is now read-only.

Operation canceled on some pages #12750

Closed
Guigoz opened this issue Nov 17, 2014 · 106 comments
Closed

Operation canceled on some pages #12750

Guigoz opened this issue Nov 17, 2014 · 106 comments

Comments

@Guigoz
Copy link

Guigoz commented Nov 17, 2014

Hello,

I'm experiencing some issues with phantomJS when trying to render some Urls.
It works well for 99% of the requested urls but some are not working and i'm getting the "Operation canceled" error.

To reproduce the error you can use this simple script :

var webPage = require('webpage');
var page = webPage.create();

page.viewportSize = { width: 1920, height: 1080 };
page.open("http://www.thalesgroup.com", function start(status) {
  page.render('screenshot.jpeg', {format: 'jpeg', quality: '100'});
  phantom.exit();
});

It will produce the following result.

phantomjs-1.9.8-linux-x86_64/bin/phantomjs --debug=true --ignore-ssl-errors=yes --web-security=no --ssl-protocol=any simpleRender.js 
2014-11-17T15:18:32 [DEBUG] CookieJar - Created but will not store cookies (use option '--cookies-file=<filename>' to enable persisten cookie storage) 
2014-11-17T15:18:32 [DEBUG] Phantom - execute: Configuration 
2014-11-17T15:18:32 [DEBUG]      0 objectName : "" 
2014-11-17T15:18:32 [DEBUG]      1 cookiesFile : "" 
2014-11-17T15:18:32 [DEBUG]      2 diskCacheEnabled : "false" 
2014-11-17T15:18:32 [DEBUG]      3 maxDiskCacheSize : "-1" 
2014-11-17T15:18:32 [DEBUG]      4 ignoreSslErrors : "true" 
2014-11-17T15:18:32 [DEBUG]      5 localToRemoteUrlAccessEnabled : "false" 
2014-11-17T15:18:32 [DEBUG]      6 outputEncoding : "UTF-8" 
2014-11-17T15:18:32 [DEBUG]      7 proxyType : "http" 
2014-11-17T15:18:32 [DEBUG]      8 proxy : ":1080" 
2014-11-17T15:18:32 [DEBUG]      9 proxyAuth : ":" 
2014-11-17T15:18:32 [DEBUG]      10 scriptEncoding : "UTF-8" 
2014-11-17T15:18:32 [DEBUG]      11 webSecurityEnabled : "false" 
2014-11-17T15:18:32 [DEBUG]      12 offlineStoragePath : "" 
2014-11-17T15:18:32 [DEBUG]      13 offlineStorageDefaultQuota : "-1" 
2014-11-17T15:18:32 [DEBUG]      14 printDebugMessages : "true" 
2014-11-17T15:18:32 [DEBUG]      15 javascriptCanOpenWindows : "true" 
2014-11-17T15:18:32 [DEBUG]      16 javascriptCanCloseWindows : "true" 
2014-11-17T15:18:32 [DEBUG]      17 sslProtocol : "any" 
2014-11-17T15:18:32 [DEBUG]      18 sslCertificatesPath : "" 
2014-11-17T15:18:32 [DEBUG]      19 webdriver : ":" 
2014-11-17T15:18:32 [DEBUG]      20 webdriverLogFile : "" 
2014-11-17T15:18:32 [DEBUG]      21 webdriverLogLevel : "INFO" 
2014-11-17T15:18:32 [DEBUG]      22 webdriverSeleniumGridHub : "" 
2014-11-17T15:18:32 [DEBUG] Phantom - execute: Script & Arguments 
2014-11-17T15:18:32 [DEBUG]      script: "simpleRender.js" 
2014-11-17T15:18:32 [DEBUG] Phantom - execute: Starting normal mode 
2014-11-17T15:18:32 [DEBUG] WebPage - setupFrame "" 
2014-11-17T15:18:32 [DEBUG] FileSystem - _open: ":/modules/fs.js" QMap(("mode", QVariant(QString, "r") ) )  
2014-11-17T15:18:32 [DEBUG] FileSystem - _open: ":/modules/system.js" QMap(("mode", QVariant(QString, "r") ) )  
2014-11-17T15:18:32 [DEBUG] FileSystem - _open: ":/modules/_coffee-script.js" QMap(("mode", QVariant(QString, "r") ) )  
2014-11-17T15:18:32 [DEBUG] FileSystem - _open: ":/modules/../coffee-script/package.json" QMap(("mode", QVariant(QString, "r") ) )  
2014-11-17T15:18:32 [DEBUG] FileSystem - _open: ":/modules/../coffee-script/./lib/coffee-script/coffee-script.js" QMap(("mode", QVariant(QString, "r") ) )  
2014-11-17T15:18:32 [DEBUG] FileSystem - _open: ":/modules/../coffee-script/./lib/coffee-script/./lexer.js" QMap(("mode", QVariant(QString, "r") ) )  
2014-11-17T15:18:32 [DEBUG] FileSystem - _open: ":/modules/../coffee-script/./lib/coffee-script/././rewriter.js" QMap(("mode", QVariant(QString, "r") ) )  
2014-11-17T15:18:32 [DEBUG] FileSystem - _open: ":/modules/../coffee-script/./lib/coffee-script/././helpers.js" QMap(("mode", QVariant(QString, "r") ) )  
2014-11-17T15:18:32 [DEBUG] FileSystem - _open: ":/modules/../coffee-script/./lib/coffee-script/./parser.js" QMap(("mode", QVariant(QString, "r") ) )  
2014-11-17T15:18:32 [DEBUG] FileSystem - _open: ":/modules/../coffee-script/./lib/coffee-script/./helpers.js" QMap(("mode", QVariant(QString, "r") ) )  
2014-11-17T15:18:32 [DEBUG] FileSystem - _open: ":/modules/../coffee-script/./lib/coffee-script/./nodes.js" QMap(("mode", QVariant(QString, "r") ) )  
2014-11-17T15:18:32 [DEBUG] FileSystem - _open: ":/modules/../coffee-script/./lib/coffee-script/././scope.js" QMap(("mode", QVariant(QString, "r") ) )  
2014-11-17T15:18:32 [DEBUG] FileSystem - _open: ":/modules/../coffee-script/./lib/coffee-script/./././helpers.js" QMap(("mode", QVariant(QString, "r") ) )  
2014-11-17T15:18:32 [DEBUG] FileSystem - _open: ":/modules/../coffee-script/./lib/coffee-script/././lexer.js" QMap(("mode", QVariant(QString, "r") ) )  
2014-11-17T15:18:32 [DEBUG] FileSystem - _open: ":/modules/../coffee-script/./lib/coffee-script/./././rewriter.js" QMap(("mode", QVariant(QString, "r") ) )  
2014-11-17T15:18:32 [DEBUG] FileSystem - _open: ":/modules/webpage.js" QMap(("mode", QVariant(QString, "r") ) )  
2014-11-17T15:18:32 [DEBUG] WebPage - updateLoadingProgress: 10 
2014-11-17T15:18:35 [DEBUG] WebPage - updateLoadingProgress: 16 
2014-11-17T15:18:35 [DEBUG] WebPage - updateLoadingProgress: 19 
2014-11-17T15:18:35 [DEBUG] WebPage - updateLoadingProgress: 21 
2014-11-17T15:18:35 [DEBUG] WebPage - updateLoadingProgress: 27 
2014-11-17T15:18:35 [DEBUG] WebPage - updateLoadingProgress: 31 
2014-11-17T15:18:35 [DEBUG] WebPage - updateLoadingProgress: 37 
2014-11-17T15:18:35 [DEBUG] WebPage - updateLoadingProgress: 40 
2014-11-17T15:18:35 [DEBUG] WebPage - updateLoadingProgress: 42 
2014-11-17T15:18:35 [DEBUG] WebPage - setupFrame "" 
2014-11-17T15:18:35 [DEBUG] CookieJar - Saved "has_js=1; domain=www.thalesgroup.com; path=/" 
2014-11-17T15:18:36 [DEBUG] WebPage - updateLoadingProgress: 45 
2014-11-17T15:18:36 [DEBUG] CookieJar - Saved "has_js=1; domain=www.thalesgroup.com; path=/" 
2014-11-17T15:18:36 [DEBUG] CookieJar - Saved "context_breakpoints=none; domain=www.thalesgroup.com; path=/" 
2014-11-17T15:18:36 [DEBUG] WebPage - updateLoadingProgress: 100 
2014-11-17T15:18:36 [DEBUG] Network - Resource request error: 5 ( "Operation canceled" ) URL: "https://secure.leadforensics.com/Track/Capture.aspx?trk_user=26055&trk_sw=1024&trk_sh=768&trk_ref=&trk_tit=Thales Group&trk_loc=https://www.thalesgroup.com/en&trk_agn=Netscape&trk_agv=Mozilla/5.0 (Unknown; Linux x86_64) AppleWebKit/534.34 (KHTML, like Gecko) PhantomJS/1.9.8 Safari/534.34.lfcd32.lflngfr-FR&trk_dom=www.thalesgroup.com&trk_guid=1e390c06-f5a3-41e8-bc51-d4a46952b54e&trk_cookie=NA" 
2014-11-17T15:18:36 [DEBUG] Network - Resource request error: 5 ( "Operation canceled" ) URL: "https://www.google-analytics.com/analytics.js" 
2014-11-17T15:18:36 [DEBUG] Network - Resource request error: 5 ( "Operation canceled" ) URL: "https://www.thalesgroup.com/sites/default/files/js/js_3gTGsabd1RPSpnBDnrFkHoY_7DsRs04arZaXhxjiyHY.js" 
2014-11-17T15:18:36 [DEBUG] WebPage - updateLoadingProgress: 10 
2014-11-17T15:18:36 [DEBUG] WebPage - setupFrame "" 
2014-11-17T15:18:36 [DEBUG] FileSystem - _open: ":/modules/fs.js" QMap(("mode", QVariant(QString, "r") ) )  
2014-11-17T15:18:36 [DEBUG] FileSystem - _open: ":/modules/system.js" QMap(("mode", QVariant(QString, "r") ) )  
2014-11-17T15:18:36 [DEBUG] FileSystem - _open: ":/modules/_coffee-script.js" QMap(("mode", QVariant(QString, "r") ) )  
2014-11-17T15:18:36 [DEBUG] FileSystem - _open: ":/modules/webpage.js" QMap(("mode", QVariant(QString, "r") ) )  
2014-11-17T15:18:36 [DEBUG] WebPage - updateLoadingProgress: 10 
2014-11-17T15:18:36 [DEBUG] WebPage - setupFrame "" 
2014-11-17T15:18:36 [DEBUG] FileSystem - _open: ":/modules/fs.js" QMap(("mode", QVariant(QString, "r") ) )  
2014-11-17T15:18:36 [DEBUG] FileSystem - _open: ":/modules/system.js" QMap(("mode", QVariant(QString, "r") ) )  
2014-11-17T15:18:36 [DEBUG] FileSystem - _open: ":/modules/_coffee-script.js" QMap(("mode", QVariant(QString, "r") ) )  
2014-11-17T15:18:36 [DEBUG] FileSystem - _open: ":/modules/webpage.js" QMap(("mode", QVariant(QString, "r") ) )  
2014-11-17T15:18:36 [DEBUG] WebPage - updateLoadingProgress: 100 
2014-11-17T15:18:36 [DEBUG] WebPage - setupFrame "" 
2014-11-17T15:18:36 [DEBUG] Network - Resource request error: 5 ( "Operation canceled" ) URL: "https://www.thalesgroup.com/en" 
2014-11-17T15:18:36 [DEBUG] WebPage - updateLoadingProgress: 100 
2014-11-17T15:18:36 [DEBUG] WebPage - updateLoadingProgress: 10 
2014-11-17T15:18:36 [DEBUG] WebPage - setupFrame "" 
2014-11-17T15:18:36 [DEBUG] WebPage - updateLoadingProgress: 100 
2014-11-17T15:18:36 [DEBUG] WebPage - setupFrame "" 
2014-11-17T15:18:36 [DEBUG] CookieJar - Purged (session) "context_breakpoints=none; domain=www.thalesgroup.com; path=/" 
2014-11-17T15:18:36 [DEBUG] CookieJar - Purged (session) "has_js=1; domain=www.thalesgroup.com; path=/" 

Thanks for your help.
Guillaume.

@bprodoehl
Copy link

I see the same thing with a build of PhantomJS 2.0. Given the nature of Thales Group, perhaps they just have some safeguards in place against this sort of scraping.

@grooveek
Copy link

That's not some sort of special protection. Curl works just fine with no additional configuration, even the UA String.
Stracing the process didn't gave me any advice. Perhaps someone knows a good way to debug PhantomJS website-related bugs...

@thoop
Copy link

thoop commented Dec 10, 2014

I'm experiencing this as well with Linux x86_64 PhantomJS 1.9.8 and PhantomJS 2.0. It doesn't happen all the time, but I'll get an "Operation canceled" on the request with id === 1.

@vinnitu
Copy link

vinnitu commented Jan 26, 2015

Network - Resource request error: 5 ( "Operation canceled" )
I have such trouble too (dev 2.0.0)

@entrity
Copy link

entrity commented Feb 1, 2015

👍

@maximilianredt
Copy link

same here...

@vinnitu
Copy link

vinnitu commented Feb 5, 2015

I cannot understand what is really trouble? I made simple app on qt5 with Qt5.4 and QWebView and my url loaded successfull.

@tgt
Copy link

tgt commented Apr 24, 2015

I also have the same issue with various websites. For example, http://www.bbc.co.uk/ fails when fetching it through an HTTP proxy, but can be fetched successfully without a proxy.

Is ther any information I can provide that'll help you diagnose the issue?

@arikkfir
Copy link

Happened to me as well. I had a page containing multiple IFRAMEs, and the script attempted a series of requests by clicking links in one IFRAME, causing a refresh on another IFRAME. Each "click" on a link in the menu IFRAME was preceded by a call to "switchToFrame", and then the actual "click" on the link (using page.evaluate).

Once I added a "switchToMainFrame" right after the "page.evaluate", the problem disappeared for me.

@sadasidha
Copy link

Is this issue solved yet? I am getting the same error

@vclteam
Copy link

vclteam commented Oct 30, 2015

i also getting it on some pages

@mattlyons0
Copy link

I am also getting this issue about 50% of the time my script runs. My script deals with a website with around 25 iframes and am using switchToFrame multiple times to get into nested iframes.

Oddly enough the onResourceError url is always a image. However it may be because the website loads mostly images with ajax the the probability of getting another resource is low.

Note, I'm on Arch Linux with phantomJS 2.0

@sadasidha
Copy link

@mattlyons0 Exactly, I am facing the same issue, which is leading me to lots of unnecessary error.

@sintanial
Copy link

I have the same trouble, on many pages. This trouble reproduced on versions: 1.9.8, 2.0.0, 2.0.1-dev.
And sometimes i catch another problem "Segmentation fault" :((

Anybody have idea how to solve this problem ? I suffer 2 weeks with this bugs

@ParthBarot-BoTreeConsulting

Me also facing same issue, it stops at such error Resource request error: 5 ( "Operation canceled" ) URL: "https://www.google-analytics.com/analytics.js"

@apelican
Copy link

I am getting this as well - Phantom 2.0.0 OSX 10.10.5
2015-12-18T16:51:17 [DEBUG] Network - Resource request error: 5 ( "Operation canceled" ) URL: "http://www.google.com/uds/?file=visualization&v=1.0&packages=corechart"

Any advice or feedback?

@harrismaan
Copy link

Hello guys, I am facing similar issues and it seems to be related to redirection, since direct loading of the url works. Any idea why this could be happening?

@Dexus77
Copy link

Dexus77 commented Dec 28, 2015

I have this error - PhantomJS 2.0.0, Centos 7
[DEBUG - 2015-12-28T13:02:29.231Z] Session [3959c460-ad63-11e5-81ae-c570b6e5ae25] - page.onResourceError - {"errorCode":5,"errorString":"Operation canceled","id":57,"status":null,"statusText":null,"url":"https://mc.yandex.ru/webvisor/14067460?rn=398363363&page-url=http%3A%2F%2Fjob.ukr.net%2F&wmode=0&wv-type=0&wv-hit=260517100&wv-part=2&wv-check=3341&browser-info=z%3A120%3Ai%3A20151228150224%3Arqnl%3A1%3Ast%3A1451307749%3Au%3A145130774598162282"}

@listen-lavender
Copy link

any solution with this problem?

@apelican
Copy link

apelican commented Jan 5, 2016

After some tinkering, my root cause was initiating async work after the complete event has been fired. I'm not sure if there's a better time in the lifecycle to try to bring in async resources (I was trying to load Google Charts, since it doesn't allow me to inline the JavaScript library). I wound up setting the page content to include the resource request as a script tag and this issue stopped for me, but your milage and root cause may vary.
My hunch is this is open requests getting killed after the renderer is done.

@tjoneseng
Copy link

I am seeing this when the page loads Javascript through the CloudFront CDN. When Javascript is loaded from the same host I don't get the "operation canceled" errors.

@csman
Copy link

csman commented Feb 19, 2016

I switched from phantomjs 1.9 to 2.1 and I'm getting murdered by this error. No websites work. Zero. Every website dies with this:

2016-02-19T07:41:00 [DEBUG] Network - Resource request error: QNetworkReply::NetworkError(OperationCanceledError) ( "Operation canceled" )

I updated QT to 5.5, same thing. Anyone??

@zackw
Copy link
Collaborator

zackw commented Feb 19, 2016

None of us devs have been able to reproduce this bug. It must be caused by something about the environment in which y'all are running the tests. We are going to need you to tinker with your environment and try to find out what triggers it. Unfortunately, I don't have the least idea what could be the problem.

Please note that PhantomJS is statically linked against Qt (we have to do this, our copy of Qt is nontrivially modified) and therefore upgrading the system copy of Qt will never make anything change. 2.1 is already using Qt 5.5.

@smurf667
Copy link

Hello,

we too have been struggling a lot with this issue. We're on RHEL using PhantomJS 2.1.1. The application is AngularJS-based with require loading lots of modules simultaneously. The problem for us always occurred at startup when one (random) module failed to load due to the cancelled network operation, breaking the app.
I liked the theory put forth by apelican, however when I tried to put a long-loading image request (5s) into the markup it did not help. On the contrary, afterwards I observed complete hangers. So it is probably not the renderer killing pending requests.

However, some observations and a workaround for our case: Not sure where exactly the issue lies, maybe a race condition or a concurrent request overload?
The problem often occurred when running in a setup where Tomcat 7 was serving the app, testing code (Java WebDriver) and hosted app on the same machine.
When configuring an HTTP proxy for the PhantomJS driver with --proxy the problem never occurred (this is our workaround: we a start a Jetty-based HTTP proxy and route all requests through it - we have not seen any aborted requests). We also used the Paros proxy experimentally and did not observe the problem. Either the proxy slows things down sufficiently (if it is a race condition), or the PhantomJS code takes a different non-problematic route for handling requests. The problem also did not occur when we used the simple Python HTTP server to serve the app from the file system (instead of through Tomcat).

We've analysed the logs of the app server and can only conclude that in problem cases the requests never reached the app server.

Hope this helps...

@outboundexplorer
Copy link

I have been struggling with this problem for a little while. I have come up with a bit of a hacky fix, that for the most part seems to be working at the moment.

First of all, i store all of the urls that are causing the resource errors and then causing the operation to be cancelled.

page.onResourceError = function(resourceError){
    // store the urls that caused the resource errors
    errorResources.push(resourceError.url);
};

Next, I have an array of resources that frequently causes resource errors.

// Common resources that cause errors -- note that most of them are analytics and ads
var skipResourcesList = [
   'facebook.com',
   'quantserve',
   'adzerk',
   'doubleclick',
   'adition',
   'exelator',
   'sharethrough',
   'cdn.api.twitter',
   'google-analytics',
   'google.com'
];

Now we can check against these resources as we load them and skip them as necessary. By simply redirecting to my own server, I can return a simple 200 response. From below, you can see that I am actually concatanating skipResourcesList with config.errorResources. The first time that this runs, the config.errorResources will be empty. If however, the page fails and I have a set of resources that were stored because there were resource errors, then the 'errorResources' array can be returned to the program that executed the phantomjs script. If i then pass this in with the config object, I can add this to the resources that are skipped during loading and increase the chance that second time round, the operation will not be cancelled.

page.onResourceRequested = function(requestData, networkRequest){
   
   var regex = new RegExp(skipResourcesList.concat(config.errorResources).join('|'),'i');
   var bypassPing = 'http://to-my-own-server'

   if (requestData.url.match(regex) != null){
      networkRequest.changeUrl(bypassPing);
   }
};

This sure is a very hacky solution to the problem. But it is a solution that has let me move forwards. I hope it might be useful for someone.

@gitariman
Copy link

hi, @vitallium

I ran into the similar issue, and it only happens when I use 2.5 beta version, when I use 2.1 release, everything is good.

the error is something like this:
Network - Resource request error: QNetworkReply::NetworkError(RemoteHostClosedError) ( "Connection closed" ) URL: "https://cm.g.doub...

sorry for that I can't paste more detailed info due to I'm working on a business project.

@MajorChump
Copy link

Currently running into this exact issue. Was happening on 2.1 and I've updated to trial 2.5 and still happening there.

phantomjs -v
2.5.0-development

While running a simple GET on https://getproxylist.com/ the error appears for the following resources:

2017-04-06T00:24:14 [DEBUG] Network - Resource request error: QNetworkReply::NetworkError(OperationCanceledError) ( "Operation canceled" ) URL: "https://getproxylist.com/js/site.js"
2017-04-06T00:24:14 [DEBUG] Network - Resource request error: QNetworkReply::NetworkError(OperationCanceledError) ( "Operation canceled" ) URL: "https://getproxylist.com/images/header-bg.png"

@brad-anton
Copy link

Thanks to @ariya for all the hard work! Still seeing this issue using the latest release (2.1.1) and after compiling the latest commit to the master branch. I used the example site from @marktheunissen to confirm: http://dev-phantom-failure-sample.pantheonsite.io/index.php and netlog.js. Would love to vote up the priority up for this!

$ ./phantomjs -v
2.1.1
$ ./phantomjs --debug=true ../examples/netlog.js "http://dev-phantom-failure-sample.pantheonsite.io/index.php"
2017-04-07T09:47:46 [DEBUG] CookieJar - Created but will not store cookies (use option '--cookies-file=<filename>' to enable persistent cookie storage)
2017-04-07T09:47:47 [DEBUG] Set  "http"  proxy to:  "" : 1080
2017-04-07T09:47:47 [DEBUG] Phantom - execute: Configuration
2017-04-07T09:47:47 [DEBUG]      0 objectName : ""
2017-04-07T09:47:47 [DEBUG]      1 cookiesFile : ""
2017-04-07T09:47:47 [DEBUG]      2 diskCacheEnabled : "false"
2017-04-07T09:47:47 [DEBUG]      3 maxDiskCacheSize : "-1"
2017-04-07T09:47:47 [DEBUG]      4 diskCachePath : ""
2017-04-07T09:47:47 [DEBUG]      5 ignoreSslErrors : "false"
2017-04-07T09:47:47 [DEBUG]      6 localUrlAccessEnabled : "true"
2017-04-07T09:47:47 [DEBUG]      7 localToRemoteUrlAccessEnabled : "false"
2017-04-07T09:47:47 [DEBUG]      8 outputEncoding : "UTF-8"
2017-04-07T09:47:47 [DEBUG]      9 proxyType : "http"
2017-04-07T09:47:47 [DEBUG]      10 proxy : ":1080"
2017-04-07T09:47:47 [DEBUG]      11 proxyAuth : ":"
2017-04-07T09:47:47 [DEBUG]      12 scriptEncoding : "UTF-8"
2017-04-07T09:47:47 [DEBUG]      13 webSecurityEnabled : "true"
2017-04-07T09:47:47 [DEBUG]      14 offlineStoragePath : ""
2017-04-07T09:47:47 [DEBUG]      15 localStoragePath : ""
2017-04-07T09:47:47 [DEBUG]      16 localStorageDefaultQuota : "-1"
2017-04-07T09:47:47 [DEBUG]      17 offlineStorageDefaultQuota : "-1"
2017-04-07T09:47:47 [DEBUG]      18 printDebugMessages : "true"
2017-04-07T09:47:47 [DEBUG]      19 javascriptCanOpenWindows : "true"
2017-04-07T09:47:47 [DEBUG]      20 javascriptCanCloseWindows : "true"
2017-04-07T09:47:47 [DEBUG]      21 sslProtocol : "default"
2017-04-07T09:47:47 [DEBUG]      22 sslCiphers : "ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES128-SHA:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-RC4-SHA:ECDHE-RSA-RC4-SHA:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA:DHE-RSA-AES256-SHA:AES128-GCM-SHA256:AES128-SHA:AES256-SHA:DES-CBC3-SHA:RC4-SHA:RC4-MD5"
2017-04-07T09:47:47 [DEBUG]      23 sslCertificatesPath : ""
2017-04-07T09:47:47 [DEBUG]      24 sslClientCertificateFile : ""
2017-04-07T09:47:47 [DEBUG]      25 sslClientKeyFile : ""
2017-04-07T09:47:47 [DEBUG]      26 sslClientKeyPassphrase : ""
2017-04-07T09:47:47 [DEBUG]      27 webdriver : ":"
2017-04-07T09:47:47 [DEBUG]      28 webdriverLogFile : ""
2017-04-07T09:47:47 [DEBUG]      29 webdriverLogLevel : "INFO"
2017-04-07T09:47:47 [DEBUG]      30 webdriverSeleniumGridHub : ""
2017-04-07T09:47:47 [DEBUG] Phantom - execute: Script & Arguments
2017-04-07T09:47:47 [DEBUG]      script: "../examples/netlog.js"
2017-04-07T09:47:47 [DEBUG]      0 arg: "http://dev-phantom-failure-sample.pantheonsite.io/index.php"
2017-04-07T09:47:47 [DEBUG] Phantom - execute: Starting normal mode
2017-04-07T09:47:47 [DEBUG] WebPage - setupFrame ""
2017-04-07T09:47:47 [DEBUG] FileSystem - _open: ":/modules/fs.js" QMap(("mode", QVariant(QString, "r")))
2017-04-07T09:47:47 [DEBUG] FileSystem - _open: ":/modules/system.js" QMap(("mode", QVariant(QString, "r")))
2017-04-07T09:47:47 [DEBUG] FileSystem - _open: ":/modules/webpage.js" QMap(("mode", QVariant(QString, "r")))
2017-04-07T09:47:47 [DEBUG] WebPage - updateLoadingProgress: 10
requested: {
    "headers": [
        {
            "name": "Accept",
            "value": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"
        },
        {
            "name": "User-Agent",
            "value": "Mozilla/5.0 (Macintosh; Intel Mac OS X) AppleWebKit/538.1 (KHTML, like Gecko) PhantomJS/2.1.1 Safari/538.1"
        }
    ],
    "id": 1,
    "method": "GET",
    "time": "2017-04-07T13:47:47.664Z",
    "url": "http://dev-phantom-failure-sample.pantheonsite.io/index.php"
}
2017-04-07T09:47:48 [DEBUG] CookieJar - Saved "NO_CACHE=1; domain=dev-phantom-failure-sample.pantheonsite.io; path=/"
received: {
    "body": "",
    "bodySize": 177,
    "contentType": "text/html; charset=UTF-8",
    "headers": [
        {
            "name": "Content-Encoding",
            "value": "gzip"
        },
        {
            "name": "Content-Type",
            "value": "text/html; charset=UTF-8"
        },
        {
            "name": "Server",
            "value": "nginx"
        },
        {
            "name": "Set-Cookie",
            "value": "NO_CACHE=1"
        },
        {
            "name": "Surrogate-Key-Raw",
            "value": ""
        },
        {
            "name": "X-Pantheon-Endpoint",
            "value": "88b2a64a-428d-4d22-b8ce-29613a51ed0a"
        },
        {
            "name": "X-Pantheon-Styx-Hostname",
            "value": "styx636a566b"
        },
        {
            "name": "X-Styx-Req-Id",
            "value": "styx-dde2b9122215fc657e2b7f38b1d43de8"
        },
        {
            "name": "X-Styx-Version",
            "value": "StyxGo"
        },
        {
            "name": "Fastly-Debug-Digest",
            "value": "cab4bb0b93cccd65398bdda9e1270dc9518b9dbdce450e32859932383a988f2e"
        },
        {
            "name": "Accept-Ranges",
            "value": "bytes"
        },
        {
            "name": "Date",
            "value": "Fri, 07 Apr 2017 13:47:48 GMT"
        },
        {
            "name": "Via",
            "value": "1.1 varnish, 1.1 varnish"
        },
        {
            "name": "Age",
            "value": "0"
        },
        {
            "name": "Connection",
            "value": "keep-alive"
        },
        {
            "name": "X-Served-By",
            "value": "cache-ord1726-ORD, cache-sjc3623-SJC"
        },
        {
            "name": "X-Cache",
            "value": "MISS, MISS"
        },
        {
            "name": "X-Cache-Hits",
            "value": "0, 0"
        },
        {
            "name": "X-Timer",
            "value": "S1491572868.993328,VS0,VE67"
        },
        {
            "name": "Vary",
            "value": "Accept-Encoding, Cookie, Cookie"
        },
        {
            "name": "Cache-Control",
            "value": "no-cache"
        },
        {
            "name": "X-Robots-Tag",
            "value": "noindex"
        }
    ],
    "id": 1,
    "redirectURL": null,
    "stage": "start",
    "status": 200,
    "statusText": "OK",
    "time": "2017-04-07T13:47:48.172Z",
    "url": "http://dev-phantom-failure-sample.pantheonsite.io/index.php"
}
received: {
    "contentType": "text/html; charset=UTF-8",
    "headers": [
        {
            "name": "Content-Encoding",
            "value": "gzip"
        },
        {
            "name": "Content-Type",
            "value": "text/html; charset=UTF-8"
        },
        {
            "name": "Server",
            "value": "nginx"
        },
        {
            "name": "Set-Cookie",
            "value": "NO_CACHE=1"
        },
        {
            "name": "Surrogate-Key-Raw",
            "value": ""
        },
        {
            "name": "X-Pantheon-Endpoint",
            "value": "88b2a64a-428d-4d22-b8ce-29613a51ed0a"
        },
        {
            "name": "X-Pantheon-Styx-Hostname",
            "value": "styx636a566b"
        },
        {
            "name": "X-Styx-Req-Id",
            "value": "styx-dde2b9122215fc657e2b7f38b1d43de8"
        },
        {
            "name": "X-Styx-Version",
            "value": "StyxGo"
        },
        {
            "name": "Fastly-Debug-Digest",
            "value": "cab4bb0b93cccd65398bdda9e1270dc9518b9dbdce450e32859932383a988f2e"
        },
        {
            "name": "Accept-Ranges",
            "value": "bytes"
        },
        {
            "name": "Date",
            "value": "Fri, 07 Apr 2017 13:47:48 GMT"
        },
        {
            "name": "Via",
            "value": "1.1 varnish, 1.1 varnish"
        },
        {
            "name": "Age",
            "value": "0"
        },
        {
            "name": "Connection",
            "value": "keep-alive"
        },
        {
            "name": "X-Served-By",
            "value": "cache-ord1726-ORD, cache-sjc3623-SJC"
        },
        {
            "name": "X-Cache",
            "value": "MISS, MISS"
        },
        {
            "name": "X-Cache-Hits",
            "value": "0, 0"
        },
        {
            "name": "X-Timer",
            "value": "S1491572868.993328,VS0,VE67"
        },
        {
            "name": "Vary",
            "value": "Accept-Encoding, Cookie, Cookie"
        },
        {
            "name": "Cache-Control",
            "value": "no-cache"
        },
        {
            "name": "X-Robots-Tag",
            "value": "noindex"
        }
    ],
    "id": 1,
    "redirectURL": null,
    "stage": "end",
    "status": 200,
    "statusText": "OK",
    "time": "2017-04-07T13:47:48.173Z",
    "url": "http://dev-phantom-failure-sample.pantheonsite.io/index.php"
}
2017-04-07T09:47:48 [DEBUG] WebPage - updateLoadingProgress: 30
2017-04-07T09:47:48 [DEBUG] WebPage - setupFrame ""
2017-04-07T09:47:48 [DEBUG] WebPage - updateLoadingProgress: 100
2017-04-07T09:47:48 [DEBUG] WebPage - updateLoadingProgress: 10
requested: {
    "headers": [
        {
            "name": "Accept",
            "value": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"
        },
        {
            "name": "Referer",
            "value": "http://dev-phantom-failure-sample.pantheonsite.io/index.php"
        },
        {
            "name": "User-Agent",
            "value": "Mozilla/5.0 (Macintosh; Intel Mac OS X) AppleWebKit/538.1 (KHTML, like Gecko) PhantomJS/2.1.1 Safari/538.1"
        }
    ],
    "id": 2,
    "method": "GET",
    "time": "2017-04-07T13:47:48.175Z",
    "url": "http://dev-phantom-failure-sample.pantheonsite.io/target.php"
}
FAIL to load the address
2017-04-07T09:47:48 [DEBUG] WebPage - setupFrame ""
2017-04-07T09:47:48 [DEBUG] Network - Resource request error: QNetworkReply::NetworkError(OperationCanceledError) ( "Operation canceled" ) URL: "http://dev-phantom-failure-sample.pantheonsite.io/target.php"
received: {
    "contentType": null,
    "headers": [],
    "id": 2,
    "redirectURL": null,
    "stage": "end",
    "status": null,
    "statusText": null,
    "time": "2017-04-07T13:47:48.176Z",
    "url": "http://dev-phantom-failure-sample.pantheonsite.io/target.php"
}
2017-04-07T09:47:48 [DEBUG] WebPage - updateLoadingProgress: 100
2017-04-07T09:47:48 [DEBUG] WebPage - updateLoadingProgress: 10
2017-04-07T09:47:48 [DEBUG] WebPage - setupFrame ""
2017-04-07T09:47:48 [DEBUG] WebPage - updateLoadingProgress: 100
2017-04-07T09:47:48 [DEBUG] WebPage - setupFrame ""
2017-04-07T09:47:48 [DEBUG] FileSystem - _open: ":/modules/fs.js" QMap(("mode", QVariant(QString, "r")))
2017-04-07T09:47:48 [DEBUG] FileSystem - _open: ":/modules/system.js" QMap(("mode", QVariant(QString, "r")))
2017-04-07T09:47:48 [DEBUG] FileSystem - _open: ":/modules/webpage.js" QMap(("mode", QVariant(QString, "r")))
2017-04-07T09:47:48 [DEBUG] WebPage - updateLoadingProgress: 10
2017-04-07T09:47:48 [DEBUG] WebPage - setupFrame ""
2017-04-07T09:47:48 [DEBUG] FileSystem - _open: ":/modules/fs.js" QMap(("mode", QVariant(QString, "r")))
2017-04-07T09:47:48 [DEBUG] FileSystem - _open: ":/modules/system.js" QMap(("mode", QVariant(QString, "r")))
2017-04-07T09:47:48 [DEBUG] FileSystem - _open: ":/modules/webpage.js" QMap(("mode", QVariant(QString, "r")))
2017-04-07T09:47:48 [DEBUG] WebPage - updateLoadingProgress: 100
2017-04-07T09:47:48 [DEBUG] WebPage - setupFrame ""
2017-04-07T09:47:48 [DEBUG] CookieJar - Purged (session) "NO_CACHE=1; domain=dev-phantom-failure-sample.pantheonsite.io; path=/"

@Hoiy
Copy link

Hoiy commented Apr 8, 2017

Inspired by @outboundexplorer ,

Added this '--cookies-file=/tmp/phantom/cookies.txt' to my phantom config and finally able to get status = 'success' for page.open('http://glbn.ca/TImpbv') after probing for a few hours.

It looks like ads provider scripts has strange behaviours if cookies is disabled, which causes all the strange operation canceled in PhantomJS. There are still a lot of script errors after that, but at least it works for me now. Hope this help!

P.S. The first loading would still fail, but second loading and afterwards would be success after cookie is setup (I guess?)

@bluepeter
Copy link

@Hoiy thanks for the suggestion... unfortunately, it still doesn't work for me. I continue to get "Operation canceled" on certain pages.

@ktecho
Copy link

ktecho commented Apr 19, 2017

@Hoiy Thanks a lot. It's not fixed for me either.

@vitallium It happens with 2.5 too.

The problem is that when the bug is triggered, success is not "success". Before I was doing this:

page.open(url, function(success) {
     if(success === "success") {
          // Do a lot of important phantom stuff
     } else {
          // Errors out. Something went wrong.
     }
}

But right now I'm supposing it's always working ok, so:

page.open(url, function(success) {
     if (success != "success") {
          console.log("-----  Not ok, but I'll do my works anyways ----\n");<
     }

     // Do a lot of important phantom stuff anyways
}

@jo-37
Copy link

jo-37 commented Apr 30, 2017

I had the same problem. A simple modification solved it for me. Changed

page.open(url, function(success) {
     if(success === "success") {
        page.render(output);
        phantom.exit();
     } else {
        // Error
     }
}

to

page.open(url, function(success) {
     if(success === "success") {
        window.timeout(function () {
                page.render(output);
                phantom.exit();
        }, 2000);
     } else {
        // Error
     }
}

like it is done in the example script renderize.js. The timeout must be chosen large enough, of course.

@marktheunissen
Copy link

For those looking for alternative solutions, try https://developers.google.com/web/updates/2017/04/headless-chrome

@joshuaostrom
Copy link

I found that the Operation canceled error was an artifact from a page.settings.resourceTimeout that was set too low. Increasing that value resolved the issue.

@tommybutler
Copy link

This bug is also affecting me. bump

@ilsainteractive
Copy link

ilsainteractive commented Nov 22, 2017

i am currently facing this issue and cannot resolve it after reading all of this my output is the following.

2017-11-22T19:39:10 [DEBUG] CookieJar - Created but will not store cookies (use option '--cookies-file=' to enable persistent cookie storage)
2017-11-22T19:39:10 [DEBUG] Set "http" proxy to: "proxy.crawlera.com" : 8010
2017-11-22T19:39:10 [DEBUG] Phantom - execute: Configuration
2017-11-22T19:39:10 [DEBUG] 0 objectName : ""
2017-11-22T19:39:10 [DEBUG] 1 cookiesFile : ""
2017-11-22T19:39:10 [DEBUG] 2 diskCacheEnabled : "false"
2017-11-22T19:39:10 [DEBUG] 3 maxDiskCacheSize : "-1"
2017-11-22T19:39:10 [DEBUG] 4 diskCachePath : ""
2017-11-22T19:39:10 [DEBUG] 5 ignoreSslErrors : "true"
2017-11-22T19:39:10 [DEBUG] 6 localUrlAccessEnabled : "true"
2017-11-22T19:39:10 [DEBUG] 7 localToRemoteUrlAccessEnabled : "false"
2017-11-22T19:39:10 [DEBUG] 8 outputEncoding : "UTF-8"
2017-11-22T19:39:10 [DEBUG] 9 proxyType : "http"
2017-11-22T19:39:10 [DEBUG] 10 proxy : "proxy.crawlera.com:8010"
2017-11-22T19:39:10 [DEBUG] 11 proxyAuth : ":"
2017-11-22T19:39:10 [DEBUG] 12 scriptEncoding : "UTF-8"
2017-11-22T19:39:10 [DEBUG] 13 webSecurityEnabled : "true"
2017-11-22T19:39:10 [DEBUG] 14 offlineStoragePath : ""
2017-11-22T19:39:10 [DEBUG] 15 localStoragePath : ""
2017-11-22T19:39:10 [DEBUG] 16 localStorageDefaultQuota : "-1"
2017-11-22T19:39:10 [DEBUG] 17 offlineStorageDefaultQuota : "-1"
2017-11-22T19:39:10 [DEBUG] 18 printDebugMessages : "true"
2017-11-22T19:39:10 [DEBUG] 19 javascriptCanOpenWindows : "true"
2017-11-22T19:39:10 [DEBUG] 20 javascriptCanCloseWindows : "true"
2017-11-22T19:39:10 [DEBUG] 21 sslProtocol : "any"
2017-11-22T19:39:10 [DEBUG] 22 sslCiphers : "ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES128-SHA:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-RC4-SHA:ECDHE-RSA-RC4-SHA:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA:DHE-RSA-AES256-SHA:AES128-GCM-SHA256:AES128-SHA:AES256-SHA:DES-CBC3-SHA:RC4-SHA:RC4-MD5"
2017-11-22T19:39:10 [DEBUG] 23 sslCertificatesPath : ""
2017-11-22T19:39:10 [DEBUG] 24 sslClientCertificateFile : ""
2017-11-22T19:39:10 [DEBUG] 25 sslClientKeyFile : ""
2017-11-22T19:39:10 [DEBUG] 26 sslClientKeyPassphrase : ""
2017-11-22T19:39:10 [DEBUG] 27 webdriver : ":"
2017-11-22T19:39:10 [DEBUG] 28 webdriverLogFile : ""
2017-11-22T19:39:10 [DEBUG] 29 webdriverLogLevel : "INFO"
2017-11-22T19:39:10 [DEBUG] 30 webdriverSeleniumGridHub : ""
2017-11-22T19:39:10 [DEBUG] Phantom - execute: Script & Arguments
2017-11-22T19:39:10 [DEBUG] script: "/tmp/742460d84df8a9ee3738"
2017-11-22T19:39:10 [DEBUG] Phantom - execute: Starting normal mode
2017-11-22T19:39:10 [DEBUG] WebPage - setupFrame ""
2017-11-22T19:39:10 [DEBUG] FileSystem - _open: ":/modules/fs.js" QMap(("mode", QVariant(QString, "r")))
2017-11-22T19:39:10 [DEBUG] FileSystem - _open: ":/modules/system.js" QMap(("mode", QVariant(QString, "r")))
2017-11-22T19:39:10 [DEBUG] FileSystem - _open: ":/modules/webpage.js" QMap(("mode", QVariant(QString, "r")))
2017-11-22T19:39:10 [DEBUG] WebPage - updateLoadingProgress: 10
2017-11-22T19:39:15 [DEBUG] Network - Resource request error: QNetworkReply::NetworkError(OperationCanceledError) ( "Operation canceled" ) URL: "https://www.google.com.pk/"
2017-11-22T19:39:15 [DEBUG] WebPage - updateLoadingProgress: 100
2017-11-22T19:39:15 [DEBUG] WebPage - evaluateJavaScript "(function() { return (function () {\n \n var styles = {};\n \n for(var property in styles) {\n document.body.style[property] = styles[property];\n }\n})(); })()"
2017-11-22T19:39:15 [DEBUG] WebPage - setupFrame ""
2017-11-22T19:39:15 [DEBUG] WebPage - evaluateJavaScript result QVariant(Invalid)
\n2017-11-22T19:39:15 [DEBUG] WebPage - setupFrame ""
2017-11-22T19:39:15 [DEBUG] WebPage - updateLoadingProgress: 10
2017-11-22T19:39:15 [DEBUG] WebPage - setupFrame ""
2017-11-22T19:39:15 [DEBUG] WebPage - updateLoadingProgress: 100
2017-11-22T19:39:15 [DEBUG] WebPage - setupFrame ""
2017-11-22T19:39:15 [DEBUG] FileSystem - _open: ":/modules/fs.js" QMap(("mode", QVariant(QString, "r")))
2017-11-22T19:39:15 [DEBUG] FileSystem - _open: ":/modules/system.js" QMap(("mode", QVariant(QString, "r")))
2017-11-22T19:39:15 [DEBUG] FileSystem - _open: ":/modules/webpage.js" QMap(("mode", QVariant(QString, "r")))
2017-11-22T19:39:15 [DEBUG] WebPage - updateLoadingProgress: 10
2017-11-22T19:39:15 [DEBUG] WebPage - setupFrame ""
2017-11-22T19:39:15 [DEBUG] FileSystem - _open: ":/modules/fs.js" QMap(("mode", QVariant(QString, "r")))
2017-11-22T19:39:15 [DEBUG] FileSystem - _open: ":/modules/system.js" QMap(("mode", QVariant(QString, "r")))
2017-11-22T19:39:15 [DEBUG] FileSystem - _open: ":/modules/webpage.js" QMap(("mode", QVariant(QString, "r")))
2017-11-22T19:39:15 [DEBUG] WebPage - updateLoadingProgress: 100
2017-11-22T19:39:15 [DEBUG] WebPage - setupFrame ""

@smurf667
Copy link

I would abandon all hope of this getting fixed. Multiple people are reporting the problem, which has been around for a long time. Well. We will be ditching PhantomJS for headless Chrome/Firefox.

@gsouf
Copy link

gsouf commented Nov 22, 2017

For anyone hopping to get it fixed: https://www.infoq.com/news/2017/04/Phantomjs-future-uncertain

@arsenalstudios
Copy link

For what it's worth, this error also shows up if you have an htpassword that isn't being given. If this is your case then passing an auth header should do the trick. Obviously doesn't address the real problems cited above though...

@luongnv89
Copy link

I have faced the same problem when trying to get data from multiple websites. I have fixed that by closing & re-creating the page. This is my source code:

function pageOpenCallback(status) {
    if (status === 'success') {
        console.log('[SUCCESS] Openned page: ' + current_url);
        // DO SOMETHING ON SUCCESS
        // Go to next page
        current_url = get_next_url();
    } else {
        console.log('[ERROR] Cannot open page: ' + current_url);
        // DO SOMETHING ON ERROR
        // Close the page and re-create the page - avoid operation canceled error (5)
        console.log('Going to close the page');
        page.close();
        console.log('Going to re-create the page');
        page = require("webpage").create();
        console.log('The page has been re-created!');
    }     
    page.open(current_url, pageOpenCallback);
}

page.open(current_url, pageOpenCallback);

Hope this help!

@ghost ghost removed this from the Release 2.5 milestone Jan 10, 2018
@ghost ghost removed 1.x labels Jan 10, 2018
@ghost
Copy link

ghost commented Jan 26, 2018

I strongly believe that this is caused by some protection that checks the order of the HTTP headers sent by the browser, and since phantomjs uses QT which has a random/awkward HTTP headers order that we cannot even configure, this fails.
https://www.toysrus.com/ is an example.

@stale
Copy link

stale bot commented Dec 28, 2019

Due to our very limited maintenance capacity (see #14541 for more details), we need to prioritize our development focus on other tasks. Therefore, this issue will be automatically closed. In the future, if we see the need to attend to this issue again, then it will be reopened. Thank you for your contribution!

@stale stale bot closed this as completed Dec 28, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests