Piping two TCP connections to each other
Hey, I'm messing around trying to create a proxy in deno. I want to take an incoming connection, use some logic to decide how to route it, and then create an outgoing connection to pass it to.
I have some code like this right now:
Which seems right to me in theory, but when I run it I get some streaming error after these commands all run:
Any idea if I'm using these APIs wrong, or if this might be a bug? I noticed
pipeTo
returns a promise, but if I await these it seems to stall the program indefinitely (like it's waiting for the pipe to close)3 Replies
I just realized that
read
and write
to buffers does not guarantee that the buffer is fully exhausted. I'll see if that's the issue first
Nope, if I remove the initial read/write to buffer, it still fails in the same way@Doctor 🤖 Do you happen to know this?
I'm not familiar with Deno.listen, but if you want a proxy why not use nginx?