Cloudmersive / Cloudmersive.APIClient.Java

Cloudmersvie API Client for Java. Uses OkHttp API client library.
Apache License 2.0
13 stars 5 forks source link

java.net.SocketTimeoutException when upload image #1

Open kofinder opened 5 years ago

kofinder commented 5 years ago

I cannot upload image file and then I use Free Tier plan but i can upload less than 1MB image file. image size -> 1.9MB image type -> jpg

public String cloudOcrService(File file) throws IOException {
        final ApiClient client = new ApiClient();
        final ImageOcrApi apiInstance = new ImageOcrApi();
        final ApiClient defaultClient = Configuration.getDefaultApiClient();
        final StringBuilder sb = new StringBuilder();

        client.addDefaultHeader(OCRConstant.CLOUD_MERSIVE_API_KEY, OCRConstant.CLOUD_MERSIVE_API_SERECT);
        ApiKeyAuth apikey = (ApiKeyAuth) defaultClient.getAuthentication(OCRConstant.CLOUD_MERSIVE_API_KEY);
        apikey.setApiKey(OCRConstant.CLOUD_MERSIVE_API_SERECT);

        try {
            ImageToTextResponse result = apiInstance.imageOcrPost(file, OCRConstant.CLOUD_MERSIVE_LANGUAGE, OCRConstant.CLOUD_MERSIVE_PROCESS);
            sb.append(result.getTextResult().replaceAll("\n", ""));
        } catch (ApiException e) {
            System.err.println("Exception when calling OCR Service ====>:"+ e.getMessage());
            e.printStackTrace();
        }

        return sb.toString();
    }

I getting those error when upload image. pls help me thanks

com.cloudmersive.client.invoker.ApiException: java.net.SocketTimeoutException: timeout at com.cloudmersive.client.invoker.ApiClient.execute(ApiClient.java:845) at com.cloudmersive.client.ImageOcrApi.imageOcrPostWithHttpInfo(ImageOcrApi.java:1267) at com.cloudmersive.client.ImageOcrApi.imageOcrPost(ImageOcrApi.java:1251)

Michi-2142 commented 4 years ago

Any news on this issue?