Notice (2018-05-24): bugzilla.xamarin.com is now in
Please join us on
Visual Studio Developer Community and in the
Mono organizations on
GitHub to continue tracking issues. Bugzilla will remain
available for reference in read-only mode. We will continue to work
on open Bugzilla bugs, copy them to the new locations
as needed for follow-up, and add the new items under Related
Our sincere thanks to everyone who has contributed on this bug
tracker over the years. Thanks also for your understanding as we
make these adjustments and improvements for the future.
Please create a new report on
Developer Community or GitHub with
your current version information, steps to reproduce, and relevant error
messages or log files if you are hitting an issue that looks similar to
this resolved bug and you do not yet see a matching new report.
I believe this is a bug, but not entirely sure.
In an emulator, after disabling my network connection (Windows control panel), ConnectAsync() will hang for a long time before determining that a connection could not be made.
It will also hang after the network connection has been re-enabled, for an equally long period.
I would like to think that:
1. If no network interface is connected/ready, that TcpClient should immediately be able to determine connection failure
2. If not, should at least be able to quickly make a connection after a network interface has been made ready.
It doesn't appear to be a bug. The connection has some timeout set and it waits for this period of time until the attempt fails. You can try setting a lower timeout to see if that changes the amount of time it spends waiting for the connection. If the network interface is up in the emulator, the only way to determine that the connection failed is to wait for its timeout - this stems from the client-server nature of TCP/IP.
Another issue might be that the Google Android emulator doesn't notice the Windows network connection goes down and doesn't reflect the state of the emulated network device inside the emulator, thus not letting the application know that the connection is gone. If this is what happens it would be a bug in the Google Android emulator and should be filed with the Android project bug tracker.
I'm going to close this bug since I see no evidence of an error. If, however, you determine that the emulated network interface in the emulator reflects the state of the Windows interface and it's Xamarin.Android that fails to notice the network interface being down, please reopen the bug.