-
Notifications
You must be signed in to change notification settings - Fork 5
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: "connection not upgraded to websocket" #6
Comments
Okay, a bit of progress - I was able to reference this library for a way to get the correct URL. It looks like this: import 'dart:developer' as dev;
import 'package:path/path.dart' as path;
main(List<String> args) async {
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.addPackagePath(Uri(scheme: 'package', path: 'server_test/'));
await reloader.go();
}
// ...
} Something similar should probably replace the constant URL in the library? (Let me know if you'd like a PR for that change.) This gets me connected and running - I now see messages like these:
So far, so good. It doesn't work though - changes made to that script don't have any effect. I'm using I don't know the limitations or the precise workings of hot reloading, but would I need to do something else to get this working? (e.g. tear down and rebuild my |
I've also tried the basic example that ships with the package, and this doesn't work either. For example, changing the |
For the record, someone on the Dart Gitter channel gave it a shot on Linux - he also had to copy the code I posted (to get the websocket path) to get it working, so that bit needs a PR either way. He then confirmed that the example did work for him. So the issue is likely Windows-specific. We also found that the vm_service_lib package has been superseded by the vm_service package and should be upgraded - I tried switching that dependency, which was easy enough, just needs a simple update of the |
Please submit a PR with the fix. |
I will open a separate issue to track the Windows problem. |
Thank you so much @mindplay-dk, your snippet worked for me on a macOS setup where I was having this issue as well. |
I've got a straight forward setup like this:
When I launch my
server.dart
script, I get this output:But the moment I change one of the files, it crashes with this stack trace:
I'm on 64-bit Windows 10 with the following Dart version:
I noticed a mismatch in socket URLs between the startup message:
And the error message:
The websocket URL displayed at startup contains a random key that changes with every launch, so a constant is probably not enough to make this work.
Likely related to #5, though the error message in that issue is different. (?)
Let me know if there's anything I can do to help resolve the issue.
The text was updated successfully, but these errors were encountered: