You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This task is to allow actor containers to listen on multiple ports.
I guess one open question is how the router deals with? Will it add listeners dynamically as actor templates are created? Will the DNS names be extended to include the port in the name (some sandboxing tools do this).
One concrete design that fits this issue is to encode the target actor port in the left-most DNS label, while preserving the existing host format as the default-port path.
my-actor.actors.resources.substrate.ate.dev -> my-actor on port 80
8080-my-actor.actors.resources.substrate.ate.dev -> my-actor on port 8080
49983-sbx1.actors.resources.substrate.ate.dev -> sbx1 on port 49983
Why this shape:
It does not require dynamic listener creation in Envoy or atenet.
It should work with the existing wildcard DNS shape because the host still ends in actors.resources.substrate.ate.dev.
It is backwards compatible: hosts without a numeric prefix keep routing to port 80.
It matches the convention used by several sandbox systems where a sandbox service port is encoded in the hostname.
It enables generic multi-service actors, not just one specific SDK or compatibility layer.
Implementation sketch:
Extend the actor-host parsing helper in cmd/atenet/internal/router/extproc_in.go so it returns both actorID and port.
If the left-most label matches ^(\d+)-(.+)$, parse the leading digits as the port and the remainder as the actor ID.
If there is no numeric prefix, keep the existing behavior and default the port to 80.
Validate the parsed port is in 1..65535; invalid ports should fail routing rather than falling back silently.
In cmd/atenet/internal/router/extproc.go, replace the hardcoded net.JoinHostPort(workerIP, "80") with net.JoinHostPort(workerIP, parsedPort).
Add unit tests for default-port routing, prefixed-port routing, invalid ports, and ambiguous labels.
The main ambiguity is actor IDs that themselves start with <digits>-, since DNS-1123 allows that. I think the router should use a simple deterministic rule: if the first label matches ^(\d+)-(.+)$, it is treated as a port-prefixed actor host. Clients or higher-level tools that generate actor IDs for multi-port access can avoid IDs beginning with <digits>-. Existing actor IDs that do start with digits still work on the default route as long as the label does not start with <digits>-; if they do, callers can use the default unprefixed host only.
This would also support higher-level sandbox runtimes that expose multiple in-actor services, for example command/filesystem API, code execution API, VNC/noVNC, user HTTP servers, or debugging endpoints, without requiring every actor image to run an extra in-actor reverse proxy just to multiplex ports.
I see you mentioned this is common pattern for some of the sandbox providers -- any references? I am a bit concerned if we don't allow for dynamic ports this will be significant friction for users. If this actually well-supported, then doing this through DNS is less of a concern.
Would it make more sense to extend the dns name vs adding it to the ID label? So the name would be: port-<port>.<actor id>.actors.resources.substrate.ate.dev:
It still allows for the full DNS label for the actors ID.
No interference between port and id and we could support direct access to the port on the current actor dns name as well.
There are workarounds for port handling -- we can use transparent port rewriting (outside Envoy) used by meshes and have Envoy read the original port, so this is less of a concern re: dynamic updates to the router component.
It is backwards compatible: hosts without a numeric prefix keep routing to port 80.
Unfortunately, it seems ambiguous, unless I am missing something. Specifically, I can create an actor named "foo" or "80-foo" or "8080-80-88-foo" and those are all valid actor names. How then do you parse out the port number? In fact, I can create an actor named "80" which is weird, IMO, but is a valid DNS label.
I think Bowei Du (@bowei) is right - something like 80.<actor>.actors... is needed. At some point we will need to revisit the overall domain, but in the meantime...
Do we want to encode this as <portnum>.<actor>.actors... (implying the only prefix is a port number) or more generally like port-<portnum>.<actor>.actors..., which is more verbose but allows potentially other metadata?
One more thing IMO is super important -- this is very much a user friction, interop story where we should check whether or not someone can bring their framework with no or minor modifications and use it with Substrate.
Bowei Du (@bowei) on references — E2B is a concrete example, and it answers the dynamic-port concern directly. Its public URL is https://<port>-<sandboxId>.e2b.app (sandbox.getHost(port) is just client-side string assembly), and the
port routing happens entirely in their edge proxy: it parses <port> and <sandboxId> from the hostname at request time, finds the sandbox, and forwards to that port. The user just listens on the port inside the sandbox
(bound to 0.0.0.0) — no in-sandbox reverse proxy, no config, and crucially no pre-registration of ports. So the hostname-encoded approach is already fully dynamic; there's no per-port listener setup and no friction when a
sandbox opens a new port. GitHub Codespaces (<codespace>-<port>.app.github.dev) works the same way.
The one thing we can't copy from E2B is the hyphen. Their sandbox IDs are constrained random strings, so <port>-<id> never collides. Our actor IDs are arbitrary DNS-1123 labels (80, 80-foo, … are all valid), which is
exactly the ambiguity Tim Hockin (@thockin) flagged. That's why I'd switch to the dot-separated label you both suggested — port-<port>.<actor>.actors.resources.substrate.ate.dev — where the . boundary makes it unambiguous regardless of
the actor ID. So E2B actually supports the design direction; we just need a separator the actor ID can't contain.
The general approach seems OK, though I am a little worried that we end up with things like port-<p>.foo-<f>.bar-<b>.whatever-<w>.<name>.<atespace>.actors.resources.substrate.ate.dev where the whole prefix is a pseudo-map. This would also suggest that reordering the metadata would be equivalent but not equal. Maybe we need to mandate that metadata segments are sorted lexicographically (LC_SORT=C)?
This would make http://port-99.foo.bar.actors.resources.substrate.ate.dev unambiguous but how about if I don't spec a port? What port does http://foo.bar.actors.resources.substrate.ate.dev mean? Does it change if I use https?
The current setup goes through Kubernetes Serivce and this does impose a limit on the number of different ports that could be allocated. We technically can put a quite a few Ports on a Service, but there is some limit way less than 65k.
Maybe we should have fixed the all ports thing in K8s back then...
Clarify my comment -- it was to consider IF we wanted to support arbitrary numbers of ports and especially if we want to allow the user not have to declare ports apriori, the Kubernetes limitation comes into play.
This has been added via the CONNECT support. I am going to mark this as done, please open with a new issue for additional feature requests around multi-port support.
Activity
BenTheElder commentedon Jun 17, 2026
See also: #240 (it's also hardcoded in ateom at the moment, but I think we can/should lift that part)
rogeroger-yu commentedon Jun 24, 2026
One concrete design that fits this issue is to encode the target actor port in the left-most DNS label, while preserving the existing host format as the default-port path.
Proposed routing format:
Examples:
Why this shape:
atenet.actors.resources.substrate.ate.dev.Implementation sketch:
cmd/atenet/internal/router/extproc_in.goso it returns bothactorIDandport.^(\d+)-(.+)$, parse the leading digits as the port and the remainder as the actor ID.80.1..65535; invalid ports should fail routing rather than falling back silently.cmd/atenet/internal/router/extproc.go, replace the hardcodednet.JoinHostPort(workerIP, "80")withnet.JoinHostPort(workerIP, parsedPort).The main ambiguity is actor IDs that themselves start with
<digits>-, since DNS-1123 allows that. I think the router should use a simple deterministic rule: if the first label matches^(\d+)-(.+)$, it is treated as a port-prefixed actor host. Clients or higher-level tools that generate actor IDs for multi-port access can avoid IDs beginning with<digits>-. Existing actor IDs that do start with digits still work on the default route as long as the label does not start with<digits>-; if they do, callers can use the default unprefixed host only.This would also support higher-level sandbox runtimes that expose multiple in-actor services, for example command/filesystem API, code execution API, VNC/noVNC, user HTTP servers, or debugging endpoints, without requiring every actor image to run an extra in-actor reverse proxy just to multiplex ports.
atenet: route actor hosts by optional "<port>-" prefix
ateom-gvisor: DNAT all inbound TCP ports to the actor
bowei commentedon Jun 24, 2026
Couple of notes:
port-<port>.<actor id>.actors.resources.substrate.ate.dev:thockin commentedon Jun 24, 2026
Unfortunately, it seems ambiguous, unless I am missing something. Specifically, I can create an actor named "foo" or "80-foo" or "8080-80-88-foo" and those are all valid actor names. How then do you parse out the port number? In fact, I can create an actor named "80" which is weird, IMO, but is a valid DNS label.
I think Bowei Du (@bowei) is right - something like
80.<actor>.actors...is needed. At some point we will need to revisit the overall domain, but in the meantime...Do we want to encode this as
<portnum>.<actor>.actors...(implying the only prefix is a port number) or more generally likeport-<portnum>.<actor>.actors..., which is more verbose but allows potentially other metadata?bowei commentedon Jun 25, 2026
One more thing IMO is super important -- this is very much a user friction, interop story where we should check whether or not someone can bring their framework with no or minor modifications and use it with Substrate.
rogeroger-yu commentedon Jun 29, 2026
Bowei Du (@bowei) on references — E2B is a concrete example, and it answers the dynamic-port concern directly. Its public URL is
https://<port>-<sandboxId>.e2b.app(sandbox.getHost(port) is just client-side string assembly), and theport routing happens entirely in their edge proxy: it parses
<port>and<sandboxId>from the hostname at request time, finds the sandbox, and forwards to that port. The user just listens on the port inside the sandbox(bound to 0.0.0.0) — no in-sandbox reverse proxy, no config, and crucially no pre-registration of ports. So the hostname-encoded approach is already fully dynamic; there's no per-port listener setup and no friction when a
sandbox opens a new port. GitHub Codespaces (
<codespace>-<port>.app.github.dev) works the same way.Docs: https://e2b.dev/docs/sandbox/internet-access
The one thing we can't copy from E2B is the hyphen. Their sandbox IDs are constrained random strings, so
<port>-<id>never collides. Our actor IDs are arbitrary DNS-1123 labels (80, 80-foo, … are all valid), which isexactly the ambiguity Tim Hockin (@thockin) flagged. That's why I'd switch to the dot-separated label you both suggested —
port-<port>.<actor>.actors.resources.substrate.ate.dev— where the . boundary makes it unambiguous regardless ofthe actor ID. So E2B actually supports the design direction; we just need a separator the actor ID can't contain.
thockin commentedon Jul 7, 2026
(note: I edited the last comment to wrap
<stuff in angle brackets>with backquotes - github allows naked HTML, apparently.Does it blink?
thockin commentedon Jul 7, 2026
The general approach seems OK, though I am a little worried that we end up with things like
port-<p>.foo-<f>.bar-<b>.whatever-<w>.<name>.<atespace>.actors.resources.substrate.ate.devwhere the whole prefix is a pseudo-map. This would also suggest that reordering the metadata would be equivalent but not equal. Maybe we need to mandate that metadata segments are sorted lexicographically (LC_SORT=C)?This would make
http://port-99.foo.bar.actors.resources.substrate.ate.devunambiguous but how about if I don't spec a port? What port doeshttp://foo.bar.actors.resources.substrate.ate.devmean? Does it change if I use https?bowei commentedon Jul 17, 2026
This was pointed out in a side conversation:
The current setup goes through Kubernetes Serivce and this does impose a limit on the number of different ports that could be allocated. We technically can put a quite a few Ports on a Service, but there is some limit way less than 65k.
Maybe we should have fixed the all ports thing in K8s back then...
thockin commentedon Jul 19, 2026
I thought all the service does is 443/80 (for now)? Eventually TCP will be a problem...
bowei commentedon Jul 19, 2026
Clarify my comment -- it was to consider IF we wanted to support arbitrary numbers of ports and especially if we want to allow the user not have to declare ports apriori, the Kubernetes limitation comes into play.
EItanya commentedon Jul 24, 2026
Given #445 and #484, I'm more than a little worried about relying on DNS for this feature.
However, I do think this is a pretty large limitation and might be worth adding to M2 if we think we can fit it in
bowei commentedon Aug 24, 2026
This has been added via the CONNECT support. I am going to mark this as done, please open with a new issue for additional feature requests around multi-port support.
EItanya commentedon Aug 24, 2026
I agree that this should be closed, should we create a follow-up to remove the single port implementation as clean-up?