Как использовать workload_uri и management_uri в IoT Edge на Windows - PullRequest
0 голосов
/ 10 марта 2020

Я пытаюсь написать модуль Python для запуска в контейнере на IoT Edge, работающем на Windows.

Поскольку Python на windows не поддерживает unix сокетов, я думаю, что мне нужно изменить соединение: и слушать: раздел config.yaml. По умолчанию они установлены на unix (сокеты).

###############################################################################
# Connect settings
###############################################################################
#
#
# Configures URIs used by clients of the management and workload APIs
#     management_uri - used by the Edge Agent and 'iotedge' CLI to start,
#                      stop, and manage modules
#     workload_uri   - used by modules to retrieve tokens and certificates
#
# The following uri schemes are supported:
#     http - connect over TCP
#     unix - connect over Unix domain socket
#
# If the 'unix' scheme is selected, the daemon expects that the parent
# directory of the specified socket file already exists, and that the Windows
# group 'NT AUTHORITY\Authenticated Users' has been given 'Modify' rights on
# the directory. For example, if the URI "unix:///C:/path/to/sock.file" is
# specified, then the directory "C:\path\to" must exist with the correct
# permissions.
#
###############################################################################

connect:
  management_uri: 'unix:///C:/ProgramData/iotedge/mgmt/sock'
  workload_uri: 'unix:///C:/ProgramData/iotedge/workload/sock'
#  management_uri: 'http://172.23.224.1:8080'
#  workload_uri: 'http://172.23.224.1:8081'

###############################################################################
# Listen settings
###############################################################################
#
# Configures the listen addresses for the daemon.
#     management_uri - used by the Edge Agent and 'iotedge' CLI to start,
#                      stop, and manage modules
#     workload_uri   - used by modules to retrieve tokens and certificates
#
# The following uri schemes are supported:
#     http - listen over TCP
#     unix - listen over Unix domain socket
#
# If the 'unix' scheme is selected, the daemon expects that the parent
# directory of the specified socket file already exists, and that the Windows
# group 'NT AUTHORITY\Authenticated Users' has been given 'Modify' rights on
# the directory. For example, if the URI "unix:///C:/path/to/sock.file" is
# specified, then the directory "C:\path\to" must exist with the correct
# permissions.
#
###############################################################################

listen:
  management_uri: 'unix:///C:/ProgramData/iotedge/mgmt/sock'
  workload_uri: 'unix:///C:/ProgramData/iotedge/workload/sock'
#  management_uri: 'http://172.23.224.1:8080'
#  workload_uri: 'http://172.23.224.1:8081'

Просмотр: https://github.com/Azure/iotedge/blob/master/edgelet/doc/testiotedgedapi.md, похоже, я могу установить для них http://ipaddress: 8080 и 8181 соответственно, но если я использую 172.17.0.0.1 (согласно документации), я получаю:

error: edgelet_utils::logging --    caused by: An error occurred while binding a listener to address 172.17.0.1:8080

Сетевой адаптер, созданный moby, имеет IP 172.23.224.1, поэтому я попытался http://172.23.224.1: 8080 и 8181, и я получаю ошибку ниже, и edgeAgent не запускается.

