Skip to content

Latest commit

 

History

History
80 lines (63 loc) · 2.5 KB

File metadata and controls

80 lines (63 loc) · 2.5 KB

Complete Timeout Removal Configuration

All HTTP timeouts have been completely disabled for debugging with breakpoints.

Console App (Client) - No Timeouts

1. Program.cs HttpClient Configuration

builder.Services.AddHttpClient<ChatService>((serviceProvider, client) =>
{
    // Force infinite timeout for debugging - no timeouts anywhere
    client.Timeout = System.Threading.Timeout.InfiniteTimeSpan;
})

2. ChatService.cs Constructor Override

public ChatService(HttpClient httpClient, IOptions<WebApiConfiguration> webApiConfig)
{
    _httpClient = httpClient;
    _apiBaseUrl = webApiConfig.Value.ChatUrl;
    
    // Remove ALL timeouts for debugging with breakpoints
    _httpClient.Timeout = System.Threading.Timeout.InfiniteTimeSpan;
    Console.WriteLine("🔧 HttpClient timeout: DISABLED (infinite timeout for debugging)");
}

Web API (Server) - No Timeouts

1. Kestrel Server Configuration

// Configure Kestrel with no timeouts for debugging
builder.Services.Configure<Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServerOptions>(options =>
{
    options.Limits.KeepAliveTimeout = System.Threading.Timeout.InfiniteTimeSpan;
    options.Limits.RequestHeadersTimeout = System.Threading.Timeout.InfiniteTimeSpan;
});

2. Azure OpenAI HttpClient Configuration

// Configure Azure OpenAI with NO timeout for debugging
var httpClient = new HttpClient();
httpClient.Timeout = System.Threading.Timeout.InfiniteTimeSpan; // No timeout for debugging with breakpoints

Verification

When running the console app, you should see:

🔧 HttpClient timeout: DISABLED (infinite timeout for debugging)

Benefits for Debugging

No 100-second HttpClient timeout
No Kestrel server timeouts
No Azure OpenAI API timeouts
Can set breakpoints anywhere without timeout errors
Can debug step-by-step through Semantic Kernel processes
Can pause execution indefinitely during debugging

Production Considerations

⚠️ Remember to restore appropriate timeouts in production:

  • Client timeouts: 30-300 seconds depending on use case
  • Server timeouts: 30-60 seconds for request headers/keep-alive
  • Azure OpenAI timeouts: 120-300 seconds for LLM calls

Quick Toggle for Production

To quickly restore timeouts, change:

// Development (no timeouts)
client.Timeout = System.Threading.Timeout.InfiniteTimeSpan;

// Production (with timeouts)
client.Timeout = TimeSpan.FromSeconds(300); // 5 minutes