engine/docs/DEBUG_PORTS_AND_SERVICES.md
It is possible to connect to and interact with a debug version of the engine through a number of different open TCP ports and services. The following services and ports are typically available in a debug build of the engine:
DM_SERVICE_PORT environment variable. When running from the editor DM_SERVICE_PORT is set to “dynamic” which means that the engine will let the OS assign a random available port.mDNS/DNS-SD is used by the running engine to broadcast its existence on the network so that the editor can discover it and connect to issue commands.
The service type is _defold._tcp.local and discovery metadata is provided through TXT records. The editor uses this metadata directly to build targets.
The advertised instance name is a protocol identifier, not display text: it is emitted as defold[-<sanitized-address>][-<port>][-<startup-suffix>], must fit within one 63-byte DNS label, and may omit the address segment when keeping the port and suffix makes the label more useful. The editor-facing display name and stable target identity come from the TXT name and id entries instead of the wire instance label.
dns-sd -B _defold._tcp local
The engine service is implemented as a small web server running within the engine. The server provides a number of endpoints which can be used to query for data or issue commands:
This endpoint will accept a POST request containing a protobuf command. One such example is the Reload command from resource_ddf.proto to reload a resource when hot-reloading content. Examples (also check engine.clj where some of these are used):
/post/@system/reboot - Reboot the engine. com.dynamo.system.proto.System$Reboot/post/@system/run_script - Run a Lua script. com.dynamo.engine.proto.Engine$RunScript/post/@render/resize - Resize the engine window. com.dynamo.render.proto.Render$Resize/post/@resource/reload - Reload a resource (ie hot-reload). com.dynamo.resource.proto.Resource$ReloadThis endpoint will accept a GET request and reply with a "pong". This can be used to check that the server is running and responding to requests.
This endpoint will accept a GET request and reply with a JSON formatted string containing information about the engine:
{"version": "1.4.1", "platform": "x86_64-macos", "sha1": "8f96e450ddfb006a99aa134fdd373cace3760571", "log_port": "7001"}
The redirect service will redirect any request to the engine service on its actual port (see Engine Service)
The log service can be used to read logs from the engine using a TCP socket.
Remotery, the high performance profiler used in Defold, serves data on port 17815 using a Web Socket connection.