Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mlaunch --tcp-tunnel with TcpListener and TcpClient works only once #20598

Closed
JaneySprings opened this issue May 12, 2024 · 3 comments
Closed
Labels
need-info Waiting for more information before the bug can be investigated
Milestone

Comments

@JaneySprings
Copy link

Hi! I have a simple app with TcpListener and TcpClient for working with iOS device. I use mlaunch --tcp-tunnel for the communication. For the first time it works perfectly. But for the second time it gets the incorrect stream(?) and hangs at ReadLine() (client and listener).

Example

TcpListener (iOS device side):

var tcpListener = new TcpListener(IPAddress.Loopback, 9988);
tcpListener.Start();
 
while (true) {
     using var client = await tcpListener.AcceptTcpClientAsync();
     using var stream = client.GetStream();
     using var reader = new StreamReader(stream);
     using var writer = new StreamWriter(stream) { AutoFlush = true };
      
     var request = await reader.ReadLineAsync(); // hangs here
     await writer.WriteLineAsync("message from device");
}

dotnet console app:

using var client = new TcpClient("localhost", port);
using var stream = client.GetStream();
using var writer = new StreamWriter(stream) { AutoFlush = true };
using var reader = new StreamReader(stream);

writer.WriteLine("message to device");
var response = reader.ReadLine();  // hangs here

Steps to Reproduce

  1. run mlaunch --tcp-tunnel=9988:9988 --devname=<udid>
  2. run the console app from example -> OK
  3. run the console app from example -> hanging on ReadLine()

Expected Behavior

works every run

Actual Behavior

Hangs after first try

Environment

9.0.100-preview.3.24204.13
Xamarin.Launcher 1.0.83 (refs/heads/main: 699ed5eaf2)

maui-maccatalyst           9.0.0-preview.3.10457/9.0.100-preview.3      SDK 9.0.100-preview.3
maui-ios                   9.0.0-preview.3.10457/9.0.100-preview.3      SDK 9.0.100-preview.3

Xcode 17.2
MacOS 14.4.1
iOS 16.7.7

@rolfbjarne
Copy link
Member

I'm not entirely sure I understand your scenario, but mlaunch --tcp-tunnel is a single-attempt tunnel. If any side closes the connection, you'll have to run mlaunch again to re-establish a new tunnel.

So as far as I can tell this behaves as expected?

@rolfbjarne rolfbjarne added the need-info Waiting for more information before the bug can be investigated label May 21, 2024
@rolfbjarne rolfbjarne added this to the Future milestone May 21, 2024
Copy link
Contributor

Hi @JaneySprings. We have added the "need-info" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

@JaneySprings
Copy link
Author

Yes, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
need-info Waiting for more information before the bug can be investigated
Projects
None yet
Development

No branches or pull requests

2 participants