簡體   English   中英

天藍色的移動服務調用sql服務器存儲過程並獲得requestTimeout 15000ms錯誤

[英]azure mobile services calling sql server stored procedure and get a requestTimeout 15000ms error

我不斷收到此錯誤:

{“名稱”:“ RequestError”,“消息”:“超時:請求未能在15000毫秒內完成”,“代碼”:“ ETIMEOUT”,“數字”:“ ETIMEOUT”,“ precedingErrors”:[]}

如何增加請求的超時時間?

我不確定這是來自sql服務器數據庫還是來自node.js服務?

我如何從Azure中查看SQL Server發生了什么?

我有SQL Server Management Studio和Visual Studio,因此我可以登錄到數據庫,但看不到如何增加超時時間等。

我在node.js中設置了任何參數以增加超時時間嗎?

我找到了這個:

http://azure.github.io/azure-mobile-apps-node/global.html#dataConfiguration

並假設我必須在查詢對象中設置某些內容?

我調用的我的node.js API searchService.js

var HttpStatus = require('http-status-codes');

module.exports = {
    "post": function (req, res, next) {
        var resultSet = {
            TotalRecords: 0,
            Results: null
        };
        var parameters = [
            { name: 'forumId', value: req.body.forumId },
            { name: 'registrantId', value: req.body.registrantId },
            { name: 'userId', value: req.azureMobile.user.id },
            { name: 'exclusive', value: req.body.exclusive },
            { name: 'type', value: req.body.type },
            { name: 'categoryIds', value: req.body.categoryIds.join(",") },
            { name: 'locationIds', value: req.body.locationIds.join(",") },
            { name: 'unitIds', value: req.body.unitIds.join(",") },
            { name: 'priceIds', value: req.body.priceIds.join(",") },
            { name: 'delimiter', value: "," }
        ];

        console.log("parameters = " + JSON.stringify(parameters));

        var query = {
            sql: "exec SearchServicesStrictTotal @forumId, @registrantId, @userId, @exclusive, @type, @categoryIds, @locationIds, @unitIds, @priceIds, @delimiter",
            parameters: parameters
        };

        req.azureMobile.data.execute(query)
            .then(function(result) {
                console.log("got result " + JSON.stringify(result));

                resultSet.TotalRecords = result[0].Total;
                res.status(HttpStatus.OK).send(resultSet);
            }).catch(function(error){
                console.log("error one " + JSON.stringify(error));
                res.status(HttpStatus.BAD_REQUEST).send(error);
            });
    }
};

請求超時的默認值為15000毫秒。 為了增加請求的超時時間,您可以嘗試將其放入您的app.js文件。

var mobileApp = azureMobileApps({
    homePage: true,
    data: {
        requestTimeout: 60000
    }
});

app.js文件將如下所示。

var express = require('express'),
    azureMobileApps = require('azure-mobile-apps');

var app = express();

var mobileApp = azureMobileApps({
    homePage: true,
    data: {
        requestTimeout: 60000
    }
});

mobileApp.tables.import('./tables');

mobileApp.api.import('./api');

mobileApp.tables.initialize()
    .then(function () {
        app.use(mobileApp);    // Register the Azure Mobile Apps middleware
        app.listen(process.env.PORT || 3000);   // Listen for requests
    });

希望能幫助到你。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM