Azure Document Intelligence from serverless function leads to azure.core.exceptions.ServiceRequestError: EOF

ajo 50 Reputation points
2024-01-31T18:34:26.7166667+00:00

When I call the Azure Document Intelligence API from a modal serverless function, I get this "azure.core.exceptions.ServiceRequestError: EOF occurred in violation of protocol (_ssl.c:2396)" error. It works for small documents, but I face this SSL issue for longer documents that take over 2 min to process.

The Azure Document Intelligence API works fine every time when I call it from my machine or AWS ec2 instance for all document sizes, but I'm having issues when calling from a modal serverless function. How should I debug? Please help.

Here is the full error message:

Traceback (most recent call last):
Expand
  File "/pkg/modal/_container_entrypoint.py", line 372, in handle_input_exception
    yield
  File "/pkg/modal/_container_entrypoint.py", line 602, in run_input
    value = await res
  File "/root/cloud_functions_filings.py", line 171, in scrape_chunk_embed_filings
    _, tables_list, sections_list = await process_pdf(
  File "/root/services/ocr.py", line 206, in process_pdf
    for future in futures:
  File "/usr/local/lib/python3.10/concurrent/futures/_base.py", line 621, in result_iterator
    yield _result_or_cancel(fs.pop())
  File "/usr/local/lib/python3.10/concurrent/futures/_base.py", line 319, in _result_or_cancel
    return fut.result(timeout)
  File "/usr/local/lib/python3.10/concurrent/futures/_base.py", line 451, in result
    return self.__get_result()
  File "/usr/local/lib/python3.10/concurrent/futures/_base.py", line 403, in __get_result
    raise self._exception
  File "/usr/local/lib/python3.10/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/root/services/ocr.py", line 189, in 
Azure AI Document Intelligence
Azure AI Document Intelligence
An Azure service that turns documents into usable data. Previously known as Azure Form Recognizer.
1,984 questions
Azure AI services
Azure AI services
A group of Azure services, SDKs, and APIs designed to make apps more intelligent, engaging, and discoverable.
3,276 questions
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.