shaz-tech / flutter_internet_speed_test

Internet speed test plugin to integrate it in your app wherever you want.
MIT License
12 stars 46 forks source link

Could not connect to the server #1

Closed ahmdsdk closed 1 year ago

ahmdsdk commented 1 year ago

Hi, I am trying to implement this package in my app to get information about the internet speed but I am getting an error that says "Could not connect to the server". I was wondering if the test servers are down or is the issue from my side. I am running the code on a real device iPhone 14 Pro iOS 16.1.2.

Here is the flutter doctor output:

Doctor summary (to see all details, run flutter doctor -v): [✓] Flutter (Channel stable, 3.3.9, on macOS 13.0.1 22A400 darwin-x64, locale en-US) [✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0) [✓] Xcode - develop for iOS and macOS (Xcode 14.1) [✓] Chrome - develop for the web [✓] Android Studio (version 2021.3) [✓] VS Code (version 1.73.1) [✓] Connected device (2 available) [✓] HTTP Host Availability

I tried triggering the function with a button and I tried putting it in the initState method but I keep getting the same error.

Here is my implementation:

@override
void initState() {
    final speedTest = FlutterInternetSpeedTest();

    speedTest.startTesting(
      onStarted: () {},
      onCompleted: (TestResult download, TestResult upload) {
        if (speedTest.isLogEnabled) {
          print('the transfer rate ${download.transferRate}, ${upload.transferRate}');
        }
      },
      onProgress: (double percent, TestResult data) {
        if (speedTest.isLogEnabled) {
          print('the transfer rate ${data.transferRate}, ${data.transferRate}');
        }
      },
      onError: (String errorMessage, String speedTestError) {
        print("error message: $errorMessage speedTestError: $speedTestError");
      },
      onDefaultServerSelectionInProgress: () {
        print('server selection in progress');
      },
      onDefaultServerSelectionDone: (Client? client) {
        print('server selection done ${client?.ip} ${client?.isp} ${client?.asn}');
      },
      onDownloadComplete: (TestResult data) {
        print('the download transfer rate ${data.transferRate}');
      },
      onUploadComplete: (TestResult data) {
        print('the upload transfer rate ${data.transferRate}');
      },
    );
    super.initState();
}

Below is the error I'm getting:

