Skip to content

Commit 037fb45

Browse files
committed
📝 (channels.md): add documentation for broadcasting from a different machine
1 parent f686a3d commit 037fb45

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

‎docs/Usage/channels.md‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,19 @@ If the server is running on the default host (`localhost`) and port (`8000`), no
247247
- Parameters are validated the same way as when called from actions
248248
- Works with both sync and async contexts
249249

250+
!!! note "Broadcasting from a Different Machine"
251+
By default, the broadcast endpoint only accepts connections from localhost (`127.0.0.1`, `::1`, `localhost`) for security reasons. If you need to call channel functions from a different machine or server, you must explicitly configure `broadcast_allowed_hosts` when creating the SocketAPI instance:
252+
253+
```python
254+
app = SocketAPI(
255+
host="0.0.0.0",
256+
port=8000,
257+
broadcast_allowed_hosts=("127.0.0.1", "::1", "localhost", "192.168.1.50")
258+
)
259+
```
260+
261+
Add the IP address of the machine that needs to communicate with the server to the `broadcast_allowed_hosts` tuple.
262+
250263
This feature makes SocketAPI perfect for building real-time applications that need to integrate with existing infrastructure and external services.
251264

252265
## Complete Example

0 commit comments

Comments
 (0)