Windows Azure Node.js内部服务器错误

Windows Azure Node.js内部服务器错误,node.js,azure,Node.js,Azure,当我点击这个地址时,我会时不时地出现这个错误: 但当我点击刷新时,网站加载正确,一切正常。只有当我离开这个网站几个小时后,我才会回来,也许我会再次看到这个错误,也许不会。这很烦人,因为浏览我的网站的用户认为我的网站坏了,不想点击刷新 所以我的问题是,以前是否有其他人遇到过此类问题,您已经检查了代码,站点加载的所有内容似乎都是正确的,但是Node或IIS节点偶尔会抛出此错误 我的设置如下: 服务器:Windows Azure/网站(共享,2个实例) 语言:Node.js 工具:Webmatrix

当我点击这个地址时,我会时不时地出现这个错误:

但当我点击刷新时,网站加载正确,一切正常。只有当我离开这个网站几个小时后,我才会回来,也许我会再次看到这个错误,也许不会。这很烦人,因为浏览我的网站的用户认为我的网站坏了,不想点击刷新

所以我的问题是,以前是否有其他人遇到过此类问题,您已经检查了代码,站点加载的所有内容似乎都是正确的,但是Node或IIS节点偶尔会抛出此错误

我的设置如下:

服务器:Windows Azure/网站(共享,2个实例) 语言:Node.js 工具:Webmatrix(我使用了一个模板项目启动站点)

最烦人的是我打开了错误消息的日志记录等,而日志记录系统没有发现这个错误,当我去检查我的日志时,当这个错误发生时,没有创建错误日志,所以我还没有找到捕获它的方法。有人有什么建议吗

这就是我的server.js文件的外观:

var express = require('express')
  , connect = require('connect')
  , config = require('./utils/config')
  , observer = require('./utils/observer')
  , cronJob = require('cron').CronJob
  , azure = require('azure')
  , uuid = require('node-uuid')
  , db = require("./utils/database")
  , async = require('async')
  , serialNumbers = require("./utils/serialNumbers");

var app = module.exports = express.createServer();

// Create a cron job to listen for servicebus queue messages
var jobProcessServices = new cronJob({
    cronTime: '*/1 * * * * *',
    onTick: function () {
        observer.processQueue(function () { });
    },
    start: false
});

app.configure(function() { 
    app.set('views', __dirname + '/views');
    app.set('view engine', 'ejs');
    app.set('view options', {
      layout: false
    });
    app.use(express.favicon());
    app.use(express.bodyParser());
    app.use(express.methodOverride());
    app.use(connect.static(__dirname + '/public'));
    app.use(require('./middleware/siteTotals'));
    app.use(require('./middleware/authenticate'));
    app.use(express.cookieParser());
    app.use(express.session({ secret: 'ljklkdsflkfdj4848384' }));
    app.use(app.router);

    // start listening for queue messages
    jobProcessServices.start();
    console.log('starting job service\n\n');

    // create table stores
    var ts1 = azure.createTableService(config.storageAccount, config.storageAccessKey, config.tableHost);

    ts1.createTableIfNotExists('channels', function(error) {
        ts1.createTableIfNotExists('users', function(error) {
            ts1.createTableIfNotExists('snusers', function(error) {
                ts1.createTableIfNotExists('snchannels', function(error) {
                    var query = azure.TableQuery
                        .select()
                        .from('snchannels');

                    ts1.queryEntities(query, function(error, result) {
                        if(error === null && result.length == 0) {
                            // must be site initialization, generate serial numbers for channels and users
                            serialNumbers.generateNewNumbers('snchannels', config.maxNumber, config.usageRates[2], function() {
                                serialNumbers.generateNewNumbers('snusers', config.maxNumber, config.usageRates[2], function() {
                                    initializeDefaultQueues(function() {
                                        // Create default storage container
                                        var bc1 = azure.createBlobService(config.storageAccount, config.storageAccessKey, config.blobHost);
                                        bc1.createContainerIfNotExists(config.container, function () { });
                                    });
                                });
                            });
                        }
                        else initializeDefaultQueues(function() { });
                    }); 
                });
            });
        });
    });

    ts1.createTableIfNotExists('sitetotals', function(error) {
        if(error === null) {
            var query = azure.TableQuery
                .select()
                .from('sitetotals');

            ts1.queryEntities(query, function(error, siteTotals) {
                if(error === null && siteTotals.length == 0) {
                    // must be site initialization create defaults
                    ts1.insertEntity('sitetotals', { PartitionKey: 'users', RowKey: uuid(), Total: '0', Deleted: '0' }, function(error) {
                        ts1.insertEntity('sitetotals', { PartitionKey: 'channels', RowKey: uuid(), Total: '0', Deleted: '0' }, function(error){ });
                    });
                }
            });
        }
    });
});

