Aspose.PDF self-hosted container report 500 ERROR: `Object reference not set to an instance of an object.`

Here is my docker-compose.yml configuration

services:
  AsposePdfCloud:
    image: aspose/pdf-cloud
    container_name: 'AsposePdfCloud'
    ports: ["8083:5000"]
    volumes: [
      "/data/fonts:/fonts",
      "/data/convert:/data",
    ]
    environment:
      "ASPOSE_PDF_CLOUD_SELFHOST_PUBLIC_KEY": $ASPOSE_PUB_KEY
      "ASPOSE_PDF_CLOUD_SELFHOST_PRIVATE_KEY": $ASPOSE_PRIV_KEY

and my python code:

import asposepdfcloud

if __name__ == "__main__":
    pdf_api_client = asposepdfcloud.ApiClient('', '', 'http://0.0.0.0:8083/v3.0/', True)
    pdf_api = asposepdfcloud.PdfApi(pdf_api_client)
    ret = pdf_api.put_pdf_in_request_to_doc(
        "/data/test.docx",
        format="docx",
        file="7ages.pdf",
    )

When running this code, the following error is reported:

asposepdfcloud.rest.ApiException: (500)
Reason: Internal Server Error
HTTP response headers: HTTPHeaderDict({'Content-Type': 'application/json; charset=utf-8', 'Date': 'Fri, 27 Sep 2024 03:29:21 GMT', 'Server': 'Kestrel', 'Transfer-Encoding': 'chunked'})
HTTP response body: {
  "RequestId": "424b9c68-0d38-4cd1-b3fc-6d5554841da3",
  "Error": {
    "Code": "internalError",
    "Message": "Object reference not set to an instance of an object.",
    "Description": "Operation Failed. Internal error.",
    "DateTime": "2024-09-27T03:29:21.8796034Z",
    "InnerError": null
  }
}

@aizpy
Please share your input document.

7ages.pdf (406.9 KB)

This is the document mentioned in the code. In fact, I have tried several documents and all of them give the same problem.

@kirill.novinskiy

Try using the docker image aspose/pdf-cloud:24.9.0. The code was tested on aspose-pdf-cloud/aspose-pdf-cloud-python: Python library for communicating with the Aspose.PDF Cloud API (github.com) version 24.9.0.
Also try to change url to http://127.0.0.1:8083/v3.0/.

        pdf_api_client = asposepdfcloud.ApiClient('', '', 'http://127.0.0.1:5000/v3.0/', True)
        pdf_api = asposepdfcloud.PdfApi(pdf_api_client)
        ret = pdf_api.put_pdf_in_request_to_doc(
            "/data/test.docx",
            format="docx",
            file="test_data/7ages.pdf",

I tried it the way you said and the error is still the same. I changed the version of the docker image to 24.9.0, I also made sure that the version number of asposepdfcloud is 24.9.0, I even changed the port number of the bindings to 5000 in your example, but it still doesn’t work. I checked the docker logs and there are only the following lines:

warn: Microsoft.AspNetCore.DataProtection.Repositories.FileSystemXmlRepository[60]
      Storing keys in a directory '/root/.aspnet/DataProtection-Keys' that may not be persisted outside of the container. Protected data will be unavailable when container is destroyed.
warn: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[35]
      No XML encryptor configured. Key {0cad6a99-58eb-4da8-b7a9-bda3baf5a75e} may be persisted to storage in unencrypted form.
warn: Microsoft.AspNetCore.Server.Kestrel[0]
      Overriding address(es) 'http://+:80'. Binding to endpoints defined via IConfiguration and/or UseKestrel() instead.
warn: Microsoft.AspNetCore.HttpsPolicy.HttpsRedirectionMiddleware[3]
      Failed to determine the https port for redirect.

Is there any way I can output more debuggable logs?

@aizpy
it looks like your request is not being processed using the aspose-cloud docker image. Do you have any other services running in parallel with aspose-cloud? If you have more than one network card, check the ip address that the docker container uses.

-> sudo docker container list
CONTAINER ID   IMAGE                     COMMAND                  CREATED        STATUS              PORTS
                NAMES
287e3eae6399   aspose/pdf-cloud:24.9.0   "/bin/sh -c ./Aspose…"   12 hours ago   Up About a minute   0.0.0.0:5000->5000/tcp, :::5000->5000/tcp   AsposePdfCloud
(doc) ➜  document sudo docker exec -it AsposePdfCloud /bin/sh
# ls
AWSSDK.Core.dll                                    Microsoft.Extensions.PlatformAbstractions.dll
AWSSDK.S3.dll                                      Microsoft.IdentityModel.JsonWebTokens.dll
AppData                                            Microsoft.IdentityModel.Logging.dll
Aspose                                             Microsoft.IdentityModel.Protocols.OpenIdConnect.dll
Aspose.PDF.dll                                     Microsoft.IdentityModel.Protocols.dll
Aspose.Pdf.Cloud.Fonts.deps.json                   Microsoft.IdentityModel.Tokens.dll
Aspose.Pdf.Cloud.Fonts.dll                         Microsoft.Win32.SystemEvents.dll
Aspose.Pdf.Cloud.Fonts.pdb                         Microsoft.WindowsAzure.Storage.dll
Aspose.Pdf.Cloud.Web                               NJsonSchema.dll
Aspose.Pdf.Cloud.Web.deps.json                     NSwag.Annotations.dll
Aspose.Pdf.Cloud.Web.dll                           NSwag.AspNetCore.dll
Aspose.Pdf.Cloud.Web.pdb                           NSwag.Core.dll
Aspose.Pdf.Cloud.Web.runtimeconfig.json            NSwag.SwaggerGeneration.AspNetCore.dll
Aspose.Pdf.Cloud.deps.json                         NSwag.SwaggerGeneration.WebApi.dll
Aspose.Pdf.Cloud.dll                               NSwag.SwaggerGeneration.dll
Aspose.Pdf.Cloud.dll.config                        Newtonsoft.Json.Bson.dll
Aspose.Pdf.Cloud.pdb                               Newtonsoft.Json.dll
Aspose.Pdf.Cloud.xml                               Ninject.Web.Common.dll
BouncyCastle.Crypto.dll                            Ninject.Web.WebApi.dll
Box.V2.Core.dll                                    Ninject.dll
DotNetZip.dll                                      Syntellect.Typography.GlyphLayout.dll
Dropbox.Api.dll                                    Syntellect.Typography.OpenFont.dll
Dynabic.ProductsRestApi.Common.deps.json           System.Configuration.ConfigurationManager.dll
Dynabic.ProductsRestApi.Common.dll                 System.Diagnostics.DiagnosticSource.dll
Dynabic.ProductsRestApi.Common.pdb                 System.Diagnostics.PerformanceCounter.dll
Dynabic.Storage.deps.json                          System.Drawing.Common.dll
Dynabic.Storage.dll                                System.IdentityModel.Tokens.Jwt.dll
Dynabic.Storage.pdb                                System.Net.Http.Formatting.dll
Dynabic.Storage.xml                                System.Net.Http.Json.dll
Google.Apis.Auth.PlatformServices.dll              System.Runtime.Caching.dll
Google.Apis.Auth.dll                               System.Security.Cryptography.ProtectedData.dll
Google.Apis.Core.dll                               System.Security.Permissions.dll
Google.Apis.Drive.v3.dll                           System.Text.Encoding.CodePages.dll
Google.Apis.dll                                    System.Text.Encodings.Web.dll
IdentityModel.AspNetCore.OAuth2Introspection.dll   System.Text.Json.dll
IdentityModel.dll                                  System.Web.Http.dll
Microsoft.AspNetCore.Authentication.JwtBearer.dll  System.Windows.Extensions.dll
Microsoft.AspNetCore.JsonPatch.dll                 app.config
Microsoft.AspNetCore.Mvc.NewtonsoftJson.dll        appsettings.Development.json
Microsoft.AspNetCore.Mvc.Versioning.dll            appsettings.json
Microsoft.DotNet.PlatformAbstractions.dll          packages.config
Microsoft.Extensions.DependencyModel.dll           web.config
Microsoft.Extensions.Logging.Abstractions.dll

@aizpy
We have noticed the reported issues and logged the following tickets in our issue tracking system for further investigation and rectification. We will notify you as soon as these issues are resolved.

PDFCLOUD-4489: Self Hosing - Object reference not set to an instance of an object

@aizpy
The bug has been investigated and tested. Try to run the aspose/pdf-cloud:24.9.0 image with the --env ASPNETCORE_ENVIRONMENT=Development parameter to display AspNetCore informational messages.
If you don’t see information messages in the docker log command, please share the command to start the container.

1 Like

Not sure if this is resolved, but I had similar problem and it turns out that the docker volumes are not mounted correctly. Once the volumes are setup correctly, the problem disappeared.

@kirill.novinskiy I am trying to run the latest version of aspose/pdf-cloud container in azure web app. I found that when I mount azure files (storage account via SMB) on /data only. The API works without problem. However when I also mount azure files on /fonts. I would get the same error. What is the /fonts folder for? Do we actually need to mount that?

@ccrarthur
Can you attach the error log entries from the container?