![](/img/trans.png)
[英]Failed to connect to mydb.database.windows.net:1433 in 15000ms (Microsoft Azure SQL Database)
[英]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.