简体   繁体   English

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

[英]Windows Azure Node.js Internal Server Error

I would get this error now and then when I hit this address: 我现在会遇到这个错误,当我点击这个地址时:

http://apps.facebook.com/pazooza http://apps.facebook.com/pazooza

iisnode encountered an error when processing the request.

HRESULT: 0x2
HTTP status: 500
HTTP reason: Internal Server Error
You are receiving this HTTP 200 response because system.webServer/iisnode/@devErrorsEnabled configuration setting is 'true'.

In addition to the log of stdout and stderr of the node.exe process, consider using debugging and ETW traces to further diagnose the problem.

You may get additional information about this error condition by logging stdout and stderr of the node.exe process.To enable logging, set the system.webServer/iisnode/@loggingEnabled configuration setting to 'true' (current value is 'false').

But when I hit refresh, the site loads correctly and everything is working fine. 但是当我点击刷新时,网站正确加载,一切正常。 It is only when I leave the site for a couple of hours comeback and perhaps I would see this error again, or perhaps not. 只有当我离开网站几个小时后才会回来,或许我会再次看到这个错误,或者也许不会。 It's annoying because users who navigate to my site think it's broken and aren't inclined to hit refresh! 这很烦人,因为导航到我网站的用户认为它已经坏了而且不想点击刷新!

So my question is whether anybody else has encountered this type of problem before, where you've checked your code and everything seems correctly the site loads, but every now and then Node or IIS-Node would chuck this error. 所以我的问题是之前是否有其他人遇到过这种类型的问题,你已经检查了你的代码,并且网站加载的一切似乎都正确,但是不时的Node或IIS-Node都会发现这个错误。

My setup is as follows: 我的设置如下:

Server: Windows Azure/Websites (Share, 2 Instances) Language: Node.js Tools: Webmatrix (I used a template project Starter Site) 服务器:Windows Azure /网站(共享,2个实例)语言:Node.js工具:Webmatrix(我使用模板项目Starter Site)

The most annoying thing is I've turned on logging of error messages etc, and the logging system isn't picking up this error, when I go to check my logs no error log gets created when this error occurs, so I haven't figured out a way to capture it. 最烦人的事情是我已经开启了错误消息的记录等,并且日志记录系统没有收到此错误,当我去检查我的日志时,如果发生此错误则没有创建错误日志,所以我没有找到了捕捉它的方法。 Anyone got any suggestions? 有人有什么建议吗?

This is what my server.js file looks like: 这是我的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();
    });
}

There are middleware modules such as siteTotals and authenticate that manage Facebook Users who install the app and ensure that their FB info is available to the application at all times. 有一些中间件模块,例如siteTotals和authenticate,用于管理安装应用程序的Facebook用户,并确保他们的FB信息始终可供应用程序使用。

I don't know maybe I need to install the latest version of IISNode? 我不知道是否需要安装最新版本的IISNode? How do I determine the version of IISNode and whether it needs to be updated? 如何确定IISNode的版本以及是否需要更新?

Also I should point out that this error occurs regardless of which Windows Azure Websites Mode your in either: FREE, SHARE or RESERVED. 此外,我应该指出,无论您使用哪种Windows Azure网站模式,都会发生此错误:免费,分享或保留。

And here is my web.config file: 这是我的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=""
 />

it's the standard file that gets created when using Webmatrix templates which I used to start this whole project. 它是使用我用来启动整个项目的Webmatrix模板时创建的标准文件。

We had a similar issue with our Node site that used a mongolab backend as it's database. 我们的Node站点有一个类似的问题,它使用了mongolab后端作为它的数据库。 We ended up adding a keep alive flag to our connection string(and setting it to on) to resolve the issue. 我们最终在连接字符串中添加了一个keep alive标志(并将其设置为on)以解决问题。 I think the issue was due to azure's load balancing but I never spent the time to figure it out exactly as we moved to Amazon. 我认为这个问题是由于azure的负载平衡问题,但我从来没有花时间弄清楚我们搬到亚马逊的时候。 Hope that helps you out. 希望能帮到你。

Can you provide some more details about your application? 你能提供一些关于你的申请的更多细节吗? It's difiicult to pinpoint the exact problem without more info, especially about resources your application is connecting to. 如果没有更多信息,很难确定确切的问题,尤其是关于应用程序连接的资源。

The issue is likely caused by an application refresh after a period of inactivity. 该问题可能是由于一段时间不活动后应用程序刷新引起的。 Because websites are shared, each site is periodically refreshed if not used to improve application density. 由于网站是共享的,因此如果不用于提高应用程序密度,则会定期刷新每个站点。 There is likely some resource that you need to reestablish the connection to after an application restart. 在应用程序重新启动后,可能需要重新建立连接的某些资源。

You can get more details on the error (basically any data logged to the stdout or stderr streams) by editing your iisnode.yml file and setting loggingEnabled=true, then dowloading the log (azure site log download using the cross-platform tool). 您可以通过编辑iisnode.yml文件并设置loggingEnabled = true来获取有关错误的更多详细信息(基本上是记录到stdout或stderr流的任何数据),然后下载日志(使用跨平台工具下载azure站点日志)。

-Mark -标记

If you have iisnode.yml, use it to turn on logging and debugging. 如果您有iisnode.yml,请使用它来打开日志记录和调试。 iisnode.yml overrides any settings in web.config, and the default one we drop would have deverrors and logging both disabled, as those are the normal settings for production apps. iisnode.yml会覆盖web.config中的任何设置,我们删除的默认设置会将deverrors和logging都禁用,因为这些是生产应用程序的正常设置。 Editing iisnode.yml to change these values should enable logs for you. 编辑iisnode.yml以更改这些值应该为您启用日志。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM