Reputation: 619
I have a two part question.
First, what Dart command should I use to "start" the VM service listening for requests, with possibly giving it what host and port number to use.
I'm using Windows, and I don't need the Observatory possibly interfering.
I'm currently trying to use this, after I CD into the project's directory:
dart --pause_isolates_on_start bicycle
And the second part of the question is, is it possible to verify that the VM service is there and listening on whatever port?
I want to be able to send a request to the VM service, from a WebSocket client, and get back a response.
After I give the above command, if I do a 'netstat' it doesn't look like there is anything there listening.
And any attempts at trying to connect to the VM service get a connection refused Exception, same as if I didn't even try to start the VM service.
UPDATE:
I was looking at the intelliJ plugin code, to see how they did their connect, and saw that they used "ws://localhost:8181/ws", I was trying to use "ws://localhost:8181", and now it's finally getting past the handshake, the server was returning "200 OK" instead of "101" before.
I'm assuming that I'm talking to the Observer at this point, and not the VM service, I'm not sure, but at least I'm further along..
When it worked, I was using:
dart --enable-vm-service --pause_isolates_on_start bicycle.dart
Thanks!!
Upvotes: 0
Views: 6747
Reputation: 657781
dart --help -v
prints
--observe[=<port>[/<bind-address>]]
The observe flag is a convenience flag used to run a program with a
set of options which are often useful for debugging under Observatory.
These options are currently:
--enable-vm-service[=<port>[/<bind-address>]]
--pause-isolates-on-exit
--pause-isolates-on-unhandled-exceptions
--warn-on-pause-with-no-debugger
This set is subject to change.
Please see these options for further documentation.
It depends on what exactly you want to do, but as far as I know the Observatory just uses this service and if you don't access any of its features, it won't add additional load to the process.
There is a Dart client API https://pub.dartlang.org/packages/vm_service_client and a documentation about the protocol https://github.com/dart-lang/sdk/blob/master/runtime/vm/service/service.md
Perhaps this is what you are looking for
enum EventKind {
// Notification that VM identifying information has changed. Currently used
// to notify of changes to the VM debugging name via setVMName.
VMUpdate,
// Notification that a new isolate has started.
IsolateStart,
used with Events https://github.com/dart-lang/sdk/blob/master/runtime/vm/service/service.md#events
Upvotes: 2