Failed to send request to Form Recognizer. Please check your Form Recognizer service settings and network connection.

Valon Rinaldi 55 Reputation points
2023-08-15T13:36:26.09+00:00

I am trying to setup custom template with studio according this documentation: https://learn.microsoft.com/en-us/azure/ai-services/document-intelligence/containers/install-run?view=doc-intel-3.1.0&tabs=custom

But as soon as I send a document for analyzing I receive the following error:

User's image

I see in the logs that the request to the nginx and layout has been successfully

Logs on nginx

100.71.2.2 - - [15/Aug/2023:13:17:56 +0000] "OPTIONS /formrecognizer/documentModels/prebuilt-layout:analyze?api-version=2022-08-31&stringIndexType=utf16CodeUnit HTTP/2.0" 200 0 "https://studio.mydomain.com/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36 Edg/115.0.1901.183" "-"

92023/08/15 13:17:56 [warn] 23#23: *1 a client request body is buffered to a temporary file /tmp/client_temp/0000000001, client: 100.71.2.2, server: studio-service.mydomain.net, request: "POST /formrecognizer/documentModels/prebuilt-layout:analyze?api-version=2022-08-31&stringIndexType=utf16CodeUnit HTTP/2.0", host: "studio-service.mydomain.net", referrer: "https://studio.mydomain.net/"

10100.71.2.2 - - [15/Aug/2023:13:17:56 +0000] "POST /formrecognizer/documentModels/prebuilt-layout:analyze?api-version=2022-08-31&stringIndexType=utf16CodeUnit HTTP/2.0" 202 0 "https://studio.mydomain.net/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36 Edg/115.0.1901.183" "-"

logs on layout

info: formrecognizerlayout[0]
      Work item xxx Completed. SubscriptionId='' RequestId='xxx' Timestamp='' buildVersion='xxx' hostId='xxx' serviceName='formrecognizerlayout' namespace='vdi' Namesapce='vdi' fileSizeInBytes='189628' processedPageIndex='0' toSecondaryQueue='False' totalPageCount='1' fileType='Pdf' apiName='layout-2022-08-31' ocrModelName='2022-08-31' scenario='fr_async_layout' resultNameEnum='UpstreamFRResult' ocrResolution='Standard' workItemId='xxx'

I have setup 2 nginx server:

studio.mydomain.net -> proxy for studio

studio-service.mydomain.net -> proxy for custom-model, layout etc.

I do not see any exception on studio logs. How can I identify the root cause of the issue? How do I enable more logs for studio? What could be the issue?

Azure AI Document Intelligence
Azure AI Document Intelligence
An Azure service that turns documents into usable data. Previously known as Azure Form Recognizer.
2,102 questions
{count} vote

1 answer

Sort by: Most helpful
  1. Valon Rinaldi 55 Reputation points
    2023-09-15T14:43:40.4666667+00:00

    @VicRem

    Yes, the problem was because of the https definition of the server:

    nginx.conf {
    
    ...
    
       server { 
    
           listen 443 ssl http2 default_server;
    
           ...
    
      }
    
    ...
    
    }
    

    So when studio is doing a call to the service endpoints it uses https schema and the async endpoint, e.g. https://localhost:5000/formrecognizer/documentModels/prebuilt-layout:analyze

    The async endpoint of formrecognizer, custom-template etc. are returning an header with the paramter "Operation-Location", which cointains the url to check the result status. The issue was that the url in the Operation-Location header was http instead of https, e.g.

    http://localhost:5000/formrecognizer/documentModels/prebuilt-layout/analyzeResults/id123456/

    The UI tries then to get the result with the wrong shema and the error occures.

    To resolve the issue I added a mapper and changed the returned header of the upstream server:

    nginx.conf {
    
       ...
       
       map $upstream_http_operation_location $operation_location {             
    		"~^http://(.*)$" "https://$1";         
       }
    
       server { 
    
           listen 443 ssl http2 default_server;
           ...
    		
    	   location /formrecognizer/documentModels/prebuilt-layout {
    		    ...
    
    	   		add_header 'Operation-Location' $operation_location always;
    	   }
    
      }
    
    ...
    
    }
    

    So in case there is a response header from upstream server with http it will map the schema to https.

    You should also check the network traffic in develop mode, because the UI waits until the result is successfully and saves the result afterwards, i.e. if you don't wait for the result and close the browser, nothing will be saved and you have to run it again.

    2 people found this answer helpful.
    0 comments No comments

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.