1

Trying a python program, using hugging face transformers & faiss. I was able to use the API successfully while testing locally. But while testing the same inside docker, the api executes successfully the first time & the I get a Error : Socket hang up when trying via postman. Post which the docker exits.

What I have tried so far:

  1. Adding '/' at the end of the URL
  2. Adding host = '0.0.0.0'
  3. Trying torch version == 1.11.0
  4. Changed Postman timeout settings & Max response size & Unchecked 'Send Postman token header'
  5. Tried the API using Thunder Client & cURL.

Docker File :

FROM python:3.8.0
COPY . .
RUN pip install --upgrade pip
RUN pip install --no-cache-dir -r requirements.txt
RUN python3 -m spacy download en_core_web_sm
CMD [ "python3", "-m" , "flask", "run", "--host", "0.0.0.0", "--port=8002"]
EXPOSE 8002

Log details : Successful API response:

INFO:werkzeug:172.17.0.1 - - [14/Nov/2022 11:33:55] "POST /api/v1/quotes3/ HTTP/1.1" 200 -
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): huggingface.co:443
DEBUG:urllib3.connectionpool:https://huggingface.co:443 "HEAD /sentence-transformers/multi-qa-mpnet-base-dot-v1/resolve/main/tokenizer_config.json HTTP/1.1" 200 0
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): huggingface.co:443
DEBUG:urllib3.connectionpool:https://huggingface.co:443 "HEAD /sentence-transformers/multi-qa-mpnet-base-dot-v1/resolve/main/config.json HTTP/1.1" 200 0 

Unsuccessful API response :

INFO:werkzeug:172.17.0.1 - - [14/Nov/2022 11:34:21] "POST /api/v1/quotes3/ HTTP/1.1" 200 -
(test2) Meghas-Mac:test2 mj$
Megha John
  • 153
  • 1
  • 12
  • You need to post debugging details, including the flask server log. – relent95 Nov 14 '22 at 09:25
  • @relent95 : Logging details added. Let me know if I can give you more details. this fails only within a docker, and the API works fine outside a docker. – Megha John Nov 14 '22 at 11:42
  • It seems some native module caused the Python process to be terminated. Run a GDB process inside the docker container with ```docker exec```. See [this question](https://stackoverflow.com/questions/21395106/how-can-i-gdb-attach-to-a-process-running-in-a-docker-container). Don't forget to do ```apt update``` and ```apt install gdb``` inside the container. – relent95 Nov 14 '22 at 14:08
  • please add your python flask app code and your docker container logs – Ryabchenko Alexander Nov 19 '22 at 20:29

0 Answers0