'Problem with http.get and connection time out Flutter
I have a problem with a flutter project
I will get a json on my server running on the port 8080. In the route /weather/Paris.
So I do on my weather.dart
...
String? parisW;
@override
void initState() {
getInfoCity("Paris");
super.initState();
}
...
Text(parisW.toString()),
...
void getInfoCity(String city) async {
if (global.ipAddress == null) {
return;
} else {
var reponse = await http.get(
Uri.parse('https://' + global.ipAddress + ':8080/weather/$city'));
print(reponse.body);
if (reponse.statusCode != 200) return;
setState() {
parisW = reponse.body;
}
}
}
Both of the ip and the route is correct
Solution 1:[1]
Seems strange to a have the port 8080 using the HTTPS scheme. This is usually the port 8083 but of course it depends on the server configuration.
Did you try with:
'http://' + global.ipAddress + ':8080/weather/$city'? (without the secure protocol)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Eric Taix |
