Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

馃悰 Bug Report: AppwriteException: null, Connection failed (0) - Function execution -server sdk access #6943

Closed
2 tasks done
mokamhawy opened this issue Oct 18, 2023 · 2 comments
Assignees
Labels
bug Something isn't working product / functions Fixes and upgrades for the Appwrite Functions.

Comments

@mokamhawy
Copy link

馃憻 Reproduction steps

  • I am self hosting using docker desktop win10
  • I created a simple function that list users.
  • I get error AppwriteException: null, Connection failed (0)
Future<dynamic> main(final context) async {
  // Why not try the Appwrite SDK?
 
  final asd = await NetworkInterface.list();
  for (var interface in asd) {
    for (var addr in interface.addresses) {
      if (addr.type == InternetAddressType.IPv4) {
        context.log('looping...');
        context
            .log('Interface: ${interface.name}, IP address: ${addr.address}');
      }
    }
  }

  final client = Client()
      .setEndpoint('http:https://localhost/v1')
      .setProject(Platform.environment['APPWRITE_PROJECT_ID'])
      .setKey(Platform.environment['APPWRITE_API_KEY'])
      .setSelfSigned(status: true);
  final users = Users(client);

I suspect the error is from setEndpoint.

my vars:
_APP_ENV=production
_APP_DOMAIN=localhost
_APP_DOMAIN_FUNCTIONS=localhost
_APP_DOMAIN_TARGET=localhost

_APP_FUNCTIONS_RUNTIMES=node-16.0,php-8.0,python-3.9,ruby-3.0,dart-3.0
_APP_EXECUTOR_SECRET=your-secret-key
_APP_EXECUTOR_HOST=http:https://appwrite-executor/v1
_APP_EXECUTOR_RUNTIME_NETWORK=runtimes
OPEN_RUNTIMES_NETWORK=runtimes
_APP_FUNCTIONS_RUNTIMES_NETWORK=runtimes

馃憤 Expected behavior

get users list

馃憥 Actual Behavior

AppwriteException: null, Connection failed (0)

馃幉 Appwrite version

Version 1.4.x

馃捇 Operating system

Windows

馃П Your Environment

1.4.5

馃憖 Have you spent some time to check if this issue has been raised before?

  • I checked and didn't find similar issue

馃彚 Have you read the Code of Conduct?

@mokamhawy mokamhawy added the bug Something isn't working label Oct 18, 2023
@stnguyen90 stnguyen90 added the product / functions Fixes and upgrades for the Appwrite Functions. label Oct 18, 2023
@stnguyen90 stnguyen90 self-assigned this Oct 18, 2023
@stnguyen90
Copy link
Contributor

@mokamhawy, thanks for raising this issue! 馃檹馃徏 This usually happens if something is wrong with the endpoint value. Looking at your code, it looks like you're using localhost for the endpoint. This won't work because the runtime container will try to connect to itself rather than Appwrite. One option is to use the IP of your host machine on your LAN instead of localhost.

@mokamhawy
Copy link
Author

mokamhawy commented Oct 19, 2023

@stnguyen90 Thank you so much. Problem solved. for those who come later.

  • appwrite 1.4.5
  • in dart, in function code/src
 final client = Client()
      .setEndpoint(endpoint) // local-private ip ex. http:https://192.168.10.38/v1 NOT http:https://localhost/v1
      .setProject(projectId)
      .setKey(apiKey); // this should be generated with scope of what you need to do next

api keys from: http:https://localhost/console/project-888888.../overview/keys

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working product / functions Fixes and upgrades for the Appwrite Functions.
Projects
None yet
Development

No branches or pull requests

2 participants