Skip to content

[macOS] SocketException: Connection failed (OS Error: Operation not permitted, errno = 1) #47606

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
KagurazakaHanabi opened this issue Dec 22, 2019 · 5 comments

Comments

@KagurazakaHanabi
Copy link
Contributor

Steps to Reproduce

final http.Client _client = http.Client();
String json = await _client.read('https://v2.api.dailypics.cn/today', headers: _kHeaders);

Target Platform: macOS 10.14

Logs

[ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: SocketException: Connection failed (OS Error: Operation not permitted, errno = 1), address = v2.api.dailypics.cn, port = 443
#0      IOClient.send (package:http/src/io_client.dart:33:23)                                                      
<asynchronous suspension>                                                                                          
#1      BaseClient._sendUnstreamed (package:http/src/base_client.dart:169:38)                                      
#2      BaseClient.get (package:http/src/base_client.dart:32:7)                                                    
#3      BaseClient.read (package:http/src/base_client.dart:117:12)                                                 
#4      TujianApi.getToday (package:dailypics/utils/api.dart:51:35)                                                
#5      _TodayComponentState._fetchData (package:dailypics/components/today.dart:142:42)                           
#6      _AsyncAwaitCompleter.start (dart:async-patch/async_patch.dart:47:6)                                        
#7      _TodayComponentState._fetchData (package:dailypics/components/today.dart:140:26)                           
#8      _TodayComponentState.initState (package:dailypics/components/today.dart:39:5)                              
#9      StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:4428:58)                           
#10     ComponentElement.mount (package:flutter/src/widgets/framework.dart:4274:5)
// ...
[✓] Flutter (Channel master, v1.13.6-pre.14, on Mac OS X 10.14.4 18E226, locale zh-Hans-CN)
[✗] Android toolchain - develop for Android devices
    ✗ Unable to locate Android SDK.
      Install Android Studio from: https://developer.android.com/studio/index.html
      On first launch it will assist you in installing the Android SDK components.
      (or visit https://flutter.dev/setup/#android-setup for detailed instructions).
      If the Android SDK has been installed to a custom location, set ANDROID_HOME to that location.
      You may also want to add it to your PATH environment variable.

[✓] Xcode - develop for iOS and macOS (Xcode 11.0)
[!] Android Studio (not installed)
[✓] VS Code (version 1.39.2)
[✓] Connected device (1 available)

! Doctor found issues in 2 categories.
@iapicca
Copy link
Contributor

iapicca commented Dec 22, 2019

Hi @KagurazakaHanabi
can you please provide your flutter run --verbose
and a minimal code sample to reproduce the problem?
Thank you

@iapicca iapicca added the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Dec 22, 2019
@stuartmorgan-g
Copy link
Contributor

stuartmorgan-g commented Dec 22, 2019

macOS applications are sandboxed by default. If you are making outgoing network connections you need to add the network.client entitlement.

@stuartmorgan-g stuartmorgan-g removed the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Dec 23, 2019
@Chesterguan
Copy link

@stuartmorgan Hi, thanks for your information and it works now!
For others' information 💯
Add
<key>com.apple.security.network.client</key>
<true/>
to file DebugProfile.entitlements under directory macos/Runner/

@stuartmorgan-g
Copy link
Contributor

If you only added it to that file, your release builds will have the same problem. People should follow the instructions linked above, which provide more complete information.

@github-actions
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 24, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants