我正在尝试使用Textract对PDF文档进行OCR,当我调用StartDocumentTextDetectionAsync方法时,程序将等待几秒钟,然后失败:
“连接尝试失败,因为连接方在一段时间后未正确响应,或者建立的连接失败,因为连接的主机未能响应”
我已将要OCR的文档上载到S3存储桶,并将此信息传递到请求的DocumentLocation中。我尝试在TextractConfig中设置超时,但是在达到此超时之前会返回响应。
var config = new AmazonTextractConfig { Timeout = new TimeSpan(1, 0, 0), RegionEndpoint = RegionEndpoint.EUWest2 };
var client = new AmazonTextractClient(new BasicAWSCredentials("XXXXXXXXX", "XXXXXXXXXXXXX"), config);
var request = new StartDocumentTextDetectionRequest();
request.DocumentLocation = new DocumentLocation { S3Object = new S3Object { Bucket = "myS3bucket", Name = "My.pdf" } };
request.JobTag = "Job1";
request.NotificationChannel = new NotificationChannel { SNSTopicArn = "arn:XXXXXXXX", RoleArn = "arn:XXXXXXX" };
var result = await client.StartDocumentTextDetectionAsync(request);
每次都会返回错误:
HttpRequestException:连接尝试失败,因为一段时间后连接方未正确响应,或者建立的连接失败,因为连接的主机未能响应