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

Getting "Resource request error: QNetworkReply::NetworkError(OperationCanceledError)" infrequently #13806

@Donar23

Description

@Donar23

I'm currently using phantomJS to render HTML pages as images. This works totally fine most of the time but sometimes the rendered page has no text. I've compiled phantomJS myself last week, so I'm able to use Webfonts from typekit and fonts.net, which works fine but every now an then the following error occurs while requesting the font file:

Network - Resource request error: QNetworkReply::NetworkError(OperationCanceledError) ( "Operation canceled" ) URL: "https://fast.fonts.net/someFont"

I looked up this error in the Qt documentation, which states the following:

the operation was canceled via calls to abort() or close() before it was finished.

This gave me the idea, that phantomJS might call abort() or close() for some reason. I'm just not sure why it would call those methods in only 5% of the time.

What I am doing is pretty straight forward:

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

page.onInitialized = function() {
    page.customHeaders = {
        "Accept-Language": "de-DE,de;q=0.8,en-US;q=0.6,en;q=0.4",
        "Cache-Control": "no-cache",
        "Connection": "keep-alive",
        "Pragma": "no-cache",
        "Origin": "https://myDomain.com"
    };
};

page.viewportSize = { width: 1024, height: 768 };

// Old Chrome version without woff2 support
page.settings.userAgent = "Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1866.237 Safari/537.36";

page.open('https://myDomain.com/myFile.html', function (status) 
{
    if(status !== 'success') {
        console.log('Unable to load the address!');
        phantom.exit(1);
    }
    else
    {
        page.clipRect = {top:0, left:0, width: 1024, height: 768};
        page.render('image.jpg', {quality: 100, format: 'jpeg'});
        phantom.exit();
    }   
});

The html file is requested and loads the fonts with Webfontloader. For some reason it seems to load the js and css files from fast.fonts.net but not the fonts (otherwise it wouldn't request the fonts). For typekit it fails loading the p.gif file with a long query string attached (I guess that's some kind of authentification script disguised as an image).

I call the script like this:

phantomjs --ignore-ssl-errors=true --web-security=false script.js

I set web-security to false because the file contains file:/// URLs. I tested it on a local dev server with Debian Wheezy and on an online root server with Debian Jessie. The requested URL has a self signed certificate on the dev server, which is why I ignore ssl errors. On the root server the certificate is valid and I call it without --ignore-ssl-errors. I tried pretty much every other option as well though, but nothing seems to solve the problem. Since it happens infrequently I assumed that it's probably a problem with phantomJS; It's not a realease version after all.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions