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

[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: SocketException: Send failed (OS Error: No route to host, errno = 65), address = 0.0.0.0, port = 1900 #56250

Open
billcoding opened this issue Jul 16, 2024 · 3 comments
Labels
area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends. library-io os-ios type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)

Comments

@billcoding
Copy link

Hello,

I am currently testing castscreen and encountered this problem.

Except for iOS, other platforms (Android, macOS, ...) are Ok.

Code:

import 'package:castscreen/castscreen.dart';
import 'package:flutter/material.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'CastScreen Demo',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      home: const MyHomePage(title: 'CastScreen Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key, required this.title});

  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  var devices = <Device>[];
  Device? curDev;
  final playUrl =
      'https://leshiyuncdn.ahjunqin.top/20240109/BWCSLaI6/index.m3u8';

  Future<void> search() async {
    devices =
        await CastScreen.discoverDevice(timeout: const Duration(seconds: 3));
    curDev = null;
    setState(() {});
  }

  Future<void> play() async {
    if (curDev == null) {
      return;
    }
    final alive = await curDev!.alive();
    if (!alive) {
      return;
    }
    curDev!.setAVTransportURI(SetAVTransportURIInput(playUrl));
  }

  Future<void> stop() async {
    if (curDev == null) {
      return;
    }
    final alive = await curDev!.alive();
    if (!alive) {
      return;
    }
    curDev!.stop(const StopInput());
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
          backgroundColor: Theme.of(context).colorScheme.inversePrimary,
          title: Text(widget.title),
        ),
        body: Center(
          child: Column(
            mainAxisSize: MainAxisSize.min,
            children: [
              const Text('选择设备:'),
              devices.isNotEmpty
                  ? DropdownButton<Device>(
                      value: curDev,
                      elevation: 16,
                      style: const TextStyle(color: Colors.deepPurple),
                      underline: Container(
                        height: 2,
                        color: Colors.deepPurpleAccent,
                      ),
                      onChanged: (Device? value) {
                        curDev = value;
                        setState(() {});
                      },
                      items: devices.map<DropdownMenuItem<Device>>((dev) {
                        return DropdownMenuItem<Device>(
                          value: dev,
                          child: Text(dev.spec.friendlyName),
                        );
                      }).toList(),
                    )
                  : const Text('无设备'),
              TextButton(onPressed: search, child: const Text('Search')),
              TextButton(onPressed: play, child: const Text('Play')),
              TextButton(onPressed: stop, child: const Text('Stop')),
            ],
          ),
        ));
  }
}
@dart-github-bot
Copy link
Collaborator

Summary: The user is experiencing a "SocketException: Send failed (OS Error: No route to host)" error when using the castscreen package on iOS. The error occurs during device discovery and prevents the app from connecting to Chromecast devices.

@dart-github-bot dart-github-bot added area-pkg Used for miscellaneous pkg/ packages not associated with specific area- teams. triage-automation See https://github.com/dart-lang/ecosystem/tree/main/pkgs/sdk_triage_bot. type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) labels Jul 16, 2024
@lrhn lrhn added area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends. library-io os-ios and removed area-pkg Used for miscellaneous pkg/ packages not associated with specific area- teams. triage-automation See https://github.com/dart-lang/ecosystem/tree/main/pkgs/sdk_triage_bot. labels Jul 19, 2024
@a-siva a-siva added the needs-info We need additional information from the issue author (auto-closed after 14 days if no response) label Jul 24, 2024
@a-siva
Copy link
Contributor

a-siva commented Jul 24, 2024

@billcoding is the issue here about the unhandled exception or the fact that you are getting a 'No route to host' error ?

@github-actions github-actions bot removed the needs-info We need additional information from the issue author (auto-closed after 14 days if no response) label Jul 25, 2024
@billcoding
Copy link
Author

@a-siva It's 'No route to host' error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends. library-io os-ios type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)
Projects
None yet
Development

No branches or pull requests

4 participants