We have deployed some APIs (few developed using Node.js/Express.js and others using Python Quart). All out our APIs are deployed using the Azure containerized instance. We have set-up periodic API monitoring through Postman. The APIs fail about 20% of the time with Error: Socket Hang Up. We never encountered this issue in development region or when accessing the APIs via browsers. What could cause this Socket Hang Up issue and how do we overcome it?
Our Node.js APIs Dockerfiles are set-up as below:
FROM node:16
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
RUN rm -rf .env
RUN mv production.env .env
#ENV PORT=5000
EXPOSE 5000
CMD ["npm", "run", "prod"]
The Python Quart APIs Dockerfiles are set-up as below:
FROM continuumio/miniconda3
COPY . /api/
WORKDIR /api/src
RUN conda env create -f /api/environment.yml
COPY entrypoint.sh ./
RUN chmod +x ./entrypoint.sh
ENTRYPOINT ["./entrypoint.sh"]
EXPOSE 5000
entrypoint.sh
#!/bin/bash --login
set +euo pipefail
conda activate python_env_name
set -euo pipefail
exec hypercorn --bind 0.0.0.0:5000 QuartAPI:app