Dio Package doesnot work on Flutter Desktop App - flutter

Dio is working perfectly well on both Android and iOS but when I try to run thesame code base on mac Desktop, the application launches but I cant make any http call, I cant connect to any server. It just keeps timing out. I dont know maybe DIO is not compatuble with desktop yet.
This is the error I get
DioError [DioErrorType.other]: SocketException: Connection failed
(OS Error: Operation not permitted, errno = 1),
address = api.wykinkin.app, port = 443

I later discovered I needed to add:
<key>com.apple.security.network.client</key>
<true/>
to my macos/Runner/DebugProfile.entitlements and macos/Runner/Release.entitlements.
from here

Related

How to connect wss in flutter web?

I try to connect a socket-io with flutter. Before, our server-side developer give me an URL without SSL-Certificate and everything is worked. But now, our server has SSL-Certificate, I can't connect to that socket-io. This is my code to connect:
Socket socket = io(
'wss://server-address',
OptionBuilder()
.setTransports(['websocket'])
.disableAutoConnect()
.build());
socket.connect();
socket.onConnect((_) {
print('socket connect');
});
socket.onConnectError((data) => print('socket error = ' + data.toString()));
I get this error:
socket error = {msg: websocket error, desc: null, type: TransportError}
I try to deploy my web application on a secure host like firebase but still have problems. In inspect of firefox, I also see this error:
Firefox cant establish a connection to the server
How to fix this problem? How to connect to secure socket-io address in flutter web?

Unhandled Exception: SocketException: Failed host lookup: 'imap.gmail.com' (OS Error: No address associated with hostname, errno = 7)

I was used imap_client package in my app to read my mail.
below is my connection code:
`ImapClient client = new ImapClient();
await client.connect("imap.gmail.com", 993, true);
print("success");`
Looks like your are not connected to internet. Or maybe the server you are using is temporarily down. Mainly there are the causes behind Socket Exception.

Flutter / Dart Error SocketException: OS Error: The remote computer refused the network connection. , errno = 1225, address = 127.0.0.1, port = 59250

I am getting this error in my debugger.
From what I understood it's an error generated by ip config.
I found this solve here, but i dont understand where should i modify it. where should i change the ip address?
Flutter SocketException (SocketException: OS Error: Connection refused, errno = 111, address = localhost, port = 51500)
ERROR - 2021-03-23 18:21:26.074284
PUT /SXUs66yGd7s=/
Error thrown by handler.
SocketException: OS Error: The remote computer refused the network connection.
, errno = 1225, address = 127.0.0.1, port = 59250
Help!
Thank you alot
I was going through this trouble myself
i just disconnect the emulator and restated
Not sure what is your environment:
for me->
I tried to run windows app with xampp localhost and received this error.
then i changed my uri in frontend to
String uri = 'http://127.0.0.1/db-name';
after that, all working.
in the emulator the uri is different.
String uri = 'http://your ip addres/db-name';
to get your ip address->
open cmd and run "ipconfig"
use ipv4.

How to resolve - SocketException: Failed host lookup: 'server.com' (OS Error: nodename nor servname provided, or not known, errno = 8)

I am pretty new to flutter development. I am getting the following error on connecting to the server:
SocketException: Failed host lookup: 'server.com' (OS Error: nodename nor servname provided, or not known, errno = 8)
I already referred the below link, but this was of no help for me
How to solve SocketException: Failed host lookup: 'www.xyz.com' (OS Error: No address associated with hostname, errno = 7)
Currently I am testing my application on iOS simulator. Below are the versions I am using,
Http version - http: ^0.12.2
Flutter version - 1.22.4(Stable version)
The server is connecting when I am using mobile hotspot with my company's VPN enabled. But, I get this error when I switch to the company LAN.
All the APIs are working fine in postman when connected to LAN. I am using Android Studio. Is there any specific configuration to be made in flutter? Please let me know...
Internet is off or signal is not strong. Check your LAN connection.

How do I remove the Exception Error in running flutter?

fetchData()async{
res = await http.get(api);
Exception has occurred.
HandshakeException (HandshakeException: Handshake error in client (OS Error:
CERTIFICATE_VERIFY_FAILED: self signed certificate in certificate chain(handshake.cc:352)))
print(res.body);
drinks = jsonDecode(res.body)["drinks"];
setState(() {
});
Your error log clearly states that the error is not from flutter app side for api implementation.
Error is from web api side.
Contact your api person to resolve the server side issue.
Also try adding the internet permission in your manifest file,
<uses-permission android:name="android.permission.INTERNET" />
Then, in your terminal run the following command,
flutter clean
If it doesn't work i don't think any issues are from flutte side.