cloudconvert / cloudconvert-dotnet

CloudConvert .NET SDK
Other
20 stars 15 forks source link

CreateJobAsync No Response #14

Open wickedwick opened 2 years ago

wickedwick commented 2 years ago

I have a simple conversion use case. But it seems that CreateJobAsync hangs. During troubleshooting, I implemented creating a job via RestSharp and it completes just fine. I am seeing the same behavior with UploadAsync, and WaitJobAsync. Any idea what I'm doing wrong here?

var job = await _cloudConvert.CreateJobAsync(new JobCreateRequest
{
    Tasks = new
    {
        import_it = new ImportUploadCreateRequest(),
        convert = new ConvertCreateRequest
        {
            Input = "import_it",
            Input_Format = inputFormat,
            Output_Format = outputFormat
        },
        export_it = new ExportUrlCreateRequest
        {
            Input = "convert"
        }
    }
});

var uploadTask = job.Data.Tasks.FirstOrDefault(t => t.Name == "import");
var bytes = File.StoredFileAsByteArray(storedFile);

await _cloudConvert.UploadAsync(
    uploadTask?.Result.Form.Url.ToString(),
    bytes,
    storedFile.Name,
    uploadTask?.Result.Form.Parameters);

job = await _cloudConvert.WaitJobAsync(job.Data.Id); // Wait for job completion

var exportTask = job.Data.Tasks.FirstOrDefault(t => t.Name == "export_it");

var fileExport = exportTask.Result.Files.FirstOrDefault();
return fileExport.Url.ToString();
josiasmontag commented 2 years ago

You might need to use a debugger and check how exactly the API response looks like etc.

wickedwick commented 2 years ago

I've been trying that to no avail. When I attach and set a breakpoint on the CreateJobAsync method then step into or over, nothing happens. There is no response, no exception is thrown, nothing happens.

wickedwick commented 2 years ago

So it seems that I'm getting a deadlock on var response = await base.SendAsync(request, cancellationToken); in the WebApiHandler. Since I don't have a pdb of the SDK to debug, I implemented it in my project to step through. When I change it to var response = base.SendAsync(request, cancellationToken).Result;, then I avoid the deadlock and can see a response.