Prerender.io抛出套接字错误

时间:2016-04-13 08:46:40

标签: angularjs sockets prerender

我一直在努力让prerender.io工作一周,我尝试了一切,但没有任何效果。

我有一个节点服务器:

'use strict';
var path = require('path');
var _ = require('lodash');
var express = require('express');
var app = module.exports = express();

var prerender = require('prerender-node')
   .set('prerenderToken', 'My Key');

// These search engine bot do not adheres to google's _escaped_fragment_
// proposal, so we use user agent to detect them.
var moreCrawlerUserAgents = [
  'Slurp!',
  'MSNBot',
  'YoudaoBot',
  'JikeSpider',
  'Sosospider',
  '360Spider',
  'Sogou web spider',
  'Sogou inst spider',
  'baiduspider',
  'facebookexternalhit',
  'twitterbot',
  'rogerbot',
  'linkedinbot',
  'embedly',
  'quora link preview',
  'showyoubot',
  'outbrain',
  'pinterest',
  'developers.google.com/+/web/snippet',
  'slackbot',
  'vkShare',
  'W3C_Validator',
  'redditbot'
];
prerender.set('crawlerUserAgents', _.union(
  prerender.crawlerUserAgents, moreCrawlerUserAgents));
app.use(prerender);

var options = {
  maxAge: '60d',
   setHeaders: function(res, path, stat) {
    // Webfonts need to have CORS * set in order to work.
    if (path.match(/ttf|woff|woff2|eot|svg/ig)) {
      res.set('Access-Control-Allow-Origin', '*');
    }
  }
};

var dist_path = '/client/dist/';

app.use(express.static(path.join(__dirname, dist_path), options));

app.use(function(req, res) {
    res.sendFile(path.join(__dirname + dist_path + '/index.html'));
});
var port = process.env.PORT || 8000; 
app.listen(port, '0.0.0.0');
console.log("Listening on port " + port);

它工作正常,直到我将_escaped_fragment_ =作为查询字符串参数传递,然后它抛出这两个错误:

Error: getaddrinfo EMFILE
   at Object.exports._errnoException (util.js:746:11)
   at errnoException (dns.js:49:15)
   at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:94:26)

OR

Error: socket hang up
   at createHangUpError (_http_client.js:215:15)
   at Socket.socketOnEnd (_http_client.js:300:23)
   at Socket.emit (events.js:129:20)
   at _stream_readable.js:908:16
   at process._tickCallback (node.js:355:11)

我不知道问题是什么,请帮忙!

感谢。

0 个答案:

没有答案