Ethernet fails connecting after a while

The EtherTen combines an Uno-equivalent Arduino-compatible board and Wiznet-based Ethernet support, along with a microSD card slot and Power-over-Ethernet support. [Product page]
harpo875
Posts: 1
Joined: Sun Sep 09, 2012 4:50 pm

Re: Ethernet fails connecting after a while

Post by harpo875 » Sun Sep 09, 2012 4:56 pm

I was having the same problem. I'm running a web server on the arduino/ethernet shield. A remote program hits the web server every 15 minutes. I could not get it to run for 24 hours without locking up. You could ping the arduino, but the web server didn't answer. I stumbled across the fix while I was rearranging the jungle of cables on my router. I moved the ethernet cable for the arduino from a gigabit hub to the router itself (10/100). Hasn't locked up since. Six days up so far.

EpicTinker
Posts: 9
Joined: Thu Nov 03, 2011 4:36 pm

Re: Ethernet fails connecting after a while

Post by EpicTinker » Mon Sep 10, 2012 3:38 am

Very interesting. What brand is your hub and router? I have a few EtherTens on Netgear gig switches and they seem to be working fine for the last 9 months or so. Since the W5100 chip only supports 10/100, it shouldnt make a difference if it was on a gig switch since it will negotiate down to 10 or 100mbits.

SkullKill
Posts: 3
Joined: Sun Oct 28, 2012 6:26 am
Location: Perth, WA, Australia

Re: Ethernet fails connecting after a while

Post by SkullKill » Sun Oct 28, 2012 7:28 am

Hi guys, i had a similar issue with the board freezing, and just wanted to add my feedback on what fixed it, (at least if someone google, they can get the information).

summary : removing the MicroSD card from the board fixed it. or bring Pin 4 to HIGH to disable SD card.

Detail info:
my code was written for a Freetronics EtherMega board, with the ATmega2560, Wiznet W5100 chip, and micro sd card slot.

my code is basically doing a webserver interface that pools the status of some variable and prints it in an HTML format. (i am not using the SDcard for anything)

the program will not crash at all if nothing was accessing the Network interface.
but once i try to access the webinterface, it works a few times, then after a few refresh (could be the 2nd time, or it cound be the 20th time). it will output "junk" (a lot of it, most of the junk is just a repeat of the status message itself in a random order) and the board will freeze. at this point i have to reset the board to make it work again.

while doing some troubleshooting, i wrote a much simpler code to just output text in my web browser. It was still freezing, but to my surprise , the "junk" was some of the output message of my previous code!!!!!!!!!!!!!.

did some research, and found that if i am not using the SD card, i need to explicitly disable it. p.s also read that if the SD library was in uses, it would have handle the pin mode.

Code: Select all

  pinMode(53, OUTPUT);                       // set the SS pin as an output (necessary!)
  digitalWrite(53, LOW);                    // ? (not sure)
  pinMode(4, OUTPUT);						// SD select pin
  digitalWrite(4, HIGH);					// Explicitly disable SD
  pinMode(10, OUTPUT);						// Ethernet select pin
  digitalWrite(10, LOW);					// Explicitly enable Network
from http://arduino.cc/en/Main/ArduinoEthernetShield
Arduino communicates with both the W5100 and SD card using the SPI bus (through the ICSP header). This is on digital pins 11, 12, and 13 on the Duemilanove and pins 50, 51, and 52 on the Mega. On both boards, pin 10 is used to select the W5100 and pin 4 for the SD card. These pins cannot be used for general i/o. On the Mega, the hardware SS pin, 53, is not used to select either the W5100 or the SD card, but it must be kept as an output or the SPI interface won't work.
Note that because the W5100 and SD card share the SPI bus, only one can be active at a time. If you are using both peripherals in your program, this should be taken care of by the corresponding libraries. If you're not using one of the peripherals in your program, however, you'll need to explicitly deselect it. To do this with the SD card, set pin 4 as an output and write a high to it. For the W5100, set digital pin 10 as a high output.

P.K.Tonkes
Posts: 1
Joined: Mon Nov 26, 2012 10:58 pm

Re: Ethernet fails connecting after a while

Post by P.K.Tonkes » Mon Nov 26, 2012 11:15 pm

We are using the WizNet & Arduino in our domotica-project http://www.nodo-domotica.nl. We encounter the same problem. After several minutes to several hours, the Arduino code keeps running but Client.connect() fails every time. I have read this threat but could not found the solution.

I think there is a relationship between this problem and opening ports on my router.

You can find te code on:
https://code.google.com/p/arduino-nodo/ ... cation.ino

@Sleurhutje: Zou jij wellicht contact met mij kunnen opnemen om eens van gadachten te wisseln om dit project te tackelen?

Paul.

p.k.tonkes@gmail.com

Sleurhutje
Posts: 28
Joined: Thu Mar 01, 2012 9:18 am

Re: Ethernet fails connecting after a while

Post by Sleurhutje » Wed Jan 30, 2013 11:59 am

