I have defined 1 agent called "ios_dockeragent" in agent pools configuration :
Settings/Agent pools/Default
In my Azure DevOps organization, I bought 4 Parallel jobs and 3 Parallel hosted jobs so I do not have a parallel jobs problem.
From each build server I start the self hosted server like this where "ios_dockeragent" is defined in devops:
docker run -d --rm -t --name=ios_docker_64 -e AZP_WORK=/temp/working_dir -v =/temp/working_dir:/azp -e AZP_URL=https://dev.azure.com/xx -e AZP_TOKEN=nhxxxxxxxxxxmxhu76mlua -e AZP_AGENT_NAME=ios_dockeragent
When I run 2 jobs in Parallel in 2 different servers I'm getting this error from the agent log :
X-VSS-E2EID: 2e6e97b5-f604-4b50-85ad-9fdd0db544c1^M
X-Frame-Options: SAMEORIGIN^M
X-TFS-FedAuthRealm: https://tfsprodweu6.visualstudio.com/^M
X-TFS-FedAuthIssuer: https://dev.azure.com/xxxx/^M
X-VSS-AuthorizationEndpoint: https://vssps.dev.azure.com/xxxx/^M
X-VSS-ResourceTenant: 789cbce2-e568-40be-96e3-81dddf6281f8^M
X-VSS-S2STargetService: 00000002-0000-8888-8000-000000000000/visualstudio.com^M
X-TFS-FedAuthRedirect: https://spsprodweu2.vssps.visualstudio.com/_signin?realm=dev.azure.com&reply_to=https%3A%2F%2Fdev.azure.com%2Fxxxx%2F_apis%2Fdistributedtask%2Fpools%2F1%2Fsessions&redirect=1&hid=78104741-e137-429a-b184-f357f35f83cb&context=eyJodCI6MiwiaGlkIjoiY2M2ODE0M2UtNm90#ctx=eyJTaWduSW5Db29raWVEb21haW5zIjpbImh0dHBzOi8vbG9naW4ubWljcm9zb2Z0b25saW5lLmNvbSIsImh0dHBzOi^M
Request-Context: appId=cid-v1:75f7e064-d741-4620-89f0-b5624ba3fe6d^M
Access-Control-Expose-Headers: Request-Context^M
X-Content-Type-Options: nosniff^M
X-MSEdge-Ref: Ref A: 3FE913B29BEF4D0194FD70F345C6AAE6 Ref B: ASHEDGE1414 Ref C: 2020-10-12T13:28:49Z^M
Date: Mon, 12 Oct 2020 13:28:49 GMT^M
[2020-10-12 13:28:49Z INFO RSAFileKeyManager] Loading RSA key parameters from file /azp/agent/.credentials_rsaparams
[2020-10-12 13:28:49Z INFO RSAFileKeyManager] Loading RSA key parameters from file /azp/agent/.credentials_rsaparams
[2020-10-12 13:28:50Z INFO VisualStudioServices] AAD Correlation ID for this token request: Unknown
[2020-10-12 13:28:50Z ERR VisualStudioServices] POST request to https://dev.azure.com/xxxx/_apis/distributedtask/pools/1/sessions failed. HTTP Status: Conflict, AFD Ref: Ref A: BBBA7D16EF4349E283B21690EB631FDA Ref B: ASHEDGE1414 Ref C: 2020-10-12T13:28:50Z
[2020-10-12 13:28:50Z ERR MessageListener] Catch exception during create session.
[2020-10-12 13:28:50Z ERR MessageListener] Microsoft.TeamFoundation.DistributedTask.WebApi.TaskAgentSessionConflictException: The task agent ios_dockeragent already has an active session for owner b192db24b4c0.
at Microsoft.VisualStudio.Services.WebApi.VssHttpClientBase.HandleResponseAsync(HttpResponseMessage response, CancellationToken cancellationToken)
at Microsoft.VisualStudio.Services.WebApi.VssHttpClientBase.SendAsync(HttpRequestMessage message, HttpCompletionOption completionOption, Object userState, CancellationToken cancellationToken)
at Microsoft.VisualStudio.Services.WebApi.VssHttpClientBase.SendAsync[T](HttpRequestMessage message, Object userState, CancellationToken cancellationToken)
at Microsoft.VisualStudio.Services.WebApi.VssHttpClientBase.SendAsync[T](HttpMethod method, IEnumerable`1 additionalHeaders, Guid locationId, Object routeValues, ApiResourceVersion version, HttpContent content, IEnumerable`1 queryParameters, Object userState, CancellationToken cancellationToken)
at Microsoft.VisualStudio.Services.Agent.Listener.MessageListener.CreateSessionAsync(CancellationToken token)
[2020-10-12 13:28:50Z INFO MessageListener] The session for this agent already exists.
[2020-10-12 13:28:50Z ERR Terminal] WRITE ERROR: A session for this agent already exists.
[2020-10-12 13:28:50Z INFO MessageListener] The session conflict exception haven't reached retry limit.
[2020-10-12 13:28:50Z ERR Terminal] WRITE ERROR: 2020-10-12 13:28:50Z: Agent connect error: The task agent ios_dockeragent already has an active session for owner b192xx4b4c0.. Retrying until reconnected.
[2020-10-12 13:28:50Z INFO MessageListener] Sleeping for 30 seconds before retrying.
[2020-10-12 13:29:20Z INFO MessageListener] Attempt to create session.
[2020-10-12 13:29:20Z INFO MessageListener] Connecting to the Agent Server...
[2020-10-12 13:29:20Z INFO AgentServer] Establish connection with 60 seconds timeout.
[2020-10-12 13:29:20Z INFO VisualStudioServices] Starting operation Location.GetConnectionData
[2020-10-12 13:29:20Z INFO AgentServer] Establish connection with 60 seconds timeout.
[2020-10-12 13:29:20Z INFO VisualStudioServices] Starting operation Location.GetConnectionData
[2020-10-12 13:29:20Z INFO AgentServer] Establish connection with 60 seconds timeout.
[2020-10-12 13:29:20Z INFO VisualStudioServices] Starting operation Location.GetConnectionData
[2020-10-12 13:29:20Z INFO VisualStudioServices] Finished operation Location.GetConnectionData
[2020-10-12 13:29:20Z INFO VisualStudioServices] Finished operation Location.GetConnectionData
[2020-10-12 13:29:20Z INFO VisualStudioServices] Finished operation Location.GetConnectionData
[2020-10-12 13:29:20Z INFO MessageListener] VssConnection created
[2020-10-12 13:29:20Z ERR VisualStudioServices] POST request to https://dev.azure.com/xxxx/_apis/distributedtask/pools/1/sessions failed. HTTP Status: Conflict, AFD Ref: Ref A: 00584079848E4626B042E394EC5F89B7 Ref B: BL2EDGE0921 Ref C: 2020-10-12T13:29:20Z
[2020-10-12 13:29:20Z ERR MessageListener] Catch exception during create session.
[2020-10-12 13:29:20Z ERR MessageListener] Microsoft.TeamFoundation.DistributedTask.WebApi.TaskAgentSessionConflictException: The task agent ios_dockeragent already has an active session for owner b192db24b4c0.
at Microsoft.VisualStudio.Services.WebApi.VssHttpClientBase.HandleResponseAsync(HttpResponseMessage response, CancellationToken cancellationToken)
at Microsoft.VisualStudio.Services.WebApi.VssHttpClientBase.SendAsync(HttpRequestMessage message, HttpCompletionOption completionOption, Object userState, CancellationToken cancellationToken)
at Microsoft.VisualStudio.Services.WebApi.VssHttpClientBase.SendAsync[T](HttpRequestMessage message, Object userState, CancellationToken cancellationToken)
at Microsoft.VisualStudio.Services.WebApi.VssHttpClientBase.SendAsync[T](HttpMethod method, IEnumerable`1 additionalHeaders, Guid locationId, Object routeValues, ApiResourceVersion version, HttpContent content, IEnumerable`1 queryParameters, Object userState, CancellationToken cancellationToken)
at Microsoft.VisualStudio.Services.Agent.Listener.MessageListener.CreateSessionAsync(CancellationToken token)
[2020-10-12 13:29:20Z INFO MessageListener] The session for this agent already exists.
[2020-10-12 13:29:20Z ERR Terminal] WRITE ERROR: A session for this agent already exists.
[2020-10-12 13:29:20Z INFO MessageListener] The session conflict exception haven't reached retry limit.
[2020-10-12 13:29:20Z INFO MessageListener] Sleeping for 30 seconds before retrying.
[2020-10-12 13:29:36Z INFO Terminal] WRITE LINE: Exiting...
[2020-10-12 13:29:36Z INFO ConfigurationStore] IsServiceConfigured()
[2020-10-12 13:29:36Z INFO ConfigurationStore] IsServiceConfigured: False
[2020-10-12 13:29:36Z INFO HostContext] Agent will be shutdown for UserCancelled
[2020-10-12 13:29:36Z INFO AgentProcess] Agent execution been cancelled.
I configured only 1 agent which I see here :
What do I need to configure to run more than 1 self-hosted agent?