GenericError when stream is OwnStream is set to false

Discussions about DocuVieware integration in GdPicture.NET.
Post Reply
lchorley
Posts: 19
Joined: Tue Mar 22, 2022 3:10 pm

GenericError when stream is OwnStream is set to false

Post by lchorley » Fri Feb 02, 2024 4:21 pm

Hello team DocuVieware,

We recently encountered a "GenericError" and identified the modification that caused it. We were wondering if you had any ideas on why it happens. We thought, in sending you a message, at best we could improve something, at worst we could learn something :)

We can't give you a reproduction, but we can describe the contexte in case you feel like trying to do a repro:
Running locally on a windows machine from Visual Studio in a ASP.Net cshtml .NET6 project I don't have any problem.
It's only once that project is packed up into a docker image and deployed to an AKS in Azure that the problem occurs (container's base image : mcr.microsoft.com/dotnet/aspnet:6.0)
The document that produced the error was a super simple docx with just a single line of text, though we're not convinced that this is at fault.

The code that produced the problem is the following, though we haven't tested it in isolation, so were not sure that this is sufficient. Though we can't imagine that anything else could be at fault.

The only changes are the two sets of [.../...]. If the using is in place in the method GetStream, and the boolean (OwnStream) is set to false, then status is GenericError. If there is no using on the Stream, and the parameter is true, then all is well.

Code: Select all

    public async Task<bool> GetStream(Uri uri, Action<Stream> callback)
    {
        try
        {
            using HttpResponseMessage result = await _httpClient.GetAsync(uri);
            [using/] Stream stream = await result.Content.ReadAsStreamAsync();

            if (result.StatusCode != HttpStatusCode.OK)
            {
                return false;
            }

            callback(stream);

            return true;
        }
        catch (TaskCanceledException)
        {
            return false;
        }
    }
	
var status;
bool success = await GetStream(AddressAsUri, documentStream =>
{
	status = docuVieware.LoadFromStream(documentStream, [false/true], DocumentName);
});

Thank you and looking forward to hearing what you think,

Loren

myrnaed
Posts: 1
Joined: Thu Mar 21, 2024 11:09 am

Re: GenericError when stream is OwnStream is set to false

Post by myrnaed » Thu Mar 21, 2024 11:12 am

I am encountering the same error. Did you find the solution?
geometry dash scratch

clamlithe
Posts: 1
Joined: Tue May 07, 2024 10:58 am

Re: GenericError when stream is OwnStream is set to false

Post by clamlithe » Tue May 07, 2024 11:00 am

The issue you're encountering with the "GenericError" status when using the GetStream method in your ASP.NET Core 6 project deployed to an Azure Kubernetes Service (AKS) could be related to how the stream is handled or closed.
Resource Management: When dealing with streams, it's crucial to properly manage and dispose of them to avoid resource leaks. In your GetStream method, you're using the using statement to dispose of the Stream object after it's no longer needed. However, depending on how the callback function is implemented and how the stream is used within it, there could be scenarios where the stream is prematurely closed or disposed of, leading to unexpected behavior.
Callback Function: Ensure that the callback function provided to the GetStream method doesn't inadvertently close or dispose of the stream within its implementation. If the docuVieware.LoadFromStream method closes the stream after consuming it, it could lead to issues if the stream is disposed of prematurely. snow rider
Asynchronous Behavior: Since you're using asynchronous methods (HttpClient.GetAsync and Content.ReadAsStreamAsync), ensure that the asynchronous operations are awaited properly and that any callback functions or subsequent operations depending on the stream are executed asynchronously as well.
Error Handling: Ensure that any exceptions thrown within the callback function are properly handled to prevent them from propagating and causing unexpected behavior.
Logging and Debugging: Add logging statements and debug output to trace the execution flow and identify any potential issues or unexpected behavior. This can help pinpoint the root cause of the "GenericError" status.

Post Reply

Who is online

Users browsing this forum: Amazon [Bot] and 2 guests