[tcp] tcp_input [C10.1.1.1.1:3] flags=[R.] seq=0, ack=3702651391, win=0 state=SYN_SENT rcv_nxt=0, snd_una=3702651390 [tcp] tcp_input [C10.1.2.1.1:3] flags=[R.] seq=0, ack=611674376, win=0 state=SYN_SENT rcv_nxt=0, snd_una=611674375 Connection 10: received failure notification Connection 10: failed to connect 1:61, reason -1 Connection 10: encountered error(1:61) Task .<1> HTTP load failed, 0/0 bytes (error code: -1004 [1:61]) Task .<1> finished with error [-1004] Error Domain=NSURLErrorDomain Code=-1004 "Could not connect to the server." UserInfo={_kCFStreamErrorCodeKey=61, NSUnderlyingError=0x2878a6cd0 {Error Domain=kCFErrorDomainCFNetwork Code=-1004 "(null)" UserInfo={_NSURLErrorNWPathKey=satisfied (Path is satisfied), interface: en0[802.11], ipv4, dns, expensive, fallback: {interface: pdp_ip0, agent: 2183522D-E4F3-473C-AB4A-FE764F697935, weak}, _kCFStreamErrorCodeKey=61, _kCFStreamErrorDomainKey=1}}, _NSURLErrorFailingURLSessionTaskErrorKey=LocalDownloadTask .<1>, _NSURLErrorRelatedURLSessionTaskErrorKey=( "LocalDownloadTask .<1>" ), NSLocalizedDescription=Could not connect to the server., NSErrorFailingURLStringKey=https://ipv4-c006-pmo001-tis-isp.1.oca.nflxvideo.net:8080/../download?size=200000, NSErrorFailingURLKey=https://ipv4-c006-pmo001-tis-isp.1.oca.nflxvideo.net:8080/../download?size=200000, _kCFStreamErrorDomainKey=1} Optional(Error Domain=NSURLErrorDomain Code=-1004 "Could not connect to the server." UserInfo={_kCFStreamErrorCodeKey=61, NSUnderlyingError=0x2878a6cd0 {Error Domain=kCFErrorDomainCFNetwork Code=-1004 "(null)" UserInfo={_NSURLErrorNWPathKey=satisfied (Path is satisfied), interface: en0[802.11], ipv4, dns, expensive, fallback: {interface: pdp_ip0, agent: 2183522D-E4F3-473C-AB4A-FE764F697935, weak}, _kCFStreamErrorCodeKey=61, _kCFStreamErrorDomainKey=1}}, _NSURLErrorFailingURLSessionTaskErrorKey=LocalDownloadTask .<1>, _NSURLErrorRelatedURLSessionTaskErrorKey=( "LocalDownloadTask .<1>" ), NSLocalizedDescription=Could not connect to the server., NSErrorFailingURLStringKey=https://ipv4-c006-pmo001-tis-isp.1.oca.nflxvideo.net:8080/../download?size=200000, NSErrorFailingURLKey=https://ipv4-c006-pmo001-tis-isp.1.oca.nflxvideo.net:8080/../download?size=200000, _kCFStreamErrorDomainKey=1}) task is Optional(Error Domain=NSURLErrorDomain Code=-1004 "Could not connect to the server." UserInfo={NSUnderlyingError=0x2878a6cd0 {Error Domain=kCFErrorDomainCFNetwork Code=-1004 "(null)" UserInfo={_NSURLErrorNWPathKey=satisfied (Path is satisfied), interface: en0[802.11], ipv4, dns, expensive, fallback: {interface: pdp_ip0, agent: 2183522D-E4F3-473C-AB4A-FE764F697935, weak}, _kCFStreamErrorCodeKey=61, _kCFStreamErrorDomainKey=1}}, NSErrorFailingURLStringKey=https://ipv4-c006-pmo001-tis-isp.1.oca.nflxvideo.net:8080/../download?size=200000, NSErrorFailingURLKey=https://ipv4-c006-pmo001-tis-isp.1.oca.nflxvideo.net:8080/../download?size=200000, _kCFStreamErrorDomainKey=1, _kCFStreamErrorCodeKey=61, NSLocalizedDescription=Could not connect to the server.}) error is Optional(Error Domain=NSURLErrorDomain Code=-1004 "Could not connect to the server." UserInfo={_kCFStreamErrorCodeKey=61, NSUnderlyingError=0x2878a6cd0 {Error Domain=kCFErrorDomainCFNetwork Code=-1004 "(null)" UserInfo={_NSURLErrorNWPathKey=satisfied (Path is satisfied), interface: en0[802.11], ipv4, dns, expensive, fallback: {interface: pdp_ip0, agent: 2183522D-E4F3-473C-AB4A-FE764F697935, weak}, _kCFStreamErrorCodeKey=61, _kCFStreamErrorDomainKey=1}}, _NSURLErrorFailingURLSessionTaskErrorKey=LocalDownloadTask .<1>, _NSURLErrorRelatedURLSessionTaskErrorKey=( "LocalDownloadTask .<1>" ), NSLocalizedDescription=Could not connect to the server., NSErrorFailingURLStringKey=https://ipv4-c006-pmo001-tis-isp.1.oca.nflxvideo.net:8080/../download?size=200000, NSErrorFailingURLKey=https://ipv4-c006-pmo001-tis-isp.1.oca.nflxvideo.net:8080/../download?size=200000, _kCFStreamErrorDomainKey=1}) url session2

A7medking1 commented 1 year ago

and me this error show in ios

DanielCardona commented 1 year ago

In the same boat.

DanielCardona commented 1 year ago

Some progress?

Thanks!