angelobreuer/localtunnel.net

.Net Library Not Creating Tunnel

Closed this issue · 5 comments

I'm attempting to create a tunnel using the .NET Library and then I have some other code that acts as an HTTP Listener to capture traffic on the tunnel.

I can get the CLI to work using the parameters of "-p 3000 -d my-sample-tunnel http" which creates https://my-sample-tunnel.loca.lt/ and when I attempt to go there it will eventually give me a 504 Gateway Timeout which I would expect.

However, when using the code, the https://my-sample-tunnel.loca.lt/ page loads and just says "404" on it.

Here's my sample code:

using var client = new LocaltunnelClient();
var options = new ProxiedSslTunnelOptions { };
options.Port = 3000;

var tunnel = await client.OpenAsync(x => new ProxiedSslTunnelConnection(x, options), "my-sample-tunnel");

await Task.Delay(-1);

I've also tried replacing the ProxiedSsl options/connection with the ProxiedHttp and get the same issue.

Any ideas what I'm doing wrong?

A few things come to my mind, as to why this may be not working:

  • Please check the tunnel.Information.Url property. Possibly the server rejects the subdomain request and gives you a random subdomain.
  • Check if your server allows different origins and hosts. If you did not change the options, then it will normally rewrite the host to localhost.
  • Check if the server is even getting the request (in the logs), and if not, check if there is more error information on the 404 page.

The code you sent should work fine.

I did make sure the URL was getting populated fine and added logging that shows it's being created correctly:
https://imgur.com/a/6Y9tZkc

There's not much else on the 404 page, it just looks like this:
https://imgur.com/a/7bVx3GV

I also tried making simple Postman calls to both the CLI and the console version of the app and the CLI recognizes the POST call but the console version just returns 404 Not Found.

It seems like the StartAsync call on the tunnel instance is missing. I have to admit, that it was even not included in the sample on the README.

I've previously pushed a preview version of localtunnel which is valid for the current README sample

The new code appears to have resolved the issue.

One thing I noticed however, was in both the CLI and the .NET Library, when I tell it to only be 1 Max Connection, it still displays 10 in the logging/dashboard

It may be confusing, the option in the options instance is for limiting the maximum concurrent connections. The display in the dashboard and tunnel information is the maximum allowed concurrent connection count, indicated by the server. If you specify one connection maximum, it should only create one (or fewer, if the maximum concurrent connection count advertised by the server is lower than the requested)