@Paul: Reading your message now, sorry for the delay. I've switched to the Raspberry Pi. Much more programming space, ability to use background tools/apps since it's Linux based and more stable on long term usage.

bubulindo
Posts: 1
Joined: Wed Mar 27, 2013 5:32 pm

Re: Ethernet fails connecting after a while

Post by bubulindo » Wed Mar 27, 2013 5:38 pm

Hello,

After having the same issue you guys are reporting, I followed your tips to see if I can get my application working and found myself stuck in a different place than reported here and am hoping to get some help towards fixing this issue or at least get an understanding of what is happening.

I did as you guys mentioned and changed the return values of the EthernetClient.cpp connect function and mine is getting stuck here:

EthernetClient.cpp, line 39

Code: Select all

  if (_sock != MAX_SOCK_NUM)
    return -10; //was 0, troubleshooting
As I see it, when creating the client, the only number that is accepted for a socket is 4. What is strange as the EthernetClient constructor accepts a socket number, or so is what I read from it.

Does any of you have any idea why this piece of code is here and why is it here?

richsp51
Posts: 1
Joined: Mon Apr 01, 2013 3:11 pm

Re: Ethernet fails connecting after a while

Post by richsp51 » Mon Apr 01, 2013 3:24 pm

Hello, any updates on this subject? I am having a similar problem using my Mega2560 as a webserver. It runs for anywhere for 10 hours to 2 days and then fails client connect. The server code continues to run, but client connect fails.
One observation I have that I did not read in other posts, is that I do NOT have to reset the Wiznet based shield or the Mega, but ONLY need to unplug the ethernet cable from the shield and plug it back in. Then, everything continues to run.
Have any others observed this?
I've tried most of the "tricks" outlined in this post, but have messed with EthernetClient.cpp

I'm running Mega2560, Arduino IDE 1.0.4, Wiznet W5100 based shield.

Thanks,
Rich

angusgr
Freetronics Staff
Freetronics Staff
Posts: 853
Joined: Tue Apr 09, 2013 11:19 pm
Location: Melbourne, Australia
Contact:

Re: Ethernet fails connecting after a while

Post by angusgr » Fri Apr 12, 2013 5:51 am

bubulindo wrote:

Code: Select all

  if (_sock != MAX_SOCK_NUM)
    return -10; //was 0, troubleshooting
As I see it, when creating the client, the only number that is accepted for a socket is 4. What is strange as the EthernetClient constructor accepts a socket number, or so is what I read from it.

Does any of you have any idea why this piece of code is here and why is it here?
In this instance, the value MAX_SOCK_NUM, or 4, is used as a placeholder for "I'm not using any socket". The valid socket numbers being 0-3 (W5100 can only maintain 4 sockets at once.)

If connect() is returning from that first check, it means you are calling connect() on an in-use EthernetClient that you haven't already called stop() on. So _sock is already assigned to a socket in the range 0-3! If you look at the bottom of the stop() function, you'll see that after it closes the socket it reassigns the _sock field back to MAX_SOCK_NUM, meaning the whole object is then free for reuse in a new connection.

- Angus

angusgr
Freetronics Staff
Freetronics Staff
Posts: 853
Joined: Tue Apr 09, 2013 11:19 pm
Location: Melbourne, Australia
Contact:

Re: Ethernet fails connecting after a while

Post by angusgr » Fri Apr 12, 2013 5:54 am

richsp51 wrote: One observation I have that I did not read in other posts, is that I do NOT have to reset the Wiznet based shield or the Mega, but ONLY need to unplug the ethernet cable from the shield and plug it back in. Then, everything continues to run.
Have any others observed this?
Weird. I haven't seen this, but it makes me think that you're hitting a hardware bug in the W5100 itself rather than the Arduino library or your sketch. Or possibly even something between the W5100 and the network switch. AFAIK the Arduino Ethernet library will never notice if the cable is unplugged and replugged.

Can you still ping the EtherMega when it gets in this state?

If it is a hardware bug, would you work around it, perhaps with some kind of watchdog behaviour in your sketch? Something like, if you haven't seen a new incoming connection in X minutes then reset?

- Angus

caramell
Posts: 1
Joined: Wed Jun 19, 2013 10:14 am

Re: Ethernet fails connecting after a while

Post by caramell » Wed Jun 19, 2013 10:25 am

Hi everybody,
Sleurhutje said in April 2012
When you receive a valid IP-address you can PING your interface using both IP-address and host name. E.g. is your MAC address is like 0x01,0x3a,0xf8,0xb1,0x41,0x30 the host name would be like "WIZ▒A0". That's not a valid host name! It might cause problems on networks. So the easiest way is to use what they call printable characters.
, and as I am recently using networks tools I'm not really sure of knowing what a "printable character" means. :?

Could you please precise what you meant or what you think it meant in this case. Is it only concerning letters and punctuation?

Thank you very much for your answers :)

Post Reply

Who is online

Users browsing this forum: Google [Bot] and 3 guests