Bug 60126 - iOS 11 TCP connections not working
Summary: iOS 11 TCP connections not working
Status: RESOLVED NORESPONSE
Alias: None
Product: iOS
Classification: Xamarin
Component: BCL Class Libraries ()
Version: XI 11.4 (d15-5)
Hardware: Other Other
: --- normal
Target Milestone: Future Cycle (TBD)
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2017-10-11 13:01 UTC by stanislav.svist
Modified: 2018-02-16 21:27 UTC (History)
5 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
testcase (10.95 KB, application/zip)
2017-10-11 17:35 UTC, Alex Soto [MSFT]
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and 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 Links.

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.

Related Links:
Status:
RESOLVED NORESPONSE

Description stanislav.svist 2017-10-11 13:01:39 UTC
I have a number of iOS 11 users, reporting that a TCP connection to a device in Ad-Hoc Wi-Fi network could not be established.
Remote device is a car OBD2 adapter, that creates a simple Wi-Fi network (no auth, no password, no encryption).
In iOS 8 - iOS 10 this code worked fine without any problems.
In iOS 11 it gives a very strange error.

Summary of connection code:
TcpClient client = new TcpClient();
string server = "192.168.0.10";
int port = 35000;
try
{
await client.ConnectAsync(server, port);
}
catch (Exception exc)
{

}

Here is exception details, that I've got on iOS11:
System.Net.Sockets.SocketException (0x80004005): Host is down
  at System.Net.Sockets.Socket.BeginMConnect (System.Net.Sockets.SocketAsyncResult sockares) <0x10167ab70 + 0x002b0> in <dfdaca8c413042bfa54e39ecfa379baa#a1ed88b08385f8c73b764d8fed336715>:0 
  at System.Net.Sockets.Socket.BeginConnect (System.Net.IPAddress[] addresses, System.Int32 port, System.AsyncCallback requestCallback, System.Object state) <0x10167a968 + 0x000f7> in <dfdaca8c413042bfa54e39ecfa379baa#a1ed88b08385f8c73b764d8fed336715>:0 
  at System.Net.Sockets.Socket.BeginConnect (System.String host, System.Int32 port, System.AsyncCallback requestCallback, System.Object state) <0x10167a3f4 + 0x0008f> in <dfdaca8c413042bfa54e39ecfa379baa#a1ed88b08385f8c73b764d8fed336715>:0 
  at System.Net.Sockets.TcpClient.BeginConnect (System.String host, System.Int32 port, System.AsyncCallback requestCallback, System.Object state) <0x10167e734 + 0x00013> in <dfdaca8c413042bfa54e39ecfa379baa#a1ed88b08385f8c73b764d8fed336715>:0 
  at (wrapper unknown) System.Object:gsharedvt_out ()
  at System.Threading.Tasks.TaskFactory`1[TResult].FromAsyncImpl[TArg1,TArg2] (System.Func`5[T1,T2,T3,T4,TResult] beginMethod, System.Func`2[T,TResult] endFunction, System.Action`1[T] endAction, TArg1 arg1, TArg2 arg2, System.Object state, System.Threading.Tasks.TaskCreationOptions creationOptions) <0x10108d210 + 0x00830> in <6314851f133e4e74a2e96356deaa0c6c#a1ed88b08385f8c73b764d8fed336715>:0 
  at (wrapper unknown) System.Object:gsharedvt_in ()
  at System.Threading.Tasks.TaskFactory.FromAsync[TArg1,TArg2] (System.Func`5[T1,T2,T3,T4,TResult] beginMethod, System.Action`1[T] endMethod, TArg1 arg1, TArg2 arg2, System.Object state, System.Threading.Tasks.TaskCreationOptions creationOptions) <0x10169d02c + 0x0005f> in <6314851f133e4e74a2e96356deaa0c6c#a1ed88b08385f8c73b764d8fed336715>:0 
  at System.Threading.Tasks.TaskFactory.FromAsync[TArg1,TArg2] (System.Func`5[T1,T2,T3,T4,TResult] beginMethod, System.Action`1[T] endMethod, TArg1 arg1, TArg2 arg2, System.Object state) <0x10169b3b8 + 0x0007f> in <6314851f133e4e74a2e96356deaa0c6c#a1ed88b08385f8c73b764d8fed336715>:0 
  at System.Net.Sockets.TcpClient.ConnectAsync (System.String host, System.Int32 port) <0x10167e780 + 0x0010b> in <dfdaca8c413042bfa54e39ecfa379baa#a1ed88b08385f8c73b764d8fed336715>:0 


