Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NetCore 项目发布后,云函数报错:Function instance health check failed on port 9000 in 120 seconds. #682

Open
oOtroyOo opened this issue Apr 29, 2023 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@oOtroyOo
Copy link

oOtroyOo commented Apr 29, 2023

Describe the bug
首先按照s命令,初始并创建Netcore示范容器。使用阿里云函数
然后不经任何修改,s deploy完成后。
使用http url 半天没有Response,进入阿里云函数后台,开启了日志系统(注:真的有必要加入提示初始化项目时并开通日志系统)
报错信息为
Function instance health check failed on port 9000 in 120 seconds.
同时日志里看见他监听了 http://[::]:80

根据 错误处理 #实例健康检查失败(Function instance health check failed)

得知需要将云函数配置的端口,与应用程序绑定的端口一致、
根据云函数配置、文档、以及项目中的 yaml/json都用的9000。 那么他Netcore应用本身仍然会监听80端口?

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):
Client:
Cloud integration: v1.0.31
Version: 20.10.24
API version: 1.41
Go version: go1.19.7
Git commit: 297e128
Built: Tue Apr 4 18:28:08 2023
OS/Arch: windows/amd64
Context: default
Experimental: true

Additional context

解决方法。修改Program.cs, 让程序本身监听 0.0.0.0:9000

        public static IHostBuilder CreateHostBuilder(string[] args) =>
            Host.CreateDefaultBuilder(args)
                .ConfigureWebHostDefaults(webBuilder =>
                {
                    webBuilder.UseStartup<Startup>();
                    webBuilder.UseUrls("http://0.0.0.0:9000");
                });

我不知道程序模板是从哪来的,以及s命令会不会修改模板。所以还得请你们确认并修改。

@oOtroyOo oOtroyOo added the bug Something isn't working label Apr 29, 2023
@heimanba
Copy link
Member

heimanba commented May 2, 2023

请问下是初始化了哪个模版呢?这个需要修改对应的应用模版

@oOtroyOo
Copy link
Author

oOtroyOo commented May 2, 2023

image

是这个模板。我之后找到了模板在哪。
应该就是这个东西吧?
http://www.devsapp.cn/details.html?name=start-fc-custom-container-http-aspdotnetcore

不过我觉得这行代码不值得写入模板。应该从某种启动命令传入端口。既然yaml有端口号,具体如何传入是问题。比如某种 dotnet启动命令。

@heimanba
Copy link
Member

heimanba commented Dec 4, 2023

可以在这里看下,更改 caPort 端口
https://docs.serverless-devs.com/fc/yaml/readme

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants