Skip to content
Back

[SOLVED] The function always gets timed out

  • 0
  • Functions
Hemish11
20 Jun, 2023, 17:54

I tried all the things, but the functions is always getting timed out, after about 15-17 seconds, heres the code

TypeScript
import 'dart:async';

import 'package:dart_appwrite/dart_appwrite.dart';

Future<void> start(final req, final res) async {
  final client = Client();

  final database = Databases(client);
  final document = await database.createDocument(
    databaseId: '6489ef1fb252d4ac177d',
    collectionId: '6489ef320a5a9b83cd78',
    documentId: 'unique()',
    data: {...},
  );

  res.json({document.toMap()});
}
TL;DR
The user is experiencing a timeout issue with their function. They have provided the code and mentioned that they have set the necessary credentials. Other users suggest checking if the endpoint is set correctly and using the host IP address instead of localhost. The user confirms that they have set the endpoint correctly but are still facing the timeout issue. Another user advises that using localhost is not valid inside a function and suggests using the host IP address. The user mentions that they are using macOS on Apple Silicon. No solution is provided in the thread. Solution: The thread does not provide a solution to the timeout issue.
Binyamin
20 Jun, 2023, 17:56

Be sure to set your Client with you server data

TypeScript
Client client = Client()
    .setEndpoint('https://cloud.appwrite.io/v1') 
    .setProject('[PROJECT_ID]')              
    .setKey('919c2db5d4...a2a3346ad2');     

You can read more about it here https://appwrite.io/docs/getting-started-for-server.

Hemish11
20 Jun, 2023, 18:01

But if im running it in functions, then also?

Hemish11
20 Jun, 2023, 18:01

If so, do i generate a key for the same?

Binyamin
20 Jun, 2023, 18:02

Yep

Hemish11
20 Jun, 2023, 18:02

Its actually a appwrite functions code that ive pushed

Hemish11
20 Jun, 2023, 18:02

this one didnt had any, so got confused

Binyamin
20 Jun, 2023, 18:02

Appwrite function are isolated. So if you want to connect to Appwrite then you'll to set the endpoint

Hemish11
20 Jun, 2023, 18:03

Oook, my bad i didnt checked the below part

Binyamin
20 Jun, 2023, 18:05

No worries

Hemish11
20 Jun, 2023, 18:07

Its still getting timed out

Hemish11
20 Jun, 2023, 18:08

I added project, endpoint, key and self signed

Hemish11
20 Jun, 2023, 18:08

also the key has all the required permissions

Binyamin
20 Jun, 2023, 18:08

Have you set the endpoint with localhost?

Hemish11
20 Jun, 2023, 18:08

yes

Hemish11
20 Jun, 2023, 18:10

It also has /v1 with it

Hemish11
20 Jun, 2023, 18:10

and also tried without /v1

Binyamin
20 Jun, 2023, 18:10

You do need to v1

Binyamin
20 Jun, 2023, 18:10

But localhost can't be used inside a function

Binyamin
20 Jun, 2023, 18:11

What you should do locally is to use your host IP address

Binyamin
20 Jun, 2023, 18:11

What os you using

Hemish11
20 Jun, 2023, 18:15

macOS

Hemish11
20 Jun, 2023, 18:15

On apple silicon

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