Skip to content

java.net.SocketTimeoutException when upload image #1

@kofinder

Description

@kofinder

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions