Skip to content
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

Unhandled exception in Windows 10 chinese #190

Closed
xmlspyspring opened this issue Mar 26, 2024 · 3 comments · Fixed by #194
Closed

Unhandled exception in Windows 10 chinese #190

xmlspyspring opened this issue Mar 26, 2024 · 3 comments · Fixed by #194

Comments

@xmlspyspring
Copy link

I ran the following code and got the following error:

code:

import 'package:network_tools/network_tools.dart';

import '../example_utils.dart';

Future<void> main() async {
  enableExampleLogging();
  await configureNetworkTools('build');

  const String subnet = '192.168.1'; //Default network id for home networks

  // final interface = await NetInterface.localInterface();
  // final netId = interface?.networkId;
  // if (netId != null) {
  //   subnet = netId;
  // }

  // or You can also get address using network_info_plus package
  // final String? address = await (NetworkInfo().getWifiIP());
  examplesLogger.fine("Starting scan on subnet $subnet");

  // You can set [firstHostId] and scan will start from this host in the network.
  // Similarly set [lastHostId] and scan will end at this host in the network.
  final stream = HostScannerService.instance.getAllPingableDevicesAsync(
    subnet,
    // firstHostId: 1,
    // lastHostId: 254,
    progressCallback: (progress) {
      examplesLogger.finer('Progress for host discovery : $progress');
    },
  );

  stream.listen(
    (host) async {
      //Same host can be emitted multiple times
      //Use Set<ActiveHost> instead of List<ActiveHost>
      examplesLogger.fine('Found device: ${await host.toStringFull()}');
    },
    onDone: () {
      examplesLogger.fine('Scan completed');
    },
  ); // Don't forget to cancel the stream when not in use.
}

console output:

C:/a_dev/flutter-sdk/bin/cache/dart-sdk/bin/dart.exe --enable-asserts C:\Users\xmlspyspring\IdeaProjects\look_net_cli\bin\look_net_cli.dart
Positional arguments: []
2024-03-25 15:29:02.881110: FINE: network_tools: Downloading mac-vendors-export.csv from network_tools
Unhandled exception:
ClientException with SocketException: Failed host lookup: 'raw.githubusercontent.com' (OS Error: 请求的名称有效,但是找不到请求的类型的数据。
, errno = 11004), uri=https://raw.githubusercontent.com/osociety/network_tools/main/lib/assets/mac-vendors-export.csv
#0      IOClient.send (package:http/src/io_client.dart:154:7)
<asynchronous suspension>
#1      BaseClient._sendUnstreamed (package:http/src/base_client.dart:93:32)
<asynchronous suspension>
#2      _withClient (package:http/http.dart:167:12)
<asynchronous suspension>
#3      VendorTable._fetchVendorTable (package:network_tools/src/device_info/vendor_table.dart:42:24)
<asynchronous suspension>
#4      VendorTable.createVendorTableMap (package:network_tools/src/device_info/vendor_table.dart:31:25)
<asynchronous suspension>
#5      configureNetworkTools (package:network_tools/src/configure_dart_native.dart:37:3)
<asynchronous suspension>
#6      main (file:///C:/Users/xmlspyspring/IdeaProjects/look_net_cli/bin/look_net_cli.dart:87:3)
<asynchronous suspension>

Process finished with exit code 255

My Environment: windows 10 chinese

PS C:\Users\xmlspyspring\IdeaProjects\network_tools> dart --version
Dart SDK version: 3.3.1 (stable) (Wed Mar 6 13:09:19 2024 +0000) on "windows_x64"

