Azure container apps giving: "upstream connect error.....delayed connect error: 111" error while trying to host a dockerized app

Sunraj sharma 65 Reputation points
2024-03-28T05:55:46.61+00:00

Hi, I have a docker image that I am trying to host on azure container apps which is currently giving an error. Any help would be greatly appreciated

Background:

  1. I am hosting a docker image of a geo-coder app called photon on Azure container instances. While it runs locally, when I try to run it on Azure container apps, it throws an error stating:
upstream connect error or disconnect/reset before headers. retried and the latest reset reason: remote connection failure, transport failure reason: delayed connect error: 111
  1. The image can be found here: (https://hub.docker.com/r/sunraj751/docker-photon)
  2. To locally run the docker file I use the following command (Edit entrypoint.sh script currently set to canada, downloads a good chunk of data):
docker run -d -p 2322:2322 -v "$(pwd)/data:/photon/photon_data" --name photon sunraj751/photon-geocoder:latest

Additional Details:

  1. I suspect this error has something to do with the docker file used for local vs changes needed for azure container apps hosting, so I have pasted both docker file content and entrypoint.sh file content.

Docker file content:

FROM openjdk:11-jre

# Install pbzip2 for parallel extraction
RUN apt-get update \
    && apt-get -y install \
        pbzip2 \
        wget \
    && rm -rf /var/lib/apt/lists/*

WORKDIR /photon
ADD https://github.com/komoot/photon/releases/download/0.5.0/photon-0.5.0.jar /photon/photon.jar
COPY entrypoint.sh ./entrypoint.sh

VOLUME /photon/photon_data
EXPOSE 2322

ENTRYPOINT /photon/entrypoint.sh

Entrypoint.sh file content:

  1. Currently this script points to url that downloads dataset for canada.
#!/bin/bash

# Download elasticsearch index
if [ ! -d "/photon/photon_data/elasticsearch" ]; then
    echo "Downloading search index"

    # Let graphhopper know where the traffic is coming from
    USER_AGENT="docker: tonsnoei/photon-geocoder"
    # If you want to install a specific region only, enable the line below and disable the current 'wget' row.
    # Take a look at http://download1.graphhopper.com/public/extracts/by-country-code for your country
    # wget --user-agent="$USER_AGENT" -O - http://download1.graphhopper.com/public/extracts/by-country-code/nl/photon-db-nl-latest.tar.bz2 | bzip2 -cd | tar x
    wget --user-agent="$USER_AGENT" -O - http://download1.graphhopper.com/public/extracts/by-country-code/ca/photon-db-ca-latest.tar.bz2 | bzip2 -cd | tar x
fi

# Start photon if elastic index exists
if [ -d "/photon/photon_data/elasticsearch" ]; then
    echo "Start photon"
    java -jar photon.jar $@
else
    echo "Could not start photon, the search index could not be found"
fi
Azure Container Apps
Azure Container Apps
An Azure service that provides a general-purpose, serverless container platform.
266 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Sina Salam 3,561 Reputation points
    2024-03-28T12:51:31.8166667+00:00

    Hello Sunraj sharma,

    Welcome to the Microsoft Q&A and thank you for posting your questions here.

    Sequel to your questions, I understand that when attempting to host a Dockerized Photon geocoder app on Azure Container Apps, an error occurs with the message:

    "upstream connect error or disconnect/reset before headers. retried and the latest reset reason: remote connection failure, transport failure reason: delayed connect error: 111"

    Most of all, this error suggests a connectivity issue between the Azure Container Apps instance and the upstream service hosting the Dockerized app. The exact cause of the connection problem needs to be identified and resolved to successfully deploy the app on Azure Container Apps.

    The "delayed connect error: 111" specifically indicates that the connection to the upstream service is being delayed or refused. Error code 111 typically corresponds to a connection refused error. This could be due to various reasons such as network configuration, firewall settings, or service availability.

    There three major things that came to my mind from the past experience and how I solved the similar challenges above:

    1. Ensure that your Azure Container Apps instance has proper network connectivity to access external resources. You will need to verify that there are no network restrictions or firewalls blocking outbound connections.
    2. Ensure that the service hosting the Docker image (Photon geocoder) is up and running. If it relies on any external services or resources, make sure they are also accessible and operational.
    3. Double-check your Dockerfile and entry point script to ensure they are configured correctly for deployment in Azure Container Apps. Specifically, verify that any URLs or dependencies referenced in the script are accessible from within the container.

    Aside from any regional outage issues from Azure services that could impact connectivity. Try the above and let me know your output.

    I hope this is helpful! Do not hesitate to let me know if you have any other questions.

    Please remember to "Accept Answer" if answer helped, so that others in the community facing similar issues can easily find the solution.

    Best Regards,

    Sina Salam