Netduino home hardware projects downloads community

Jump to content


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.
Photo

Crash on network socket unplug


  • Please log in to reply
9 replies to this topic

#1 phil

phil

    Member

  • Members
  • PipPip
  • 11 posts

Posted 28 September 2011 - 08:25 AM

Does anyone has any idea why a Netduino plus crashes out if the network cable is removed and then plugged back in?

In simple terms, my app is:

void Main()
{
  try
  {
     while (!button pressed);

     Connect to tcp server
     send message to tcp server
     poll for response
  }
  catch (Exception)
  {
     Print error
  }
}

Now, if I stop the tcp server and press the button, no sweat - the catch triggers on the send failure and then eventually
recovers when the server is restarted.

But if I pull the network cable it bombs right out .. no exception. I know it's dead as I have a threading.timer running flashing the LED each second. It just dies when the network cable is out and I press that button... Tracing the code, it seems to die at a Socket.Connect call.

I can't see any obvious way to detect if the cable is in .. if there was a way to do that I could avoid the connect call.

This is firmware 4.1.0.6

Big problem for me. I wanted to use the netduino pluses in a production environment but if they can't survive a cable pull or switch reset, then they're no good to me.

#2 erich

erich

    Member

  • Members
  • PipPip
  • 21 posts
  • LocationFrance

Posted 28 September 2011 - 08:47 AM

Hi Phil, I haven't seen your issue, mainly because I have get Socket.Connect() hanging problem (My Sockets are using http or udp). We too wanted to use Netduino in a production environment, but this another issues mainly memory related mean we are having to consider our options. Netduino Plus is a nice platform - very compact, lots of features, interesting price But................

#3 phil

phil

    Member

  • Members
  • PipPip
  • 11 posts

Posted 28 September 2011 - 10:41 AM

It would be a lot easier if there was a simple way to get at whatever is being used by the NetworkChange class to detect a change in the network availability. I can use that to prevent attempting to connect if the network cable is pulled out *after* the program starts, but not to detect if it is not up *when* the program starts. There is a nice pin (14) that would be perfect on the Ethernet PHY that's not connected to anything. I'd love to know why that decision was made given that there are plenty of free pins on the CPU. I'm getting a little frustrated. I could use mBeds but they're such a pain, having to use IP stacks of unknown quality written by 3rd party developers.

#4 Ricco

Ricco

    New Member

  • Members
  • Pip
  • 3 posts

Posted 28 September 2011 - 08:50 PM

I chose to change my arduinos with netduinos to add ethernet to my projects. If thought multi-thread can avoid hangs caused by network delay. I was desapointed when I saw my netduino hangs when I unplugged the cable... I hoped that the netduino hang until the connect timeout raise. I didn't have the time to test it and I really need my input interruption been catch even when I try to send networks request so I let it untouched. In the test of the first post, is the catching of the exception still in the main loop ? It seems that Secret Labs is confident about resolving the issue in the next 4.2 firmware, so it may not be an hardware problem. We just have to wait ... RC3 is annonced in few days (weeks ?)

#5 phil

phil

    Member

  • Members
  • PipPip
  • 11 posts

Posted 28 September 2011 - 11:28 PM

I chose to change my arduinos with netduinos to add ethernet to my projects. If thought multi-thread can avoid hangs caused by network delay. I was desapointed when I saw my netduino hangs when I unplugged the cable...

I hoped that the netduino hang until the connect timeout raise. I didn't have the time to test it and I really need my input interruption been catch even when I try to send networks request so I let it untouched.

In the test of the first post, is the catching of the exception still in the main loop ?

It seems that Secret Labs is confident about resolving the issue in the next 4.2 firmware, so it may not be an hardware problem. We just have to wait ... RC3 is annonced in few days (weeks ?)


Thanks, Ricco. So, this is a known issue? I've been trying to find info in the forums about betas, etc, but it's really hard to dig through.

This is only an issue where the cable is unplugged when the device is powered on. If the cable is plugged in when it is powered up, you can add some code like this:

static bool networkAvailable = true;

void main()
{
   NetworkChange.NetworkAvailabilityChanged += 
      new NetworkAvailabilityChangedEventHandler(NetworkChange_NetworkAvailabilityChanged);
   while (true)
   { 
      while(!detect_Event());
      if (networkAvailable)
      {
         using (socket = ConnectToServer())
         {
            SendMessage();
            DoOtherStuff();
         }
      }
   }
}

static void NetworkChange_NetworkAvailabilityChanged(object sender, NetworkAvailabilityEventArgs e)
{
    Debug.Print("Network Availability Changed : IsAvailable = " + e.IsAvailable.ToString());
    networkAvailable = e.IsAvailable;
}


#6 Ricco

Ricco

    New Member

  • Members
  • Pip
  • 3 posts

Posted 30 September 2011 - 08:02 PM

I'm just refering to this post http://forums.netdui...dpost__p__18475 Thx for your code. I think my events could be really frequent, and even a 10 sec hang is way too much. I'm waiting for another firmware in which the connection process could be independant of the event detection, if it is possible.

#7 javast

javast

    New Member

  • Members
  • Pip
  • 3 posts

Posted 06 August 2012 - 10:11 PM

Hi, this is not working for me. I'm using 4.2 RC5 and the event about network up/down is not propageted. Anybody using RC5 too? thanks jan

#8 phil

phil

    Member

  • Members
  • PipPip
  • 11 posts

Posted 07 August 2012 - 05:41 AM

Hi,
this is not working for me. I'm using 4.2 RC5 and the event about network up/down is not propageted. Anybody using RC5 too?
thanks
jan


Sorry, I can't help you. I gave up after a rude personal email from Chris. I literally threw all the netduinos my company used in the garbage bin and replaced them with devices from GHI, and use those plus custom hardware exclusively now. That's the only recommendation I can make, but someone else may have found fixes in the 4.2 RCs.

#9 Stefan

Stefan

    Moderator

  • Members
  • PipPipPip
  • 1965 posts
  • LocationBreda, the Netherlands

Posted 07 August 2012 - 06:01 AM

Hi,
this is not working for me. I'm using 4.2 RC5 and the event about network up/down is not propageted. Anybody using RC5 too?
thanks
jan

Hi,

The network detection is still a bit bugged in RC5. Remember 4.2 is not yet RTM for the Netduino and Netduino Plus. I believe this is one of the things that's beeing fixed as we speak.
"Fact that I'm a moderator doesn't make me an expert in things." Stefan, the eternal newb!
My .NETMF projects: .NETMF Toolbox / Gadgeteer Light / Some PCB designs

#10 epasquier

epasquier

    New Member

  • Members
  • Pip
  • 1 posts

Posted 08 May 2013 - 08:14 PM

Hi, I am using the MicroFrameworkSDK_NETMF42_QFE2 version with Netduino Plus 1, and I have the same behavior, i.e. works only when the ethernet cable is connected when the application is started.

 

Any information about this problem ?

I would like to avoid to reboot the application when the cable is connected ...

 

Tks,

Eric.






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.