Why am I having this Socket Exception Errno=54? - flutter

I am doing a very simple http get function by getting the time from worldtimeapi.org yet almost every time I get a SocketException: OS Error: Connection by peer, errno = 54, address = worldtimeapi.org = port = 57450)
Uri url = Uri.https('worldtimeapi.org','/api/timezone/Asia/Singapore', {'q': '{http}'});
var response = await http.get(url);

Related

Failed host lookup, No address associated with hostnam

I'm trying to fetch data from url api laravel(Laragon) but i am facing this issue.
SocketException: Failed host lookup: 'pfe_web.test' (OS Error: No
address associated with hostname, errno = 7) when i try this final
http.Response response = await
http.get(Uri.parse('http://pfe_web.test/REST/cities'));

SocketException: Connection refused (OS Error: Connection refused, errno = 111), address = 127.0.0.1, port = 52035

I am having a flutter app, and want to connect it with ganache for ether transfer. But when I connect it with my real device it has given me the following error.
[ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: SocketException: Connection refused (OS Error: Connection refused, errno = 111), address = 127.0.0.1, port = 52035
String rpcUrl = "http://127.0.0.1:7545";
String wsUrl = "ws://127.0.0.1:7545/";
sendEther() async {
Web3Client client = Web3Client(rpcUrl, Client(), socketConnector: () {
return IOWebSocketChannel.connect(wsUrl).cast<String>();
});
String privateKey =
"cce548f8263f25d63613bb48b87391b9c83f07a3ede4a5f8380549f93c2ca05f";
Credentials credentials =
await client.credentialsFromPrivateKey(privateKey);
EthereumAddress ownAddress = await credentials.extractAddress();
EthereumAddress reciever =
EthereumAddress.fromHex("0x3B0ae8eecdFe232b453Ea107B65B2B7FFE8d46B9");
print("#################");
print(ownAddress);
client.sendTransaction(
credentials,
Transaction(
from: ownAddress,
to: reciever,
value: EtherAmount.fromUnitAndValue(EtherUnit.ether, 1)
));
}
This is my code to send ether to another account.
Ganache localhost RPC SERVER "HTTP://127.0.0.1:7545". How to work it on real device?

build Flutter client for IPFS

please trying to build a FLUTTER client to access IPFS server using dart_ipfs_client
my function
sendMessage() async {
print('-------------1');
var ipfs = Ipfs(url: 'http://10.0.2.2:5001');
print('-------------2');
var addRes = await ipfs.add(utf8.encode('Hello World!'));
print('-------------3');
}
I have this error
[ERROR:flutter/lib/ui/ui_dart_state.cc(186)] Unhandled Exception:
SocketException: OS Error: Connection timed out, errno = 110, address
= 10.0.2.2, port = 41004
Please is the any solution to fix this?

Flutter: Connecting to localhost:5001 with http package from local device doesn't work

I have the following problem: I have a .NET API running on my local machine at https://localhost:5001. When I execute a request in Postman, it works totally fine, but when executing the same API call in Dart, it won't work.
In Postman https://localhost:5001 will respond with a 401 or a 200 Statuscode.
When I execute the exact same URL in Flutter, it will give me a timeout:
Flutter Devtools
When using https://localhost:5001 in Flutter -> SocketException: OS Error: Connection refused, errno = 111, address = localhost, port = 41838
When using https://192.168.0.154:5001 in Flutter -> SocketException: OS Error: Connection timed out, errno = 110, address = 192.168.0.154, port = 44624
Im executing the following code:
var response = await http.get(url);
if(response.statusCode == 200) {
print(response.body);
}else{
throw Exception('Failed to fetch');
}```

SocketException: OS Error: Connection reset by peer, errno = 54, address = 192.168.178.117, port = 52699

In flutter when i try to upload mp4 video to my local server return me this
SocketException: OS Error: Connection reset by peer, errno = 54, address = 192.168.178.117, port = 52699
i used
AssetEntity asset = toUpload[i];
final byteData = await asset.originBytes;
var request = http.MultipartRequest('POST', url)
..fields['fileName'] = _imageNames[i]
..files.add(http.MultipartFile.fromBytes('image', byteData));
Is this a client problem or a server problem ?
I use this version of http
http: ^0.12.2
The issue was in my backend.
Using quarkus in application.properties i add
quarkus.http.limits.max-body-size = 200M