The host is not down. Checked using iOS 10 device - working, iOS 11 - not working.
Comment 1 Alex Soto [MSFT] 2017-10-11 17:35:09 UTC
Created attachment 25277 [details]
testcase
Comment 2 Alex Soto [MSFT] 2017-10-11 17:38:46 UTC
Hello I created a simple test case using your code and I created an Ad-hoc connection to one of my macs and enabled a small http server on it, I was able to connect without issue, unfortunately, I am not able to reproduce the behaviour you are seeing, also tried to my local router to see if it made any difference but it did not.

Please include your full build logs, crash reports (if any), and all version your information.

To get full build logs just set the log verbosity to diagnostic at the following locations:
- On Visual Studio for Mac: Preferences > Projects > Build
- On Visual Studio for Windows: Tools > Options > Projects and Solutions > Build and Run

On Visual Studio Windows you also want to add `-v -v -v -v` to the mtouch additional arguments by right-clicking the project in the solution explorer and selecting `Properties`.
Note: this is done automatically on Visual Studio for Mac when the log verbosity is set to diagnostic.

The easiest way to get exact version information:
- On Visual Studio for Mac: "Visual Studio" menu, "About Visual Studio" item, "Show Details" button.
- On Visual Studio for Windows: "Help menu", "About Microsoft Visual Studio" item.
Then copy/paste the version information (you can use the "Copy Information" button).
Comment 3 stanislav.svist 2017-10-11 18:18:32 UTC
I don't have iOS11 compatible devices, so my report is based on my app users reports.
I have made some more investigations, and here's what I've found:
1) this bug happens with a small amount of users
2) if this bug is happening, other apps (not only xamarin based) can't connect to the same remote device too after updating to iOS11 (before update on iOS10 everything was OK).
Comment 4 Alex Soto [MSFT] 2017-10-11 18:30:41 UTC
do you happen to know on what iOS devices is this happening? I tested on an iPhone 6

> 2) if this bug is happening, other apps (not only xamarin based) can't connect to the same remote device too after updating to iOS11 (before update on iOS10 

What I'm reading here is that this is also happening on native ObjC/swift apps?
Comment 5 stanislav.svist 2017-10-11 19:18:04 UTC
I think yes, but I can't confirm, that other apps were not Xamarin-based too.
Comment 6 Manuel de la Peña [MSFT] 2017-11-20 12:30:40 UTC
I have tried to  reproduce the issue in an iPhone 7 with iOs 11.1.1 and failed to ge the issue. @Alex what device did you use?
Comment 7 Alex Soto [MSFT] 2018-01-03 03:18:52 UTC
Sorry @Manuel, missed your reply, I used an iPhone 6 to test.

@stanislav.svist is this still an issue?
Comment 8 Manuel de la Peña [MSFT] 2018-01-08 09:50:40 UTC
@Alex do you have another device. I can access an iPad 2, iPhone 7, iPhone 8 and iPhone 8+. Unfortunately I have no access to an iPhone 6 :(
Comment 9 Alex Soto [MSFT] 2018-01-08 14:42:13 UTC
@Manuel on iOS 11 I have an iPhone X, 6 and 7+ but we don't know if this is still and issue and this comment

> 2) if this bug is happening, other apps (not only xamarin based) can't connect to the same remote device too after updating to iOS11 (before update on iOS10 everything was OK).

makes it sound like an iOS 11 system bug, there has been some minor upgrades so could potentially been fixed on any of those, we need to know if this is still an issue (@stanislav) if so we also need the steps to reproduce this. From the given description we would only be guessing and this is the worst way to "debug" this. :)

Cheers!
Comment 10 Vincent Dondain [MSFT] 2018-02-16 21:27:44 UTC
We have not received the requested information. If you are still experiencing this issue please provide all the requested information and re-open the bug report. Thanks!