Is there a way in the Windows Phone 7 emulator to turn off the network connection (without yanking the cable and turning wi-fi off on my laptop)? I want to test the dropping of network connectivity without having a physical device or doing anything physical outside the emulator or the Windows Phone 7 SDK/Tools.
As an alternative to physically disabling the network connection I also, sometimes, find it useful to redirect the network connections through Fiddler2. It's then possible to use breakpoints to intercept some connections. You can then use this add a delay before the server can respond. Or you can force a timeout.
I find this a useful approach when you want to test some connections failing but not others.
No, not really. I find it useful to check network connectivity and assign the result to a boolean value so that I can then modify the result to test scenarios where there's no network connection.
Сreate a firewall rule for the application C:\Program Files\Microsoft XDE\1.0\XDE.exe and then enable/disable this rule.
You can do this using a custom rule in Fiddler.
Rules -> Customize Rules...
Find the code which adds the "Simulate &Modem Speeds" menu option, and add your new option
//Add a menu option under Rules -> Performance
public static RulesOption("Simulate Flight Mode", "Per&formance")
var bFlightMode: boolean = false;
Now, at the top of the OnBeforeRequest function, add the following code
// Cause Fiddler to respond to all requests with a 502 (Bad Gateway) - the same error you get when you remove all networks
if (bFlightMode){
oSession.oRequest.pipeClient.End();
oSession.utilCreateResponseAndBypassServer();
oSession.oResponse.headers.HTTPResponseCode = 502;
oSession.oResponse.headers.HTTPResponseStatus = "Fiddler Simulating Flight Mode";
oSession.state = SessionStates.Aborted;
return;
}
Now, under the 'Performance' menu, you can select 'Flight Mode' - or whatever you want to call it.
(Based on an #EricLaw Google Groups post)
Related
I want to block a program from accessing the local server "local host" (On windows) temporary so i can test random disconnections cases ... I tried adding a (rule) to the firewall for disabling both inbound and outbound in all networks types but the program just got block from accessing the internet not the local network
Moving on to an answer instead of a comment - nevertheless, more information on your use-case is greatly appreciated;
I think it is impossible to block access to localhost but allow internet access. Two reasons:
Networking works on different layers ("OSI layers") and localhost communication is looped back before firewall might filter (see ). Not so sure on this though.
localhost communication might be "basic" in a way that it is necessary for applications when they want to communicate via network.
UPDATE after OPs comment
I assume you are on Windows 10, and you know the path to the executable of the program you want to block.
Open "Windows Defender Firewall with Advanced Security".
On the left side, go to "Outbound Rules".
Then, on the right side click on "New Rule...".
A new window will open; Leave "Program" selected and click "Next".
Next to "This program path:" is a Button "Browse..." - select your program here. Click "Next..."
Select "Block the connection", then "Next...".
Select all three; Domain, Private and Public.
After click "Next..." choose an appropriate name, then click "Finish".
From now on, you can disable/enable this rule as you see fit.
Kinda hard to provide detailed answer having only the information you've provided, but I think this scenario can be easily tested with simple containers configuration: having both program under test and "localhost" service running in containers, you can randomly update container's network configuration to simulate connectivity issues.
You can use a reverse proxy like Fiddler and block all requests coming from this application to localhost.
If I understood what you mean then this will do:
To create a rule, select the Inbound Rules or Outbound Rules category at the left side of the window and click the Create Rule link on the right side. The Windows firewall offers four types of rules: Program – Block or allow a program. Port – Block or allow a port, port range, or protocol.
if you are using a third party anti-virus solution with a built-in firewall, go to the firewall option and black list/disable/prevent internet access to your app
Otherwise, disabling your firewall will not stop any access, as it will allow inbound and outbound traffic. you can prevent specific ports but disabling the firewall wall will not only do what mentioned before but it will also leave your device vulnerable for online threatts
Try these 3 simple steps.
run your program
Open cmd ( please check you need admin access for this, if yes then run as admin)
Run the following command to see at which port the localhost is listening.
netstat -ano | findstr :
e.g (if your localhost is listening at port 3900 the command will be as follow;
netstat -ano | findstr :3900
the result will be shown on cmd console, the last column is PID (Process id)
We will just kill that process which will eventually stop the localhost server to listen any request from any source.
taskkill /PID /F
< PID > that you will get from above command.
in this case, only the localhost will stop it's service, but you application will keep communicating to outer network, internet.
I am running a VPN in windows 10 desktop (using OpenVPN) and the VPN is the default gateway, so that all traffic by default goes through the VPN tunnel.
However, I would like to exempt certain apps from the VPN, so that their traffic goes directly out the physical interface instead, by passing the VPN (so-called "split tunnelling")
I assume this solution would involve the WFP (Windows Filtering Platform) API, and perhaps the Windows equivalent of
setsockopt(sock, SOL_SOCKET, SO_BINDTODEVICE, device, sizeof(device))
I have this working in Linux currently via "cgroups" and policy-based routing/multiple routing tables.
But it is my understanding that Windows has neither policy based routing or multiple routing tables. But i can still think of a way of achieving this in Windows, but I cannot find the APIs to make it happen
One way is to hook the socket creation of a specific app and then use the windows equivalent of SO_BINDTO_DEVICE socket option (setsockopt()) to force the socket to be bound to the physical interface rather than the tap driver.
But, again, I cannot find the relevant APIs to make the above happen.
So I have a few questions:
(1) Is what i want to do possible within the given APIs of WFP (Windows Filtering Platform) or Windows APIs in genral? if so, which APIs do you advise i look at?
(2) Or, must i write a "WFP call-out driver" ? If so, would you be able to point me towards some resources for this, and possibility a good starting point for my particular problem? :)
(3) Is there anything else I might be missing? a simpler approach to achieve what i want? I know that it is possible in windows, as i have see the feature in some VPNs, but i would like to replicate it in my own personal VPN :)
Yes, you can force an app to use your VPN connection by copying and editing your (Windows) VPN connection.
Open the run prompt with: WIN+R
Type: ncpa.cpl
Copy your "old VPN" to APP_VPN (for example)
Open a Normal user Powershell
Change the new VPN connection with:
Add-VpnConnectionTriggerApplication -Name "APP_VPN" –ApplicationID "C:\path-to-your\game.exe" -Force
# Enable (Application) split-tunneling
Set-VpnConnection -Name "APP_VPN" -SplitTunneling $True
You can also check the VPN settings details in the phonebook in:
C:\Users\<User>\AppData\Roaming\Microsoft\Network\Connections\Pbk
Done!
I have completed Google's form to enable my device to be whitelisted and have been provided with an AppID.
I have followed the procedures outlined here to try and debug the device with no success:
https://developers.google.com/cast/developing_your_receiver#debugging
I am able to ping my device by the IP, but connecting to port 9222 results in failure. Telnet to that port is also unsuccessful.
Does anyone know why this might not be working? I must be missing something simple.
The problem was that my Chromecast device was not sending the serial number to Google.
I was able to get it to work by enabling the sending of the devices serial number in the Windows settings utility (changing this setting in the android app didn't seem to work). After changing the setting I rebooted the device, and now I can connect on port 9222. I am not sure why this isn't in the developer walk through... or maybe I missed it?
I only got this option when I opened "Options" in the Google Cast Extension inside Chrome and then clicked on the blue icon about a dozen times very quickly. Suddenly a new option appeared at the bottom where I could enter the hostname of my whitelisted URL:
I also made sure that "send serial number" was enabled in the Chromecast.app (and make sure to reboot!)
Now, I am able to hit port 9222 in a browser and can see my app at http://{my-chromcast-ip}:9222/. I can use dev tools in Chrome to debug, refresh the page, inspect on-screen elements, etc.
Something else that I haven't seen others mention yet. If you're going to the right IP and getting the link to remote debugging, but you don't see your source, elements, etc. It could be blocked by security settings. This stumped me for a while until I noticed a small shield icon in my url bar. Click on this and allow it to load sources. Once I did that everything populated as expected.
I struggled a bit with this one. I think some things might have changed with the last firmware update on the Chromecast. I could connect to port 9222 after I did the following:
Registered the custom receiver and host it on the outside of my network (on Google Drive:
https://support.google.com/drive/answer/2881970?hl=en)
Launch the receiver. I used the Chromecast example https://github.com/googlecast/CastHelloText-chrome
Make sure the app ID in chromehellotext.html is the one registered on your account.
When After this, I could connect to the debugging port.
The port is only open when your custom receiver is running on the Chromecast.
I also might be useful to enable debugging on the chrome extension. This will show what's going on between the Chromecast and sender:
https://developers.google.com/cast/docs/chrome_sender
I realize that this is an ancient question, however my answer might help people searching in the future.
Simply rebooting the Chromecast after having set up my details in the Cast console helped for me.
You must cast to a custom receiver first (at least once) before trying to access the IP with debug port. Otherwise debugging won't be enabled.
why the NetworkInterface.GetIsNetworkAvailable() method always returns true,when i debug it on my windows phone 7 device?not emulator,is it sure that "NetworkInterface.NetworkInterfaceType==NetworkInterface.None" means a device does't get network access?how can i detect whether a device connected a network that has intenert access? i tried this link,Zune-Detection-and-Network-Awareness,but the NetworkInterface.GetIsNetworkAvailable() method always returns true,which stumbled me a lot.Thanks for your help.
Read the documentation for the method. Here is what MSDN has to say:
A network connection is considered to be available if any network
interface is marked "up" and is not a loopback or tunnel interface.
There are many cases in which a device or computer is not connected to
a useful network but is still considered available and
GetIsNetworkAvailable will return true. For example, if the device
running the application is connected to a wireless network that
requires a proxy, but the proxy is not set, GetIsNetworkAvailable will
return true. Another example of when GetIsNetworkAvailable will return
true is if the application is running on a computer that is connected
to a hub or router where the hub or router has lost the upstream
connection.
Generally, you could say that this method is generally prone to errors. I would recommend taking the approach of failed requests - have a couple of URLs to test against and check if HTTP/DNS resolve requests go through. If some of them pass - there is a connection. If all fail - chances are you are not connected.
Here is a sample.
So in the windows UI, if you right click on a network adapter you see a properties page that has a section labeled "This connection uses the following items"
and in this property page is a list of items with a check box beside them such as
Client for Microsoft Networks
Qos Packet Scheduler
IP Protocol Version 6
etc
I want to programatically get this list, and know whether that protocol is bound (the checkbox) is checked.
i can't seem to find any WMI class that shows this, and the closest i've seen is a primitive come interface INetCfg
Its not native PowerShell but there is a tool called nvsbind.exe that was written by someone on the hyper-v team so you can do these operations in Server Core.
You can find here
http://archive.msdn.microsoft.com/nvspbind