<6> 2020-03-10 12:41:34.191 -05:00 [INF] - Created persistent store at C:\Windows\TEMP\edgeAgent
<0> 2020-03-10 12:41:55.613 -05:00 [FTL] - Fatal error starting Agent.
System.Net.Http.HttpRequestException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond ---> System.Net.Sockets.SocketException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond
   at System.Net.Http.ConnectHelper.ConnectAsync(String host, Int32 port, CancellationToken cancellationToken)
   --- End of inner exception stack trace ---
   at System.Net.Http.ConnectHelper.ConnectAsync(String host, Int32 port, CancellationToken cancellationToken)
   at System.Threading.Tasks.ValueTask`1.get_Result()
   at System.Net.Http.HttpConnectionPool.CreateConnectionAsync(HttpRequestMessage request, CancellationToken cancellationToken)
   at System.Threading.Tasks.ValueTask`1.get_Result()
   at System.Net.Http.HttpConnectionPool.WaitForCreatedConnectionAsync(ValueTask`1 creationTask)
   at System.Threading.Tasks.ValueTask`1.get_Result()
   at System.Net.Http.HttpConnectionPool.SendWithRetryAsync(HttpRequestMessage request, Boolean doRequestAuth, CancellationToken cancellationToken)
   at System.Net.Http.RedirectHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
   at System.Net.Http.HttpClient.FinishSendAsyncUnbuffered(Task`1 sendTask, HttpRequestMessage request, CancellationTokenSource cts, Boolean disposeCts)
   at Microsoft.Azure.Devices.Edge.Agent.Edgelet.Version_2019_01_30.GeneratedCode.EdgeletHttpClient.GetSystemInfoAsync(String api_version, CancellationToken cancellationToken) in C:\agent\_work\4\s\edge-agent\src\Microsoft.Azure.Devices.Edge.Agent.Edgelet\version_2019_01_30\generatedCode\EdgeletHttpClient.cs:line 1553
   at Microsoft.Azure.Devices.Edge.Util.TaskEx.TimeoutAfter[T](Task`1 task, TimeSpan timeout)
   at Microsoft.Azure.Devices.Edge.Agent.Edgelet.Versioning.ModuleManagementHttpClientVersioned.Execute[T](Func`1 func, String operation)
   at Microsoft.Azure.Devices.Edge.Agent.Edgelet.Versioning.ModuleManagementHttpClientVersioned.Execute[T](Func`1 func, String operation) in C:\agent\_work\4\s\edge-agent\src\Microsoft.Azure.Devices.Edge.Agent.Edgelet\versioning\ModuleManagementHttpClientVersioned.cs:line 124
   at Microsoft.Azure.Devices.Edge.Agent.Edgelet.Version_2019_01_30.ModuleManagementHttpClient.GetSystemInfoAsync() in C:\agent\_work\4\s\edge-agent\src\Microsoft.Azure.Devices.Edge.Agent.Edgelet\version_2019_01_30\ModuleManagementHttpClient.cs:line 125
   at Microsoft.Azure.Devices.Edge.Agent.Docker.DockerEnvironmentProvider.CreateAsync(IRuntimeInfoProvider runtimeInfoProvider, IEntityStore`2 store, IRestartPolicyManager restartPolicyManager) in C:\agent\_work\4\s\edge-agent\src\Microsoft.Azure.Devices.Edge.Agent.Docker\DockerEnvironmentProvider.cs:line 39
   at Microsoft.Azure.Devices.Edge.Agent.Service.Modules.EdgeletModule.<>c.<<Load>b__13_6>d.MoveNext() in C:\agent\_work\4\s\edge-agent\src\Microsoft.Azure.Devices.Edge.Agent.Service\modules\EdgeletModule.cs:line 130
--- End of stack trace from previous location where exception was thrown ---
   at Microsoft.Azure.Devices.Edge.Agent.Service.Modules.AgentModule.<>c.<<Load>b__14_13>d.MoveNext() in C:\agent\_work\4\s\edge-agent\src\Microsoft.Azure.Devices.Edge.Agent.Service\modules\AgentModule.cs:line 243
--- End of stack trace from previous location where exception was thrown ---
   at Microsoft.Azure.Devices.Edge.Agent.Service.Program.MainAsync(IConfiguration configuration) in C:\agent\_work\4\s\edge-agent\src\Microsoft.Azure.Devices.Edge.Agent.Service\Program.cs:line 190
<3> 2020-03-10 12:41:55.763 -05:00 [ERR] - Unexpected error in periodic operation refresh twin config
System.Threading.Tasks.TaskCanceledException: A task was canceled.
   at Microsoft.Azure.Devices.Edge.Util.PeriodicTask.DoWork() in C:\agent\_work\4\s\edge-util\src\Microsoft.Azure.Devices.Edge.Util\PeriodicTask.cs:line 83
<6> 2020-03-10 12:41:55.771 -05:00 [INF] - Disposing module connection object

1 Ответ

0 голосов
/ 10 марта 2020

Не важно, остановка брандмауэра windows решила это. :)

...