/**
* ERROR MANAGEMENT
* -------------------------------------------------------------------------------------------------
* error management - instead of using standard express / connect error management, we are going
* to show a custom 404 / 500 error using jade and the middleware errorHandler (see ./middleware/errorHandler.js)
**/
var errorOptions = { dumpExceptions: true, showStack: true }
app.configure('development', function() { });
app.configure('production', function() {
    errorOptions = {};
});
app.use(require('./middleware/errorHandler')(errorOptions));

// static vars
app.helpers({ config: {
        fbAppNamespace: config.fbAppNamespace,
        siteUrl: config.siteUrl,
        canvasUrl: config.canvasUrl,
        appID: config.appID,
        commentPageSize: config.commentPageSize,
        videoPageSize: config.videoPageSize,
        channelPageSize: config.channelPageSize,
        userFollowPageSize: config.userFollowPageSize,
        followPageSize: config.followPageSize,
        friendPageSize: config.friendPageSize,
        pazoozaFbUrl: config.pazoozaFbUrl,
        pazoozaTwitterUrl: config.pazoozaTwitterUrl,
        anonymousUser: config.anonymousUser,
        usageRates: config.usageRates,
        categorys: config.categorys,
        channelTypes: config.channelTypes,
        ratings: config.ratings
    },
    serverYear: new Date().getFullYear()
});

// all views have access to these variables
// note: can't do http calls with these functions
app.dynamicHelpers({
    session: function (req, res) {
        return req.session;
    },
    signed_request: function (req, res) {
        return req.param('signed_request');
    }
});

/**
* ROUTING
* -------------------------------------------------------------------------------------------------
* include a route file for each major area of functionality in the site
**/

require('./routes/home')(app);
require('./routes/channel')(app);
require('./routes/user')(app);
require('./routes/search')(app);
require('./routes/utils')(app);
require('./routes/facebook')(app);
require('./routes/testing')(app);

// Global Routes - this should be last!
require('./routes/global')(app);

app.listen(process.env.PORT || 3000);
console.log("Express server in %s mode", app.settings.env);

// helper functions
function initializeDefaultQueues(callback){
    // create default service bus message queues
    var qs1 = azure.createQueueService(config.storageAccount, config.storageAccessKey, config.queueHost);
    qs1.createQueueIfNotExists('serialnumbers', function(error){
        callback();
    });
}
有一些中间件模块,如siteTotals和authenticate,用于管理安装应用程序的Facebook用户,并确保其FB信息始终可供应用程序使用

我不知道也许我需要安装IISNode的最新版本?如何确定IISNode的版本以及是否需要更新

此外,我还应该指出,无论您使用的是哪种Windows Azure网站模式:免费、共享还是保留,都会发生此错误

这是我的web.config文件:

<iisnode      
 node_env="%node_env%"
 nodeProcessCommandLine="&quot;%programfiles%\nodejs\node.exe&quot;"
 nodeProcessCountPerApplication="1"
 maxConcurrentRequestsPerProcess="1024"
 maxNamedPipeConnectionRetry="3"
 namedPipeConnectionRetryDelay="2000"      
 maxNamedPipeConnectionPoolSize="512"
 maxNamedPipePooledConnectionAge="30000"
 asyncCompletionThreadCount="0"
 initialRequestBufferSize="4096"
 maxRequestBufferSize="65536"
 watchedFiles="*.js;node_modules\*;routes\*.js;views\*.jade;middleware\*.js;iisnode.yml"
 uncFileChangesPollingInterval="5000"      
 gracefulShutdownTimeout="60000"
 loggingEnabled="true"
 debuggingEnabled="false"
 debuggerPortRange="5058-6058"
 debuggerPathSegment="debug"
 maxLogFileSizeInKB="128"
 devErrorsEnabled="true"
 flushResponse="false"      
 enableXFF="false"
 promoteServerVars=""
 />


