當我從物理 iOS 設備除錯我的應用程式并嘗試向我的本地服務器發出請求時,我收到了在 iOS 模擬器上沒有的錯誤:
SocketException (SocketException: OS Error: Connection denied, errno = 61, address = 192.168.1.186, port = 56740)
該埠應該是我的服務器埠嗎?那是5001。
我可以在 dart 開發工具除錯器中看到此請求已發送:
GET https://192.168.1.186:5001/fashionitems/search?searchTerm=Fa¤tPage=1&pageSize=10
這是正確的 URL 并且在 iOS 模擬器中作業,所以看起來它正在發送正確的請求。
我正在為服務器使用 asp.NET 6。
我覺得問題出在我的服務器上,因為谷歌地圖 API 請求正在物理設備上作業。當 asp.NET 6 應用程式在模擬器上運行而不是在物理設備上運行時,我會查看它的哪個部分?
我能看什么來解決這個問題?
編輯:在 Flutter 中,我已經看到如果在物理設備上進行測驗,我們應該使用 IP 地址而不是“localhost”。所以我這樣做了。有趣的是,IP 地址不適用于 iOS 模擬器,但只有“localhost”適用。我不認為應該是這樣。
Wifi 是starlink,但不認為這會有所作為。我無法使用移動資料熱點進行測驗。
服務器連接字串是:
"ConnectionStrings": {
"DefaultConnection": "Server=localhost;Port=5432;Database=vepo_dev_db;User Id=postgres;Password=password;Include Error Detail=true"
},
在 asp.net 應用程式上:
啟動設定.json
{
"$schema": "http://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:53210",
"sslPort": 44301
}
},
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchUrl": "swagger",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"Vepo": {
"commandName": "Project",
"dotnetRunMessages": "true",
"launchBrowser": true,
"launchUrl": "GroceryItems",
"applicationUrl": "https://localhost:5001;http://localhost:5000",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}
uj5u.com熱心網友回復:
改變
"applicationUrl": "https://localhost:5001;http://localhost:5000",
到
"applicationUrl": "https://0.0.0.0:5001;http://localhost:5000",
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/393736.html
