Back

[SOLVED] Operation Timed Out when Executing Function

  • 1
  • Databases
  • Functions
  • Cloud
Sandeep K. Dasari
8 Jun, 2023, 17:32

I have created it and it's my local machine IPv4 address right?

TL;DR
Issue: Operation Timed Out when Executing Function Solution: The issue was with the endpoint. The correct endpoint to set is `https://cloud.appwrite.io/v1`. The problem was resolved after setting the endpoint correctly. Additionally, it was suggested to increase the function timeout to 4 minutes if the execution was taking longer than expected. It was also recommended to remove any unnecessary events that could interfere with the execution.
Sandeep K. Dasari
8 Jun, 2023, 17:32

Yeah right sir, I haven;t any of it

Sandeep K. Dasari
8 Jun, 2023, 17:33

I have created variables in my functions settings

Sandeep K. Dasari
8 Jun, 2023, 17:33

and given access to all

Sandeep K. Dasari
8 Jun, 2023, 17:33

and I have created api key which access functions and databases

Sandeep K. Dasari
8 Jun, 2023, 17:33

I have done everything that mentioned in the documentation. sir

Sandeep K. Dasari
8 Jun, 2023, 17:34
TypeScript
const sdk = require("node-appwrite");
const dotenv = require('dotenv');
dotenv.config();
const { v4:uuidv4} = require('uuid');
const express = require('express');
const app = express();
app.use(express.json());

module.exports = async function (req, res) {
  const client = new sdk.Client();
  const database = new sdk.Databases(client);
  const cartItem = await JSON.parse(req.payload);

  const { customer_id, location_id, product_id, seller_id, quantity } = cartItem;
  
  if (
    !req.variables['APPWRITE_FUNCTION_ENDPOINT'] ||
    !req.variables['APPWRITE_FUNCTION_API_KEY']
  ) {
    console.warn("Environment variables are not set. Function cannot use Appwrite SDK.");
  } else {
    client
      .setEndpoint(req.variables['APPWRITE_FUNCTION_ENDPOINT'])
      .setProject(req.variables['APPWRITE_FUNCTION_PROJECT_ID'])
      .setKey(req.variables['APPWRITE_FUNCTION_API_KEY'])
      .setSelfSigned(true);
      let newCartItem = {}
      if (customer_id && location_id && product_id && seller_id && quantity) {
        try {
          newCartItem = await database.createDocument(req.variables['ECOMM_DB_ID'], req.variables['CART_COLLECTION_ID'], uuidv4(), cartItem);
          return res.json({
            success: true,
            error: false,
            message: 'New Item is successfully added to cart :)',
            data: newCartItem
          })
        } catch (error) {
          return res.json({
            success:false,
            error: true,
            message: error.message
          })
        }
      } else {
        res.json({
          success:false,
          error: true,
          message: "All Fields are required :("
        })
      }
  }

  

  res.json({
    areDevelopersAwesome: true,
  });
};
Drake
8 Jun, 2023, 17:36

It would be best to remove them altogether so make sure it doesn't interfere with anything

Drake
8 Jun, 2023, 17:37

Try increasing your function timeout to 4 minutes and try executing again

Sandeep K. Dasari
8 Jun, 2023, 17:38

please hold on sir, I am doing what you have suggested. πŸ™‚ I think, it's been late night there.

Sandeep K. Dasari
8 Jun, 2023, 17:39

Do I need to give any events?

Sandeep K. Dasari
8 Jun, 2023, 17:42
Sandeep K. Dasari
8 Jun, 2023, 17:42

After I have increased the timeout, I don't know why, It is taking a lot of time to process.

Drake
8 Jun, 2023, 17:43

Not if you're executing manually

Drake
8 Jun, 2023, 17:44

There's your problem. The endpoint doesn't work

Sandeep K. Dasari
8 Jun, 2023, 17:44

What I need to do sir?

Sandeep K. Dasari
8 Jun, 2023, 17:45

It's my IP

Sandeep K. Dasari
8 Jun, 2023, 17:47

http://192.168.1.4/v1 I have given this

Drake
8 Jun, 2023, 17:56

so how do you access your appwrite console?

Sandeep K. Dasari
8 Jun, 2023, 17:57
Sandeep K. Dasari
8 Jun, 2023, 17:57

It worked. Thank you

Drake
8 Jun, 2023, 17:57

Operation Timed Out when Executing Function

Drake
8 Jun, 2023, 17:58

[SOLVED] Operation Timed Out when Executing Function

Sandeep K. Dasari
8 Jun, 2023, 17:59

APPWRITE_FUNCTION_ENDPOIND = https://cloud.appwrite.io/v1

Sandeep K. Dasari
8 Jun, 2023, 17:59

If anyone faced this issue, this is the endpoint we have to set πŸ™‚

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more