The Netduino forums have been replaced by new forums at community.wildernesslabs.co.
This site has been preserved for archival purposes only
and the ability to make new accounts or posts has been turned off.
Thank you very much for you reply. You nailed it, it was the MAC Address being reserved in the router (see snapshot below), even thoght I was changing the Static IP address on the N+2 using MFDeploy Network Configuration to something else than 3.2.72.20, seems like the router was blocking the traffic the second time around coming from the same MAC address withing a different IP address.
Man, I spent so much time on this issue, what a relief!!!
I have a program that runs on my N+2 and captures temperature and humidity values, then it pushes those values to COSM (formaly known as Pachube). Most of the time a experiment an issue where the N+2 freezes on the HttpWebRequest.GetRequestStream() and just sits there forever on that line of code. Then even if I reset the N+2 and re-run the program again freezes on the same line of code. So, what I have to do is open MFDeploy -> Network Configuration and change its Static IP addres to something that is available in my network, so no other devices in my network are using that IP address. Then the N+2 starts pushing data to COSM once again and no problems. Then if for some reason I stop the program and re-run it, the N+2 hangs again on the same line of code. It seems like the IP gets blocked or something and cannot be used anymore. Then I go the the N+2 static IP address to other available IP addres, different than the 2 previous used IPs and the N+2 HttpWebRequest.GetRequestStream() works again. It's like the N+2 or my router remembers the last IPs being used and don't allow traffic to go thru, either that or COSM is rejecting it and making it hang, which I doubt.
I already set a timeout for the HttpWebRequest.GetRequestStream but doesn't help at all, it just freezes.
So, what could be happening? Is my router not allowing the traffic to go thru?
Attached is the code I am using to push code to COSM.
Thanks for providing your class, I really like your approach.
The program works fine the first time around, if I stop the debugging or restart the N+2 without debugging, either way, then the the program hangs on the line of code below:
serversocket.Connect(remoteEndPoint);
Then the only solution to get it to work again is to go to MFDeploy and change the N+2 Static IP address to something else available in the network, then starts working once again but I stop and re-run, then it freezes on the same line of code.
Any clues what is going on? I am suspecting that my router is doing something to block the traffic but can't confirm and if that the case then the program should timeout. Should I use sniffer or fiddler as proxy and see if the traffic is going thru?
Like to OP I think that if my code runs to completion then the following execution is OK; however when I terminate my code or it crashes then subsequent executions may hang on the following line.
Response = request.GetResponse();
Setting request.ReadWriteTimeout seems to improve this dramatically. The default is 300000 which (assuming mS) is 5 minutes.
Try the following experiment
Note the time
Start Code – terminate after GetResponse is called but before a normal complete
Start code a second time – check it hangs on GetResponse
Wait until 5 minutes have elapsed from the time in 1)
Start code a third time to see if it hangs
I'm wondering if because the previous request hasn't yet been completed (disposed, closed etc.) then subsequent requests get queued and you are waiting for the first one to complete or timeout.
I changed my code to set the ReadWriteTimeout to 2000 (not sure if this is too aggressive)
I would give dbradshaw's (Dave) suggestion a try. It could be a timeout issue but could be caused by hardware (router, Modem). Timeout could be a quick fix.
Interesting and thanks to both for their replies. I've been playing with the timeouts for all the parameters but they didn't help I remember but since I am getting old and I don't remember things that I've done lately I am going to try dbradshaw suggestion and I'll keep you both posted.
Hi Giuliano,
With the static IP... If you reboot your Netduino Plus 2 and it still can't connect (without changing the IP address), then it's most likely a router issue. Try restarting the router...and see if the issue clears up.
Also...do you have the static IP reserved for your Netduino Plus 2's MAC address on the router?
There are DDoS protections built into some routers...so it's possible that the traffic is triggering an automatic port block.
Chris
I tried your code and it hangs on the second call in this line of code:
Response = request.GetResponse();
I can let it run for 15 minutes or even more but the program sits on that line of code. Then if I change the Static IP addres on the N+2 to something else other than previous used IP that line of code works until the program is stop. A re-run with the same Static IP address wil cause the program to hang on the same line of code once again.
Thank you very much for you reply. You nailed it, it was the MAC Address being reserved in the router (see snapshot below), even thoght I was changing the Static IP address on the N+2 using MFDeploy Network Configuration to something else than 3.2.72.20, seems like the router was blocking the traffic the second time around coming from the same MAC address withing a different IP address.
Man, I spent so much time on this issue, what a relief!!!
Wow, that's strange. What type of router do you have? What your saying is that effectively you can use every IP address only once until router reboot? I assume this is the ARP cache and it's supposed to 're-register' a device every time it connects and periodically, see here ARP Cache - What is it?
So is this a result of no/bad broadcast support in the lwip stack (i.e., not registering as dynamic) or something else? If you take one of your other connected devices that are using a fixed IP address (Apple TV or Samsung printer in your example) does it also have the same problem?
Hi emg, I have an old Dlink DIR-655. I know it is time for me to upgrade but this router has been working rock solid for over years and I hate to spend the money when it is not really needed. That said, I will conduct some testing as you suggested and I'll keep you posted of my findings.
I tried to reserved the MAC addresses of most of my devices at home (even though my router only allows to reserve 25 MAC addresses at the most), so they always get the same IP address assigned, that way I know for sure they will remain in that IP address and I can do port forwarding and those kind of things. I do not go to every device and set an static IP address for them, the router takes care of that but in the N+2 situation, you have to either use DHCP or choose an IP address.
in order to be able to conduct a test with one of the other devices in my network, I would have to go to their settings and change it to use a Static IP Addres, e.g.: Change Apple TV in 3.2.72.23 to have static IP address as 3.2.72.105 for example without changing the reserverd MAC Address in the router which will still be pointing to 3.2.72.23, then see if it works after booting it up a few times.
As I am writing this I realize I can leave the MAC Address in the router reserverd MAC Addresses and just select DHCP in the N+2 Network Configuration, that way the N+2 will always get the 3.2.72.20. So I am going to try this later and I'll post the results here.
I went back to my router and reserved the MAC address for my N+2 to always be adquired in ip address 3.2.72.20 and then I changed its Network Configuration using MFDeploy to be DHCP (checkbox checked) and no problems anymore, works like a charm. So either this way or by deleting it from the router reserved MAC address and then using a Static IP in the N+2 as 3.2.72.20 works just fine.
Thanks, for the update. That looks like the better option for you (set device to DHCP and reserve it at the DHCP server). It is still unusual that the netduino that changes its static IP address does not signal the change to your router and you have to manually clear the ARP cache. This should happen by OSI model design.