After upgrading my version of Flutter to 3.29.3 :
Flutter 3.29.3 • channel stable • https://github.com/flutter/flutter.git
Framework • revision ea121f8859 (2 weeks ago) • 2025-04-11 19:10:07 +0000
Engine • revision cf56914b32
Tools • Dart 3.7.2 • DevTools 2.42.3
I'm not able to contact my SpringBoot App. I use a certificate i generate with openssl :
openssl.exe req -newkey rsa:2048 -keyout PRIVATEKEY.key -out MYCSR.csr
openssl.exe req -new -x509 -nodes -sha256 -days 365 -key PRIVATEKEY.key -out host.cert
openssl.exe pkcs12 -export -in host.cert -inkey PRIVATEKEY.key -out keystore.p12 -name myApp
With Postman, my requet : https://localhost/auth/authenticate
on POST
request works well and give me my access_token.
Now, when i launch my flutter app on my physical phone, i have this error :
I/flutter ( 3796): ClientException with SocketException: Connection timed out (OS Error: Connection timed out, errno = 110), address = 192.168.1.40, port = 37950, uri=https://192.168.1.40/auth/authenticate
I/.example.xplore( 3796): Thread[2,tid=3802,WaitingInMainSignalCatcherLoop,Thread*=0xb40000732bd83c00,peer=0x15440320,"Signal Catcher"]: reacting to signal 3
I/.example.xplore( 3796):
I/.example.xplore( 3796): Wrote stack traces to tombstoned
D/Looper ( 3796): dumpMergedQueue
D/OplusLooperMsgDispatcher( 3796): dumpMsgWhenAnr
My local ip address on my computer (ipconfig) is 192.168.1.40.
Inside my main.dart, i overrided createHttpClient
(which i think is ONLY for DEV, not in PROD) :
class MyHttpOverrides extends HttpOverrides {
@override
HttpClient createHttpClient(SecurityContext? context) {
return super.createHttpClient(context)
..badCertificateCallback =
(X509Certificate cert, String host, int port) => true;
}
}
My POST
request in my Flutter App looks like this :
var response = await http.post(Uri.parse(login),
headers: {"Content-Type": "application/json"},
body: jsonEncode(reqBody))
If you need more informations, i let you ask me :)
Thanks for your help!
Make sure:
Phone and PC on same Wi-Fi
Firewall temporarily disabled
Spring Boot binds on 0.0.0.0
Use correct IP and port in Flutter app