Commit 54b4a69
AgentServer connections ignore VSTS_HTTP_TIMEOUT environment variable and use hardcoded timeout values (#5432)
* Fix: Respect VSTS_HTTP_TIMEOUT environment variable in AgentServer
The agent listener was ignoring the VSTS_HTTP_TIMEOUT environment variable
and using hardcoded timeout values (60s for message/request connections,
100s for generic connection) when establishing server connections.
This caused timeout errors even when users set VSTS_HTTP_TIMEOUT to higher
values like 300 seconds, making the environment variable non-functional.
Changes:
- Modified AgentServer.ConnectAsync() to read timeout from AgentKnobs.HttpTimeout
- Applied valid range constraint [100, 1200] seconds as documented
- All three connections now use the same configurable timeout
- Worker connections already respect this variable via VssUtil.CreateConnection()
Fixes issue where agents in slow network environments experienced frequent
timeouts despite setting VSTS_HTTP_TIMEOUT environment variable.
Related logs showing the issue:
[INFO EnvironmentCapabilitiesProvider] Adding 'VSTS_HTTP_TIMEOUT': '300'
[INFO AgentServer] Establish connection with 60 seconds timeout.
[ERR MessageListener] System.TimeoutException: HTTP request timed out after 00:01:00
* Fix: Respect VSTS_HTTP_TIMEOUT environment variable for agent connections
- Add GetDefaultConnectionTimeout() helper to centralize timeout logic
- Update ConnectAsync to use environment variable timeout
- Update RefreshConnectionAsync to accept optional timeout (defaults to env var)
- Update ResetConnectionTimeout to accept optional timeout (defaults to env var)
- Rename SetConnectionTimeout to ResetConnectionTimeout for clarity
- Keep 30s timeout for error recovery scenarios (intentional fast failure)
- Update JobDispatcherL0 tests to handle nullable TimeSpan parameters
Fixes agent server ignoring VSTS_HTTP_TIMEOUT setting, causing unexpected
60-second timeouts instead of configured values (100-1200 second range).
* reverting to 60 sec for JobRequest connection type
* fixing override
---------
Co-authored-by: azure-pipelines-bot <[email protected]>1 parent 05a617e commit 54b4a69
File tree
4 files changed
+73
-24
lines changed- src
- Agent.Listener
- Microsoft.VisualStudio.Services.Agent
- Test/L0/Listener
4 files changed
+73
-24
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
401 | 401 | | |
402 | 402 | | |
403 | 403 | | |
404 | | - | |
| 404 | + | |
405 | 405 | | |
406 | 406 | | |
407 | | - | |
| 407 | + | |
408 | 408 | | |
409 | 409 | | |
410 | 410 | | |
| |||
816 | 816 | | |
817 | 817 | | |
818 | 818 | | |
819 | | - | |
| 819 | + | |
820 | 820 | | |
821 | | - | |
| 821 | + | |
822 | 822 | | |
823 | 823 | | |
824 | 824 | | |
| |||
888 | 888 | | |
889 | 889 | | |
890 | 890 | | |
891 | | - | |
| 891 | + | |
892 | 892 | | |
893 | 893 | | |
894 | 894 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
244 | 244 | | |
245 | 245 | | |
246 | 246 | | |
247 | | - | |
| 247 | + | |
248 | 248 | | |
249 | 249 | | |
250 | 250 | | |
| |||
Lines changed: 63 additions & 14 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| 14 | + | |
14 | 15 | | |
15 | 16 | | |
16 | 17 | | |
| |||
26 | 27 | | |
27 | 28 | | |
28 | 29 | | |
29 | | - | |
| 30 | + | |
30 | 31 | | |
31 | | - | |
| 32 | + | |
32 | 33 | | |
33 | 34 | | |
34 | 35 | | |
| |||
73 | 74 | | |
74 | 75 | | |
75 | 76 | | |
76 | | - | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
77 | 81 | | |
78 | 82 | | |
79 | 83 | | |
80 | | - | |
81 | | - | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
82 | 93 | | |
83 | 94 | | |
84 | 95 | | |
| |||
95 | 106 | | |
96 | 107 | | |
97 | 108 | | |
98 | | - | |
| 109 | + | |
99 | 110 | | |
| 111 | + | |
| 112 | + | |
100 | 113 | | |
101 | 114 | | |
102 | 115 | | |
| |||
105 | 118 | | |
106 | 119 | | |
107 | 120 | | |
108 | | - | |
| 121 | + | |
109 | 122 | | |
110 | 123 | | |
111 | 124 | | |
| |||
130 | 143 | | |
131 | 144 | | |
132 | 145 | | |
133 | | - | |
| 146 | + | |
134 | 147 | | |
135 | 148 | | |
136 | 149 | | |
| |||
155 | 168 | | |
156 | 169 | | |
157 | 170 | | |
158 | | - | |
| 171 | + | |
159 | 172 | | |
160 | 173 | | |
161 | 174 | | |
| |||
182 | 195 | | |
183 | 196 | | |
184 | 197 | | |
185 | | - | |
| 198 | + | |
186 | 199 | | |
187 | | - | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
188 | 203 | | |
189 | 204 | | |
190 | 205 | | |
191 | | - | |
| 206 | + | |
192 | 207 | | |
193 | 208 | | |
194 | | - | |
| 209 | + | |
195 | 210 | | |
196 | 211 | | |
197 | | - | |
| 212 | + | |
198 | 213 | | |
199 | 214 | | |
200 | 215 | | |
| |||
229 | 244 | | |
230 | 245 | | |
231 | 246 | | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
232 | 281 | | |
233 | 282 | | |
234 | 283 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
330 | 330 | | |
331 | 331 | | |
332 | 332 | | |
333 | | - | |
334 | | - | |
| 333 | + | |
| 334 | + | |
335 | 335 | | |
336 | 336 | | |
337 | 337 | | |
| |||
453 | 453 | | |
454 | 454 | | |
455 | 455 | | |
456 | | - | |
457 | | - | |
| 456 | + | |
| 457 | + | |
458 | 458 | | |
459 | 459 | | |
460 | 460 | | |
| |||
0 commit comments