SOCKET TIMEOUT ERROR - Zoho Catalyst OCR

SOCKET TIMEOUT ERROR - Zoho Catalyst OCR

Hi guys,

I am getting a "SOCKET TIMEOUT ERROR" when trying to OCR files using Python & Zoho Catalyst OCR

It works for some requests so i know the code works, but when it is a longer scanned pdf for example, it times out.

I would really appreciate your help getting this fixed! The error is: Failed OCR request: {"status":"failure","data":{"message":"Request timed out. Try again","error_code":"SOCKET_TIMEOUT"}}

My code is:

from flask import Flask, request, jsonify
import os
import requests

app = Flask(__name__)

*Auth Token Removed*

@app.route('/')
def index():
    return 'Hello World!'

@app.route('/process_ocr', methods=['POST'])
def process_ocr():
    access_token = get_oauth_token()
    if not access_token:
        return jsonify({'message': 'Failed to authenticate with Zoho OAuth'}), 500

    # Hardcoded image link for testing
    image_link = "*Zoho Workdrive Link removed*?directDownload=true"
   
    # Download the image from the given link
    image_response = requests.get(image_link)
    if image_response.status_code != 200:
        return jsonify({'message': 'Failed to download image', 'status': image_response.status_code}), 500

    # Prepare the OCR API call
    ocr_headers = {
        'Authorization': f'Zoho-oauthtoken {access_token}'
    }
    ocr_files = {
        'image': ('image.pdf', image_response.content, 'application/pdf'),
        'language': (None, 'eng,spa')
    }
    try:
        ocr_response = requests.post(
            headers=ocr_headers,
            files=ocr_files,
            timeout=200  # Set timeout to 60 seconds
        )
    except requests.exceptions.Timeout:
        return jsonify({'message': 'OCR request timed out, please try again later'}), 504

    if ocr_response.status_code != 200:
        print("Failed OCR request:", ocr_response.text)
        return jsonify({'message': 'OCR request failed', 'status': ocr_response.status_code}), 500

    ocr_data = ocr_response.json()
    print("OCR Response:", ocr_data)
    ocr_text = ocr_data.get('data', {}).get('text', '')
   
    # Post the OCR text to the webhook
    webhook_url = '*Webhook URL Removed*'
    webhook_response = requests.post(webhook_url, json={'text': ocr_text})
   
    return jsonify({
        'message': 'OCR processing completed',
        'status': webhook_response.status_code,
        'OCR Text': ocr_text,
        'OCR Data': ocr_data  # Optionally include full OCR response for debugging
    })

if __name__ == '__main__':
    app.run(host='0.0.0.0', port=int(os.getenv('X_ZOHO_CATALYST_LISTEN_PORT', 9000)), debug=True)


    • Topic Participants

    • Lewis

    • Announcements

    • Introducing Catalyst 3.0: The agent-ready full-stack cloud!

      Hi everyone! Catalyst 3.0 is here, bringing a major shift in how you can build and ship applications on Catalyst. With MCP connectors, agent skills, native agent plugins, a non-interactive CLI, zero egress, and 30+ services unified on one platform, Catalyst
    • [Webinar] Build smarter HR - Payroll Automation

      If your HR and payroll teams are still relying on manual exports, spreadsheet reconciliations, or constant back-and-forth coordination to keep employee data aligned, this session is for you. We’re hosting a live webinar featuring Kyle Ferrara , CTO of
    • [Webinar] How Raptee.HV accelerates its EV platform

      Curious about how EV platforms work behind the scenes? What does it actually take to run an EV platform from onboarding users to managing connected vehicles and deploying updates seamlessly? In this session, Raptee.HV shares how their platform is built
    • [Webinar] Deploy Docker apps with AppSail's custom runtime | Feb. 19

      Hi everyone, Join us on February 19, 2026 at 8–9 PM IST for a live Catalyst webinar demonstrating how to deploy OCI-compliant Docker images with AppSail's custom runtime. You’ll learn how to: Package your apps as Docker containers Deploy via CLI or connect
    • Catalyst backs Vite.js!

      Hi everyone, We're happy to support the open-source ecosystem that powers modern web development! If you’re building apps with Vite, Catalyst Slate is your go-to platform to deploy blazing-fast frontend apps with ease, scalability, and zero infrastructure

      Catalyst Community