I'm using the last flutter version on a fresh created project. I'm trying to call this URL https://crmdemo.fortex.com/open/public/login
But on iOS or Android I get flutter: Error SocketException: Connection refused (OS Error: Connection refused, errno = 61), address = crmdemo.fortex.com, port = 49266
Response response = await _dio.request(
url,
data: data,
queryParameters: queryParameters,
options: _checkOptions(method, options),
cancelToken: cancelToken,
);
RequestMethod: POST
RequestHeaders:{content-type: application/json; charset=utf-8, os: iOS 16.2, appVersion: 1.0.0, app_sys: 2}
Is there anything to do more than this ? I check the Android manifest and it has the Internet permission so should be ok
Dio: 4.0.6
Related
I've deployed a node.js service (REST API) in GCP Run and I'm having issues with the TLS handshake in Flutter.
Unhandled Exception: HandshakeException: Handshake error in client (OS Error: WRONG_VERSION_NUMBER(tls_record.cc:242))
The code that I'm trying to use is:
static Future<http.Response> get(String url, {Map<String, String>? headers}) async {
final _headers = await _addAuthHeader(headers); //appends the authorization header (not used right now)
final out = await http.get(Uri.parse(url), headers: _headers); //this throws the exception
return out;
}
In GCP Run I've haven't set anything about the security other than the allow unauthenticated calls so I should be using the managed TLS service.
I've tested in the following conditions:
curl https://<url> works ✅
curl --tls-max 1.2 https://<url> works ✅
curl --tls-max 1.1 https://<url> doesn't work ❌ (maybe Flutter doesn't support TLS 1.2?)
In dart (HTTPS call) using dio package doesn't work ❌
In dart (HTTPS call) using http package doesn't work ❌
In dart (HTTP call) works ✅
In chrome works ✅
I've tried the solutions proposed in these other posts:
Why i'm getting WRONG_VERSION_NUMBER when making a POST request to a HTTPS Server?
How to solve Flutter CERTIFICATE_VERIFY_FAILED error while performing a POST request?
Flutter on Android 7 CERTIFICATE_VERIFY_FAILED with LetsEncrypt SSL cert after Sept 30, 2021
System information:
Flutter version: 3.3.8
Dart version: 2.18.4
Flutter doctor: everything fine
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
i'm trying to connect to websocket server with token in header.
Due to web_socket_channel package not support headers i'm using dart WebSocket class.
I'm struggling with error in console:
"WebSocketException: Connection to 'https://URL:0/messenger#' was not upgraded to websocket<…>"
My code sample:
_url = 'wss://URL/messenger'
channel = await WebSocket.connect(
_url,
protocols: _protocols,
headers: {
"Cookie": "realtalk_auth=$token",
},
);
Also, same url in Postman with header "Cookie: realtalk_auth=token" lead to success connection
I have a Flask application running on my local machine, which I'm using as a backend for the Flutter application , but I'm getting this error
SocketException (SocketException: No route to host (OS Error: No route to host, Errno = 113)
Future pix(String BackgroundImagePath, String originalImagePath) async {
final uri = Uri.parse('http://my desktop address:5000').replace(queryParameters: {
'original': originalImagePath,
'background': BackgroundImagePath,
});
final response = await http.get(uri);
The phone is connected to my laptop through a USB
Both phone & Laptop are on same WIFI
I replaced localhost with my Ubuntu desktop IP address
Try adding this line in your AndroidManifest.xml, inside the <manifest> tag.
I had the same problem and this solved it.
<uses-permission android:name="android.permission.INTERNET"/>
I have app with flutter . I have to connect to server my ip is like =https://91.#.#.#:5000/api
when i post data to server i get flutter/lib/ui/ui_dart_state.cc(186)] Unhandled Exception: SocketException: OS Error: Connection refused, errno =111,address =server ip, port = 33450
my code
var url = Uri.parse(AddressController.text);
http.Response response = await http.post(url, body: {});
SocketException usually occurs when you don't have internet please make user that you have internet, if you're testing in real device make sure you put internet permission in manifest