I have solved this problem:
In file lib/src/services/impls/host_scanner_service_impl.dart Line 110
change
Ping(host, count: 1, timeout: timeoutInSeconds)
to
Ping(host, count: 1, timeout: timeoutInSeconds,forceCodepage: true

then run and get:

C:/a_dev/flutter-sdk/bin/cache/dart-sdk/bin/dart.exe --enable-asserts C:\Users\xmlspyspring\IdeaProjects\network_tools\example\lib\scan\host_scan.dart
2024-03-25 18:22:47.681016: FINE: network_tools_examples: Starting scan on subnet 192.168.1
2024-03-25 18:22:54.382557: FINE: network_tools_examples: Found device: Address: 192.168.1.1, MAC: null, HostId: 1, Vendor: null Time: 1ms, DeviceName: Generic Device, HostName: null, MdnsInfo: null
2024-03-25 18:22:58.921379: FINE: network_tools_examples: Found device: Address: 192.168.1.2, MAC: null, HostId: 2, Vendor: null Time: 46ms, DeviceName: Generic Device, HostName: null, MdnsInfo: null
2024-03-25 18:23:03.459363: FINE: network_tools_examples: Found device: Address: 192.168.1.4, MAC: null, HostId: 4, Vendor: null Time: 229ms, DeviceName: Generic Device, HostName: null, MdnsInfo: null
2024-03-25 18:23:03.469368: FINE: network_tools_examples: Found device: Address: 192.168.1.5, MAC: null, HostId: 5, Vendor: null Time: 1ms, DeviceName: host.docker.internal, HostName: host.docker.internal, MdnsInfo: null
2024-03-25 18:23:19.845421: FINE: network_tools_examples: Scan completed

Too little information obtained, many are null. I want to get more information, especially the mac address.

@git-elliot
Copy link
Collaborator

git-elliot commented Mar 26, 2024

@xmlspyspring I think mac-vendors-export.csv is not downloaded properly. Can you please delete this file and run the example again?
http error while downloading says The requested name is valid, but the data for the requested type was not found.

@xmlspyspring
Copy link
Author

Sorry, I pasted the wrong console output, the correct output is as follows:

C:/a_dev/flutter-sdk/bin/cache/dart-sdk/bin/dart.exe --enable-asserts C:\Users\xmlspyspring\IdeaProjects\network_tools\example\lib\scan\host_scan.dart
2024-03-26 22:19:24.731558: FINE: network_tools_examples: Starting scan on subnet 192.168.1
Unhandled exception:
FormatException: Missing extension byte (at offset 3)
#0      _Utf8Decoder.convertChunked (dart:convert-patch/convert_patch.dart:1845:7)
#1      _Utf8ConversionSink.addSlice (dart:convert/string_conversion.dart:304:28)
#2      _Utf8ConversionSink.add (dart:convert/string_conversion.dart:300:5)
#3      _ConverterStreamEventSink.add (dart:convert/chunked_conversion.dart:69:18)
#4      _SinkTransformerStreamSubscription._handleData (dart:async/stream_transformers.dart:111:24)
#5      _RootZone.runUnaryGuarded (dart:async/zone.dart:1594:10)
#6      _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:339:11)
#7      _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7)
#8      _SyncStreamControllerDispatch._sendData (dart:async/stream_controller.dart:784:19)
#9      _StreamController._add (dart:async/stream_controller.dart:658:7)
#10     _StreamController.add (dart:async/stream_controller.dart:606:5)
#11     _RootZone.runUnaryGuarded (dart:async/zone.dart:1594:10)
#12     _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:339:11)
#13     _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7)
#14     _SyncStreamControllerDispatch._sendData (dart:async/stream_controller.dart:784:19)
#15     _StreamController._add (dart:async/stream_controller.dart:658:7)
#16     _StreamController.add (dart:async/stream_controller.dart:606:5)
#17     _Socket._onData (dart:io-patch/socket_patch.dart:2447:41)
#18     _RootZone.runUnaryGuarded (dart:async/zone.dart:1594:10)
#19     _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:339:11)
#20     _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7)
#21     _SyncStreamControllerDispatch._sendData (dart:async/stream_controller.dart:784:19)
#22     _StreamController._add (dart:async/stream_controller.dart:658:7)
#23     _StreamController.add (dart:async/stream_controller.dart:606:5)
#24     new _RawSocket.<anonymous closure> (dart:io-patch/socket_patch.dart:1936:33)
#25     _NativeSocket.issueReadEvent.issue (dart:io-patch/socket_patch.dart:1379:14)
#26     _microtaskLoop (dart:async/schedule_microtask.dart:40:21)
#27     _startMicrotaskLoop (dart:async/schedule_microtask.dart:49:5)
#28     _runPendingImmediateCallback (dart:isolate-patch/isolate_patch.dart:118:13)
#29     _RawReceivePort._handleMessage (dart:isolate-patch/isolate_patch.dart:185:5)

@git-elliot
Copy link
Collaborator

@xmlspyspring I think the problem is with locale. Can you try once by change your wifi name to english.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants