Jaguar-dart / jaguar_hotreload

Hot reloader for Dart
BSD 3-Clause "New" or "Revised" License
9 stars 5 forks source link

Fails to work due to SocketException #5

Open TobiasHeidingsfeld opened 5 years ago

TobiasHeidingsfeld commented 5 years ago

When running with

final reloader = new HotReloader(); reloader.addPath('.'); await reloader.go();

with --enable-vm-service=1 args the following error occures:

Exception has occurred. SocketException (SocketException: OS Error: The remote computer refused the network connection. , errno = 1225, address = localhost, port = 54394)

TobiasHeidingsfeld commented 5 years ago

It seems --enable-vm-service=8181 should do as this is the port that is hard coded but it also fails with the same error

renatoathaydes commented 4 years ago

Same problem for me on Ubuntu:

Paths ./bin/server.dart changed!
Reloading the application...
Unhandled exception:
SocketException: OS Error: Connection refused, errno = 111, address = localhost, port = 49406
#0      vmServiceConnectUri (package:vm_service_lib/vm_service_lib_io.dart:20:22)
<asynchronous suspension>
#1      HotReloader.reload (package:jaguar_hotreload/src/jaguar_hotreload_base.dart:350:23)
<asynchronous suspension>
#2      new HotReloader.<anonymous closure> (package:jaguar_hotreload/src/jaguar_hotreload_base.dart:124:13)
<asynchronous suspension>
....

It works when I use this snippet (posted by @mindplay-dk on gitter) instead of the one shown in this lib's docs:

  if (HotReloader.isHotReloadable) {
    var info = await dev.Service.getInfo();
    var uri = info.serverUri;
    uri = uri.replace(path: path.join(uri.path, 'ws'));
    if (uri.scheme == 'https') {
      uri = uri.replace(scheme: 'wss');
    } else {
      uri = uri.replace(scheme: 'ws');
    }

    print('Hot reloading enabled');
    final reloader = HotReloader(vmServiceUrl: uri.toString());
    await reloader.addPath('.');
    await reloader.go();
  }
tejainece commented 4 years ago

Please submit a PR.