Open himat opened 1 month ago
What I think you're running into is a combination of two things.
First, it looks like you want to forward to a local port (3128
), but .forwards_to
is just setting informational metadata, so that doesn't actually influence things, rather Tunnel::forward_tcp
is I believe what you're after
Second, like the warning says, it looks like the tunnel is being dropped before it's being polled for any connections, i.e.
= note: streams do nothing unless polled
I think the minimal fix would be changing main to something like:
- listen_ngrok().await?;
+ let mut tun = listen_ngrok().await?;
+ let _ = tun.forward_tcp("127.0.0.1:3128").await?;
There's a more complete example of this over in examples here (though the forward_http
would probably need to become forward_tcp
for this case).
In v0.14 (still in pre-release) there's also a few more helpers around forwarding traffic, so that example has changed a bit. You can use the pre-release version if you'd like to play with that interface instead of course!
Let me know if that helps! I do think the mingrok.rs
code in examples
is quite close to what you're trying to do, so I think it could be a good starting point, good luck!
@himat following up here. Did what @euank mentioned help you?
I think I'm doing something wrong with my code since it's not actually connecting to my account's tcp endpoint
Here's my simple code:
When I run this, I see
But it's not actually connected, I'm unable to proxy through my localhost:3128 and when I go to https://dashboard.ngrok.com/cloud-edge/tcp-addresses, this endpoint is not showing up as connected/live.