C# System.Net.Sockets.SocketException: Network is unreachable (10051) - c#

I'm working on a Unity game that uses Mirror to establish a TCP socket connection to a game server hosted on GameLift. The server picks a random port to listen on between 45000 and 46000 before a game session starts.
One of our users cannot connect to servers when using mobile data but has no problems when on WiFi. This user's partner is experiencing the same problem. They both have the same mobile network operator (Three). The user is using an iPhone X on iOS 16 and so is the partner (not sure about the OS version).
Our logs show that TcpClient.Connect is throwing a SocketException with ErrorCode 10051 and SocketErrorCode NetworkUnreachable. There's no InnerException.
We've checked that the ports are open on the server when a game is active and other players have been able to join those game sessions.
We've checked that his mobile network allows him to use the port picked by the server using http://portquiz.net/.
I've ensured that we're using the latest version of Mirror and I've looked for a similar issue in the GitHub repo but found nothing similar.
I'm not sure what else to check and would appreciate any input you guys might have.

Related

Scanning devices in local network with xamarin (ios)

I would ask if it is possible to get information about connected devices in the local wireless network.
Is there any api for xamarin to do that?
It doesn't seem like Xamarin has an API for this, but Microsoft introduced a Ping (documentation here) and a NetworkInterface class (documentation here) in .NET 2.0 that you could use.
Essentially, what you need to do, is to ping the IP adresses on your local network, which you can do asynchronously using SendAsync(). You then register the callbacks by registering an EventHandler to PingCompleted. The callback will contain a PingCompletedEventArgs which you can use to retrieve basic information (e.g. IP, MAC and Hostname) about the device.
You can find a complete guide of the implementation here.
I hope this helps.
Note: Of course, it all depends on what type of information you expect to retrieve. Although, I think you can only expect to retrieve the basic information about devices on your network, as everything else could potentially be a security risk.
Secondary note: Depending on which devices you wish to discover on your network, you could also use the SNMP component which will allow you to discover devices such as routers, switches, printers, and so on.
I am thinking you are looking for which devices at layer-2 have registered with your wireless controller/accept-point/router and by being connected you are referring to how many have successfully establish 802.x handshake (implying security exchange and channel establishment has occurred).
There exists a tool to do this work (never tested this on my mac) and you can check Flying Squirrel for the above purpose. This will ofcourse be an independent sniffer over the wireless network and you'll require the password used for wifi etc. for making this work.
If you have access to a device that exposes instrumentation (MIB) then you can get that information from the device by SNMP walking the device. At this level you'll of course get the MAC address table and if DHCP is running on your router then perhaps access to DHCP table can give you information about the MAC to IP mapping. On some medium to high end networking gear MIBs like CISCO-DOT11-ASSOCIATION-MIB can be used. Also I am assuming you are refering to 802.11 here there are other wireless protocols like BlueTooth etc. in play as well which use different scanning techniques so the answer depends on what kind of network you are referring to here.
Ok, I figured out a way without snifing the local network. It makes more sense the following way in my case...
Case:
I want to connect to an device which provide an own wlan network. Then I connect to it and pass the home wlan network to it. The device restarts and is now configured as a client in the local home network. And now I need the local ip for service communications.
My Solution:
I do a register call to the device. The device gives me the mac address. Now I register (with phone device) the mac address from the access point device in a online service. After the device has been restarted and get the new local ip address it sends to the online service.
And the I can retrieve the local ip address through polling or through getting push notification from the server...

C# Identify Network Connected To

I'm working on an app that will copy files to a server.
I need a way to determine if the client is physically attached to the network (LAN cable or wirelessly attached), or if the client is connecting via some other way.
For example, if my app was running on my laptop at the office I might be plugged in. Later I disconnect and go home and my laptop is then connected to my router and my provider.
I thought of checking the domain name but that just gives me the name of my dev PC. I also considered seeing if a file share is available, but if someone who was NOT really connected created a mapping with the same name then its a false result.
In the end the app will determine how it's connected, and then either do a file copy or FTP the file in.
How can I tell how it's really connected?
Thanks

TCP Listener / Proxy in C#

I have several machines running an application that plays a video feed from a camera. Each machine is located behind a firewall on different LANs. I am trying to investigate an approach to be able to talk to these machines from an Azure web app and get access to the video they are streaming. I don't want to have to open ports on any LAN. My first attempt at this was to have a client running on each machine that contacts an intermediate Azure service via a TCP port, the port is kept open and the local machine sends data to the Azure service which basically downloads this data and then sends it on to any connected clients.
The problem I am having is the intermediate service essentially has to download each message and then retransmit it to any clients, I don't think this approach will scale as the intermediate server can become overrun very easily. Ideally all I would like the intermediate service to do is manage the connections between the local machines and the end client azure service so that they talk directly to one and other.
I guess this must be similar to what products like TeamViewer or LogMeIn do.
I'd appreciate any pointers or suggestions from others experience.

Is it possible to check who is connected to your wireless network?

So after hours of research i have found nothing about this question.
Is it possible to see who is connected to my wireless network using C#?
Example: I have 2 Laptops - Laptop A and Laptop B.
A is on running my program I made and
connected to my wireless network.
B is starting up and connects to my wireless network. A can now see that B is connected to the wireless network through the program I made.
Is this possible?
Is it possible to see whos connected to my wireless network using C#?
Option 1) depends on what your wireless connection device is (supposing a router or access point) and how programmable it is. For instance, if you have a Linksys WRT54GL, you could load DD-WRT or another OSS firmware and write your own modules to monitor this behavior. Programming that module in C# would require loading the mono libraries into the DD-WRT install.
Option 2) install a "heartbeat monitor" on each machine that could connect to the wireless network. Once the connection to that gateway has been made, the daemon tells other monitors that it is now connected to the network.
Option 1 is best if you have no control over what devices connect. Option 2 is best if you can control what devices connect.
In theory, yes - if your wireless router exposes an API that you can hook into to get the list of currently connected clients, then it's likely that you can write something in C# that will poll the API for changes.
Practically speaking, I'm not aware of any wireless router that actually does what I proposed above. Then again, I've never really looked into it so who knows!

.Net Remoting not working in Windows 7

We have a server application (developed using .Net 1.1, C#) which listen the port 8086 and the client application, before starting will handshake with this server using remoting.
The application is working fine in almost all environments - Windows 2000/2003/2008/XP/Vista.
Now we are facing an issue with Windows 7.
When we are staring the server, it’s opening the port and will be listening to clients, but when try to send a request from a client who is running in other OS, it gives a message that server is not running.
We disabled the proxy, gave the exceptions for proxy but all went in vain. On further analysis we found that the system is having multiple connectivity (LAN, Bluetooth &WIFI).
When we checked the TCP port using netstat –a it showed the Local Address as 0.0.0.0:8086. So we disabled/removed the Bluetooth & WiFi option and tried again then also netstat is showing LocalAddress 0.0.0.0:8086.
How to go ahead in this situation?
Thanks in advance.
Do a network capture using Microsoft Network Monitor or Wireshark to better understand the underlying TCP/IP packets. That can show what's up easily.

Categories

Resources