【发布时间】:2023-07-15 01:15:01
【问题描述】:
我在过去几周开始工作(或尝试)Simple MVC-App 用于通知。
我使用了这个例子并用 ngrok 建立了 iP-tunnels ot localhost。(参见下面的示例和内容页面)。 https://docs.microsoft.com/de-de/learn/modules/msgraph-changenotifications-trackchanges/5-exercise-change-notification
https://github.com/microsoftgraph/msgraph-training-changenotifications/tree/live
如果我同时只在本地应用程序上运行一切都很好,但如果我要启动第二个通知应用程序 这条消息失败了
System.IO.IOException: Failed to bind to address https://127.0.0.1:5001: address already in use. ---> Microsoft.AspNetCore.Connections.AddressInUseException: Normalerweise darf jede Socketadresse (Protokoll, Netzwerkadresse oder Anschluss) nur jeweils einmal verwendet werden.
我在 ngrok.yml 文件中尝试了一些更改,但也无法访问。
# Create 3 tunnels, each for different ports, with only https enabled
# This way the ngrok process stays bellow the Free plan limit (4 tunnels)
authtoken: **************************
log: ngrok.log
tunnels:
first:
addr: 5000
proto: http
#host_header: localhost
second:
addr: 5000
proto: http
#host_header: localhost
我试图更改 appsetting.json 中的 url 但它不起作用:
{
"Logging": {
"LogLevel": {
"Default": "Debug"
}
},
"AllowedHosts":"*",
"MyConfig": {
"AppId": "****************",
"AppSecret": "*********************",
"TenantId": "********",
"Ngrok": "https://76bd76a6aca4.ngrok.io"
}
}
但是在启动第一个应用程序后,第二个应用程序因异常而崩溃。 然后我尝试使用端口 5000 m 5010 等等并更改了launchsetting.json中的设置但我又失败了。
"msgraphapp": {
"commandName": "Project",
"launchBrowser": true,
"launchUrl": "api/values",
"applicationUrl": "https://localhost:5001;http://localhost:5000",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
请有人告诉我我必须做什么,以便我可以在 localhost 上启动 2 个或更多应用程序,并使用 ngrok 或替代方案进行隧道传输。
【问题讨论】:
-
出于好奇,为什么在使用 Graph Change Notifications 时需要为同一个应用程序运行两个实例并为每个实例运行一个 Ngrok 隧道?
-
@danstan:不是同一个应用程序和类似应用程序,用于通知其他订阅另一个资源的 webhook。确实不同的 GUID 不一样,但我需要不同的应用程序来处理不同的通知。最好的情况是可以在同一台电脑本地完成。我再次更改标题以使其更清晰。
-
@danstan;与我的通话记录通知的实际问题无关,一个应用程序运行在一个应用程序或 afew uswer 进行日志记录和测试是一种正常情况。如果那时需要在本地对另一个应用程序进行简短测试,有时可能会发生。是的,在完全不同的应用程序上,使用相同的隧道是没有问题的。但是 URL/api/notifications 是由微软修复的,所以如果我没记错的话,它们的 URi 是不可更改的。
标签: c# microsoft-graph-api ngrok http-tunneling