नोट
इस पेज तक पहुँच के लिए प्रमाणन की आवश्यकता होती है. आप साइन इन करने या निर्देशिकाओं को बदलने का प्रयास कर सकते हैं.
इस पेज तक पहुँच के लिए प्रमाणन की आवश्यकता होती है. आप निर्देशिकाओं को बदलने का प्रयास कर सकते हैं.
At a glance
Goal: Add artificial latency to API responses for testing
Time: 5 minutes
Plugins: LatencyPlugin
Prerequisites: Set up Dev Proxy
Dev Proxy allows you to simulate slow API responses by using the LatencyPlugin.
Start, by enabling the plugin in your Dev Proxy configuration file:
File: devproxyrc.json
{
"$schema": "https://raw.githubusercontent.com/dotnet/dev-proxy/main/schemas/v3.1.0/rc.schema.json",
"plugins": [
{
"name": "LatencyPlugin",
"enabled": true,
"pluginPath": "~appFolder/plugins/DevProxy.Plugins.dll",
"configSection": "latencyPlugin"
}
],
"urlsToWatch": []
}
Next, specify the minimum and maximum delay (in milliseconds) to simulate for your API.
File: devproxyrc.json
"latencyPlugin": {
"minMs": 200,
"maxMs": 10000
}
The complete configuration file looks like this.
File: devproxyrc.json
{
"$schema": "https://raw.githubusercontent.com/dotnet/dev-proxy/main/schemas/v3.1.0/rc.schema.json",
"plugins": [
{
"name": "LatencyPlugin",
"enabled": true,
"pluginPath": "~appFolder/plugins/DevProxy.Plugins.dll",
"configSection": "latencyPlugin"
}
],
"urlsToWatch": [
"https://api.example.com/*"
],
"latencyPlugin": {
"$schema": "https://raw.githubusercontent.com/dotnet/dev-proxy/main/schemas/v3.1.0/latencyplugin.schema.json",
"minMs": 200,
"maxMs": 10000
}
}
When a response is delayed, Dev Proxy displays the total duration it was delayed for in the console output.
See also
- LatencyPlugin - Full reference
- Test my app with random errors - Simulate API failures
- Simulate Rate-Limit API responses - Test rate limiting
- Use Dev Proxy in CI/CD - Automate resilience testing in your pipeline
- Glossary - Dev Proxy terminology