This page is for partners integrating with our RTC service (at the server application layer). It explains what thenetparameter of the RTC grant endpointchannel/grantmeans, and how your own backend decides whether a user should use the内网(internal network) or外网(public network) line.
1. The net parameter
netis defined on the RTC service we (the RTC layer) have deployed, and generally supports two values:内网(internal network) and外网(public network). (You can configure one or more network lines according to your scenarios.)- When you call the grant endpoint without
net, it defaults to内网. - Based on this parameter, we (RTC) decide the actual service addresses returned to the client SDK, including the API service, channel control messaging service, media service, and more.
- In other words: whether the client ends up connecting to internal or public addresses is decided entirely by this single
netfield. If you pass the wrong value, the client gets the wrong addresses and either can’t connect or takes the wrong line.
2. What you (the integrating party) need to do
When calling our RTC grant endpointchannel/grant, you must include the agreed net value (内网 or 外网) in the request.
It comes down to one question: how does your backend know whether to fill in 内网 or 外网 for this request?
3. Two ways to determine net (pick one)
Option A: The user chooses manually
- Pros: The most accurate; doesn’t depend on any network detection.
- Cons: The user has to choose each time, which adds friction for users, and the user may choose wrong.
Option B: Your backend decides automatically (recommended; you can refer to our demo implementation)
- Pros: Invisible to the user; traffic is routed automatically.
- Cons: You need to implement a short piece of decision logic in your backend (the logic is simple; see the pseudocode below).
Note: The demo in this project is a reference implementation of the server application layer, and it uses Option B internally to determinenet. You don’t have to use the demo—just computenetin your own backend with the same logic, and then call ourchannel/grant.
4. Line decision flowchart
Matching rule: “a line is matched by the request domain” in the decision node means the request Host contains the domain string configured for that line (substring match, not exact equality). For example, if a line is configured withexample.com, thenmeeting.example.comalso matches that line.
5. matchNetwork logic (pseudocode)
The decision logic for Option B is as follows and can be ported directly to any language:
- Match by the access domain first—you configure a different entry domain for each line, and whichever domain the user comes in through decides the line. This is the most accurate.
- If no domain is configured or none matches, fall back to the client IP: internal IP →
内网, public IP →外网. - The
netyou finally pass to us can only be内网or外网.
Note: The line names and domains in the pseudocode above are only format examples. Real values come from your own config file, and the config file may be empty (in which case step 3, the IP fallback, is used).
6. Alignment and notes
- The
netyou pass to us must be内网or外网; if omitted it defaults to内网. Don’t pass any other value that hasn’t been agreed on. - If your network environment is simple and your users’ origins are clear, Option B (domain matching + IP fallback) is the least effort—just implement the pseudocode above.
- If the boundary between your internal and public networks is complex and automatic detection is prone to errors, we recommend Option A (manual selection by the user), which is the least error-prone.
- Before going live, we recommend verifying once each with an internal user and a public user, to confirm the
mqttand media addresses they actually receive are as expected.
7. Reverse proxy (Nginx) considerations
The line decision above relies on two key pieces of information: the request domainHost (for domain matching) and the client’s real IP (for the internal/public fallback). If your service sits behind a reverse proxy such as Nginx, it must forward both correctly; otherwise domain matching gets the proxy’s domain, and the IP fallback sees the proxy’s internal IP and picks the wrong line.
Key Nginx configuration example:
Host $host: Passes the domain the user actually accessed to the backend, so the domain matching logic gets the real entry domain.X-Real-IP $remote_addr: Passes the client’s real IP.X-Forwarded-For $proxy_add_x_forwarded_for: Appends the client IP to the forwarding chain, so the backend can get the real IP from trusted headers.X-Forwarded-Proto $scheme: Passes the original access protocol (http/https), in case you have protocol-dependent logic.
Tip: When the backend gets the client IP, it should read trusted headers such asX-Real-IP/X-Forwarded-Forfirst (and trust them only from proxy sources), rather than the TCP peer address; otherwise you get Nginx’s IP instead of the user’s.