Search code examples
prerender

Prerender does not return a page response


Long story short:

  1. Server OS got updated, which broke my virtualenv's. Before this everything worked just fine.
  2. Reinstalled the environment.
  3. Tried to fire up Prerender.io middleware with the following env variables (usually run by supervisor, now tried manually):

`

export PORT=35292
export PRERENDER_SERVICE_URL='http://localhost:35292/'
export PHANTOMJS_PORT=35294
export PHANTOM_CLUSTER_NUM_WORKERS=5
export PHANTOM_WORKER_ITERATIONS=10
export CACHE_ROOT_DIR="/home/users/jz/snapshot-env/prerender/filecache/"
export CACHE_LIVE_TIME=7200
PHANTOM_CLUSTER_MESSAGE_TIMEOUT=800

`

  1. Set up the demo server demoserver.js:

`

#!/usr/bin/env node
var prerender = require('./lib');

var server = prerender({
    workers: process.env.PRERENDER_NUM_WORKERS,
    iterations: process.env.PRERENDER_NUM_ITERATIONS
});


//server.use(prerender.sendPrerenderHeader());
// server.use(prerender.basicAuth());
// server.use(prerender.whitelist());
server.use(prerender.blacklist());
// server.use(prerender.logger());
server.use(prerender.removeScriptTags());
server.use(prerender.httpHeaders());
// server.use(prerender.inMemoryHtmlCache());
// server.use(prerender.s3HtmlCache());

server.start();

`

  1. Server starts:

`

$ node demoserver.js 
2016-05-24T01:41:35.814Z starting worker thread #0
2016-05-24T01:41:35.832Z starting worker thread #1
2016-05-24T01:41:35.839Z starting worker thread #2
2016-05-24T01:41:35.842Z starting worker thread #3
2016-05-24T01:41:35.844Z starting worker thread #4
2016-05-24T01:41:36.120Z starting phantom...
2016-05-24T01:41:36.132Z Server running on port 35292
2016-05-24T01:41:36.135Z starting phantom...
2016-05-24T01:41:36.146Z starting phantom...
2016-05-24T01:41:36.152Z Server running on port 35292
2016-05-24T01:41:36.153Z starting phantom...
2016-05-24T01:41:36.160Z Server running on port 35292
2016-05-24T01:41:36.170Z Server running on port 35292
2016-05-24T01:41:36.176Z starting phantom...
2016-05-24T01:41:36.190Z Server running on port 35292
Fontconfig warning: ignoring UTF-8: not a valid region tag
Fontconfig warning: ignoring UTF-8: not a valid region tag
Fontconfig warning: ignoring UTF-8: not a valid region tag
Fontconfig warning: ignoring UTF-8: not a valid region tag
Fontconfig warning: ignoring UTF-8: not a valid region tag

`

  1. Try to access the server locally:

$ lynx http://localhost:35292/http://google.com

I see it tries to fetch the page, but no response: HTTP request sent; waiting for response.

On the server log I see it has received the request:

2016-05-24T01:53:42.449Z getting http://google.com/

After that no entries and no action. I see prerender has indeed spawned several phantomjs processes, but for some reason nothing happens.

Any ideas how to debug this further to see why phantomjs is not processing or returning the request?

Edit: npm install output here - don't see anything fishy.

(snapshot-env)jz@lakka:~/snapshot-env/prerender$ uname -a
Linux lakka 3.14.66-grbfs-kapsi #1 SMP Sat Apr 16 10:30:24 EEST 2016 x86_64 GNU/Linux


(snapshot-env)jz@lakka:~/snapshot-env/prerender$ cat /etc/*release
PRETTY_NAME="Debian GNU/Linux 8 (jessie)"
NAME="Debian GNU/Linux"
VERSION_ID="8"
VERSION="8 (jessie)"
ID=debian
HOME_URL="http://www.debian.org/"
SUPPORT_URL="http://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"

Node version:

jz@lakka:~$ cd snapshot-env;source bin/activate
(snapshot-env)jz@lakka:~/snapshot-env$ node -v
v6.2.0

Solution

  • hey I have this problem before, I fixed by these commands

    1. Downgrade to node 4.x

    sudo apt-get purge nodejs
    curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash -
    sudo apt-get install nodejs
    

    2. Fix the issue: Fontconfig warning: ignoring UTF-8: not a valid region tag

    export LANGUAGE=en_US.UTF-8
    export LANG=en_US.UTF-8
    export LC_ALL=en_US.UTF-8
    locale-gen en_US.UTF-8
    

    That's it. Hopefully, it can help you.

    I reinstall the service and I wrote a blog showing the flows

    check it out http://ccaloha.cc/blog/2016/06/22/how-to-install-preloader-dot-io-service-in-ubuntu-14-dot-04/