[英]Docker Express Node.js app container not connecting with MongoDB container giving error TransientTransactionError
[英]Node, Express API App on Azure giving Container Start Failure error
我有一个现有的 Node 和 Express API 应用程序,我正在尝试将其部署到 Azure WebApps。 部署顺利。 但是当我尝试访问 API 时,什么也没有发生。 When I check log, I see following: "Container chdemoapi_0_f2df43ac didn't respond to HTTP pings on port: 8080, failing site start""Container chdemoapi_0_4e583132 didn't respond to HTTP pings on port: 8080, failing site start" This is how我的 index.js 文件看起来:
const config = require('./common/config/env.config.js');
const express = require('express');
const app = express();
const bodyParser = require('body-parser');
const AuthorizationRouter = require('./auth/routes.config');
const LeadsRouter = require('./leads/routes.config');
const DemoRouter = require('./demo/routes.config');
const MentorRouter = require('./mentors/routes.config');
app.use(function (req, res, next) {
res.header('Access-Control-Allow-Origin', '*');
res.header('Access-Control-Allow-Credentials', 'true');
res.header('Access-Control-Allow-Methods', 'GET,HEAD,PUT,PATCH,POST,DELETE');
res.header('Access-Control-Expose-Headers', 'Content-Length');
res.header('Access-Control-Allow-Headers', 'Accept, Authorization, Content-Type, X-Requested-With, Range, x-access-token');
if (req.method === 'OPTIONS') {
return res.send(200);
} else {
return next();
}
});
app.use(bodyParser.json());
AuthorizationRouter.routesConfig(app);
LeadsRouter.routesConfig(app);
DemoRouter.routesConfig(app);
MentorRouter.routesConfig(app);
app.listen(config.port, function () {
console.log('app listening at port %s', config.port);
});
这是我的 env.config 文件的外观:
module.exports = { "port": 3600,
//"appEndpoint": "http://localhost:3600",
//"apiEndpoint": "http://localhost:3600",
"appEndpoint": "https://chdemoapi.azurewebsites.net:3600",
"apiEndpoint": "https://chdemoapi.azurewebsites.net:3600",
"jwt_expiration_in_seconds": 36000,
"environment": "dev",
};
这是我的 package.json 文件的外观:
{"name": "ch-demo-services",
"version": "1.0.0",
"description": "microservices for demo module",
"main": "index.js",
"start":"node index.js",
"scripts": {"test":
"echo \"Error: no test specified\" && exit 1"},
"author": "", "license": "ISC",
"dependencies": { "express": "^4.17.1", "generate-password": "^1.5.1",
"jsonwebtoken": "^8.5.1", "mailgen": "^2.0.13", "moment": "^2.27.0", "mongoose":
"^5.9.18", "nodemailer": "^6.4.10", "uuid": "^8.1.0" } }
在应用程序设置中,我还添加了 WEBSITES_PORT:3600。 In my localhost, I was accessing API like: http://localhost:3600/listDemoSlotsAfter deploying to Azure, I am trying to access them like: https://chdemoapi.azurewebsites.net:3600/listDemoSlots . 但是什么也没发生,我看到上面的日志。 我的设置有什么问题。
从你的错误信息来看,是端口问题。
Azure Web App服务仅支持http端口80和Z5E056C500A431C4B6AADE5B110端口。 建议将https://chdemoapi.azurewebsites.net:3600
替换为https://chdemoapi.azurewebsites.net:443
。 然后重新启动应用程序。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.