Reputation: 121
we already have a release version in playstore and its working just fine. But suddenly now when we try to build and run the code again since we want to add new functionality. It would no longer communicate with our backend.
So i searched the net using the error as keyword and saw that need INTERNET PERMISSION as the 100% result and answer, which we have already and not helpful at all. Yes we have it in debug and live manifests.
The server is up we can access it in the browser and as well as postman also dig command
So i searched more things in the net to no avail, found about the because proxy issue thing i tried both client side and server-side. we don't have proxy
we use simple request only like this:
static Future getDriver(String phone){
var url = baseUrl + "/mobile/driverPhone";
return http.post(url,body: {
"phone" : phone
});
}
also some suggestion say to use DIO, but i want to know the reason first before i gave up with this http plugin. Can someone with good heart explain and help me with this?
P.S. we on master channel, here are some error logs
Upvotes: 6
Views: 18430
Reputation: 1
I might be late to the answer, but there is another reason this error can occur.
Failed host lookup essentially refers that you have the url but just cannot connect to the resource. This is not a code error but a loading/network issue that has not been handled.
Reasons for this could include:
The following is just an example of how this error can be "handled". The main idea is to do exception handling in case the image does not load. In this case for the CircleAvatar Widget's foregroundImage property.
CircleAvatar(
foregroundImage: NetworkImage("Your-image-Url"),
onForegroundImageError: (exception, stackTrace) => {} // If the Image does not load due to network error
);
Upvotes: 0
Reputation: 6729
The error SocketException: Failed host lookup: 'api.xyz.com' (OS Error: No address associated with hostname, errno = 7)
usually means that your DNS lookup fails. From the error itself OS Error
, is usually a system-level error and nothing specific to http
or Dart/Flutter.
You might need to adjust some settings in your DNS. Also, if you are using a Mac/Linux system you might be able to run dig api.xyz.com
to see if that resolves.
Running your app in the actual device could be possible as well since there is a possibility its getting an error in your virtual device due to DNS settings or the virtual device you are using is not connected to the internet. You will be able to isolate the problem.
Upvotes: 2