Background:
I am running a cross-platform Xamarin.Forms app on a Nexus 7 (Android API level 22) that is configured to (in order):
10.0.0.0/5000
)on startup.
Visual Studio 2019 Preview (v16.0.0 Preview 1.1)
, Xamarin.Forms (v3.4.0.1008975)
, and Xamarin.Android (v28.0.0)
.hostapd
and dnsmasq
on Raspbian Stretch. This access point hands out IP addresses in the range of 10.0.0.1
to 10.0.0.20
, with a default gateway of 10.0.0.0
. The network currently does not have Internet, but I may add it in the future.TcpClient
so it can receive sensor data from the Pi.The issue:
The app successfully connects to the WiFi and Bluetooth (steps 1 and 3), but I am getting a System.Net.Sockets.SocketException
(HRESULT: 0x80004005
) when it attempts to connect to the Python script (step 2). Here is the stack trace:
{System.Net.Sockets.SocketException (0x80004005): Network is unreachable
at System.Net.Sockets.SocketAsyncResult.CheckIfThrowDelayedException ()
[0x00014] in <165f7048c1ba483e8b4fcc215c691e9e>:0
at System.Net.Sockets.Socket.EndConnect (System.IAsyncResult asyncResult)
[0x0002c] in <165f7048c1ba483e8b4fcc215c691e9e>:0
at System.Net.Sockets.TcpClient.EndConnect (System.IAsyncResult asyncResult)
[0x0000c] in <165f7048c1ba483e8b4fcc215c691e9e>:0
at System.Threading.Tasks.TaskFactory`1[TResult].FromAsyncCoreLogic
(System.IAsyncResult iar, System.Func`2[T,TResult] endFunction,
System.Action`1[T] endAction, System.Threading.Tasks.Task`1[TResult]
promise, System.Boolean requiresSynchronization) [0x00019] in
<76298308b9444eca9d8db328b3554473>:0
--- End of stack trace from previous location where exception was thrown ---
at Liberty_Console.Models.Statics+<ConnectAsync>d__2.MoveNext () [0x00052]
in C:\Users\Micah\Source\Repos\Liberty Console\Liberty Console\Liberty
Console\Models\Statics.cs:27 }
And this is the code that's causing it:
TcpClient client = new TcpClient(AddressFamily.InterNetwork);
await client.ConnectAsync("10.0.0.0", 5000); //System.Net.Sockets.SocketException
I have:
android.permission.ACCESS_NETWORK_STATE
android.permission.ACCESS_WIFI_STATE
android.permission.BLUETOOTH
android.permission.BLUETOOTH_ADMIN
android.permission.CHANGE_NETWORK_STATE
android.permission.CHANGE_WIFI_STATE
android.permission.INTERNET
10.0.0.X
)5000
is open on the router/gatewaySystem.Net.NetworkInformation.Ping
class
My deduction:
Based on my tests and debugging, it seems like the app is unable to make requests on the network (hence it is "unreachable"). This may be due to:
192.168.1.X
instead of 10.0.0.X
)Any help is greatly appreciated!
Let me know if the question needs more detail or clarification.
User contributions licensed under CC BY-SA 3.0