You need to enable JavaScript to run this app.
最新活动
大模型
产品
解决方案
定价
生态与合作
支持与服务
开发者
了解我们

使用VZAAR .NET API v2.0无法上传视频?API调用遇加载异常

Troubleshooting VZAAR .NET API Stuck on HttpClient.SendAsync After AWS S3 Update

Let's walk through how to fix this frustrating issue where your VZAAR .NET API call hangs indefinitely at HttpClient.SendAsync(msg). First, here's a clear recap of your scenario:

We have upload/view subscription permissions for VZAAR. Recently, VZAAR updated its API for AWS S3 integration, and our .NET API is no longer working properly: when calling the HttpSendAsync method in the Client.cs class, the page keeps loading indefinitely, with the last executed code being HttpResponseMessage response = await this.httpClient.SendAsync(msg);.

The VZAAR web-based test tool works fine, but official support suggested using PHP, which we're not familiar with.

Here's the problematic method code for reference:

internal async virtual Task<string> HttpSendAsync(HttpRequestMessage msg) { 
    if (CfgUrlAuth == true) { 
        Dictionary<string, string> query = new Dictionary<string, string> (); 
        query.Add ("client_id", client_id); 
        query.Add ("auth_token", auth_token); 
        Uri uri = BuildQuery (msg.RequestUri, query); 
        msg.RequestUri = uri; 
    } else { 
        msg.Headers.Add ("X-Client-Id", client_id); 
        msg.Headers.Add ("X-Auth-Token", auth_token); 
    } 
    #if DEBUG 
        Debug.WriteLine ("\n\nRequest Method"); 
        Debug.WriteLine (msg.Method.ToString()); 
        Debug.WriteLine ("Request Uri"); 
        Debug.WriteLine (msg.RequestUri.AbsoluteUri); 
        Debug.WriteLine ("Request Headers"); 
        Debug.WriteLine (msg.Headers.ToString().Trim()); 
        if (msg.Content != null) { 
            Debug.WriteLine ("Request Content"); 
            string debug_content = await msg.Content.ReadAsStringAsync (); 
            Debug.WriteLine (debug_content); 
        } 
    #endif 
    HttpResponseMessage response = await this.httpClient.SendAsync (msg); 
    ValidateHttpResponse (response); 
    httpHeaders = response.Headers; 
    var bodyResponse = await response.Content.ReadAsStringAsync (); 
    return bodyResponse; 
}

Now let's dive into the most likely fixes, ordered by how common they are:

  • Fix Async/Await Deadlocks First
    This is the #1 culprit for hanging async calls in .NET. If you're calling this method from a synchronous context (like old ASP.NET Web Forms, or using .Wait()/.Result() upstream), you're probably hitting a deadlock. Try adding ConfigureAwait(false) to the SendAsync call to avoid capturing the sync context:

    HttpResponseMessage response = await this.httpClient.SendAsync(msg).ConfigureAwait(false);
    

    Also make sure all code calling HttpSendAsync uses await instead of blocking on the task.

  • Check HttpClient Timeout & Configuration
    S3 uploads can take longer than the default HttpClient timeout (which is 100 seconds). If the request is timing out silently, increase the timeout explicitly:

    this.httpClient.Timeout = TimeSpan.FromMinutes(5); // Adjust based on your typical upload size
    

    Double-check that no proxy or firewall is blocking the request (since the web tool works, this is less likely, but worth ruling out).

  • Compare Your Request to the Web Tool's Request
    Your debug logs already print request details, but capture the full raw request (headers, content, URI) from your app and compare it to what the VZAAR web test tool sends. Use tools like Fiddler or browser dev tools to inspect the web tool's network traffic.
    Pay extra attention to:

    • Authentication headers (ensure X-Client-Id and X-Auth-Token are correctly formatted, no extra spaces, proper casing)
    • Request URI (VZAAR might have updated the endpoint for S3-related calls)
    • Content type and encoding (S3 has strict rules for upload payloads)
  • Test with a Minimal Console App
    Create a tiny console app that makes the exact same API call with the same credentials. This will tell you if the issue is tied to your main app's context (like dependency injection, async context) or the API call itself. If the console app works, you know the problem is in how your main app is handling the async call.

  • Verify VZAAR's Updated API Specs
    Even though official support suggested PHP, double-check VZAAR's updated docs for any breaking changes to authentication or request formatting for S3 integration. Sometimes APIs switch to signed requests for S3, which might require additional steps your current code isn't handling.

内容的提问来源于stack exchange,提问作者Noshad

火山引擎 最新活动