这是在使用Webmatrix模板时创建的标准文件,我用它来启动整个项目。

我们的节点站点也有类似问题,它使用了mongolab后端作为数据库。我们最终在连接字符串中添加了一个keep-alive标志(并将其设置为on)来解决这个问题。我认为这个问题是由于azure的负载平衡造成的,但在我们搬到亚马逊的时候,我从来没有花时间完全弄清楚。希望这对您有所帮助。

您能提供有关您的应用程序的更多详细信息吗?如果没有更多信息,特别是关于您的应用程序所连接的资源的信息,很难准确地指出问题所在

该问题可能是由一段时间不活动后的应用程序刷新引起的。因为网站是共享的,所以如果不用于提高应用程序密度,每个网站都会定期刷新。在应用程序重新启动后,可能需要重新建立与某些资源的连接

通过编辑iisnode.yml文件并设置loggingeenabled=true,然后下载日志(使用跨平台工具下载azure站点日志),您可以获得有关错误的更多详细信息(基本上是记录到stdout或stderr流的任何数据)


-标记

如果您有iisnode.yml,请使用它打开日志记录和调试。iisnode.yml覆盖web.config中的任何设置,我们删除的默认设置将禁用deverrors和logging,因为这是生产应用程序的正常设置。编辑iisnode.yml以更改这些值应该可以为您启用日志。

hi mark,我在C:\Users\rkara\Documents\My Web Sites\Pazooza6\node\U modules\azure\lib\cli\templates\node目录下搜索并找到了iisnode.yml,是否正确?通常我编辑web.config以打开调试etchi mark,我编辑我的问题并提供更多信息。我正在使用Azure节点sdk与Windows Azure表存储对话。除了Facebook和Windows Azure表存储之外,我没有其他通信系统…嗨,马克,我在iisnode.yml上做了一些研究,地址:。似乎我可以使用web.config并设置loggingEnabled和DeErrorEnabled。但是,当错误发生时,它仍然不会生成stderr文件。我怀疑一定还有别的事情发生了?您可以只使用web.config,但如果您使用的是命令行工具,它会自动删除一个iisnode.yml文件,其中的设置会覆盖您的web.config设置。我没有读到你在使用webmatrix,因为你不需要担心iisnode.yml,你只需要在配置中进行更改。默认情况下,iisnode日志会写入站点的日志目录。实际上,您可以使用跨平台命令行工具(npm install-g azure cli)流式传输日志,或者通过ftp将日志发送到您的网站,并从LogFiles\iisnode目录获取日志。从您的角度来看,iisnode.yml文件标记的路径是什么?这就是你用来查找iisnode.yml文件的目录吗?C:\Users\rkara\Documents\mywebsites\Pazooza6\node\u modules\azure\lib\cli\templates\nodeFYI-。
<iisnode      
 node_env="%node_env%"
 nodeProcessCommandLine="&quot;%programfiles%\nodejs\node.exe&quot;"
 nodeProcessCountPerApplication="1"
 maxConcurrentRequestsPerProcess="1024"
 maxNamedPipeConnectionRetry="3"
 namedPipeConnectionRetryDelay="2000"      
 maxNamedPipeConnectionPoolSize="512"
 maxNamedPipePooledConnectionAge="30000"
 asyncCompletionThreadCount="0"
 initialRequestBufferSize="4096"
 maxRequestBufferSize="65536"
 watchedFiles="*.js;node_modules\*;routes\*.js;views\*.jade;middleware\*.js;iisnode.yml"
 uncFileChangesPollingInterval="5000"      
 gracefulShutdownTimeout="60000"
 loggingEnabled="true"
 debuggingEnabled="false"
 debuggerPortRange="5058-6058"
 debuggerPathSegment="debug"
 maxLogFileSizeInKB="128"
 devErrorsEnabled="true"
 flushResponse="false"      
 enableXFF="false"
 promoteServerVars=""
 />