pocketbase / dart-sdk

PocketBase Dart SDK
https://pub.dev/packages/pocketbase
MIT License
511 stars 51 forks source link

can't reach the server from flutter when running in real android device #46

Closed getch04 closed 1 year ago

getch04 commented 1 year ago

i wanted to access a collections which are in pocketbase server, it will work from postman using localhost,

but when I try to access it from dart code using my actual Android device, it will end up with Connection Timeout exception.

I tied:

  1. my PC and my android devices are on the same network.
  2. tried to change the ip to my real ip on my PC.

should I deploy to access it???

ganigeorgiev commented 1 year ago

This is not related to the SDK or PocketBase, you just need to ensure that you have access to your localhost, but I'm not sure how to help you with that.

If both devices are on the same network, when initializing the SDK in your Flutter app, you have to use the local network address of your PC aka. final pb = PocketBase('http://YOUR_IP:8090');

If that doesn't help, then you are probably using the incorrect IP, you are behind a firewall or there is something else going on with your setup.

An alternative and more universal approach is to install something like ngrok and run ngrok http 8090 to create a public address of your localhost and use the generated address in the SDK initialization.