We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent d3df144 commit 30267a6Copy full SHA for 30267a6
src/content/docs/durable-objects/api/container.mdx
@@ -126,6 +126,21 @@ const res = await port.fetch("http://container/set-state", {
126
});
127
```
128
129
+```js
130
+const conn = this.ctx.container.getTcpPort(8080).connect('10.0.0.1:8080');
131
+await conn.opened;
132
+
133
+try {
134
+ if (request.body) {
135
+ await request.body.pipeTo(conn.writable);
136
+ }
137
+ return new Response(conn.readable);
138
+} catch (err) {
139
+ console.error("Request body piping failed:", err);
140
+ return new Response("Failed to proxy request body", { status: 502 });
141
+}
142
+```
143
144
#### Parameters
145
146
- `port` (number): a TCP port number to use for communication with the container.
0 commit comments