I/flutter ( 9428): ClientException with SocketException: Failed host lookup:…
- User
I/flutter ( 9428): ClientException with SocketException: Failed host lookup: 'octopus-app-bpfg8.ondigitalocean.app' (OS Error: No address associated with hostname, errno = 7), uri=https://octopus-app-bpfg8.ondigitalocean.app/api/phone/camera
Future captureAndSendImage(String numberString) async { // Your existing code here... print("Last check"); try { if (!mounted) return; String sanitizedNumber = numberString.replaceAll(",", "."); // Send the image to the server var request = http.MultipartRequest( 'POST', Uri.parse( 'https://octopus-app-bpfg8.ondigitalocean.app/api/phone/camera')); request.fields['weight'] = sanitizedNumber; request.fields['direction'] = direction; var res = await request.send(); var response = await http.Response.fromStream(res);
if (response.statusCode == 200) { // If the server returns a 200 OK response, then proceed var responseData = jsonDecode(response.body); var audioBase64 = responseData[1]['audio']; // Decode the Base64 string to bytes var audioBytes = base64Decode(audioBase64); // Save the audio to a temporary file var directory = await getApplicationDocumentsDirectory(); var audioPath = '${directory.path}/temp.mp3'; var audioFile = File(audioPath); await audioFile.writeAsBytes(audioBytes); // Load the audio file var player = AudioPlayer(); await player.setUrl(audioPath); // Play the audio file player.play(); } else { // If the server returns an error response, } } catch (e) { print(e); }}
but it works in debug mode but not in released mode
- Assistant