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]
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 Jun 21, 2013 3:25 am

caramell wrote: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?
Hi Caramell,

In this case printable characters means "ASCII" printable characters, which is any letters, punctuation and some "standard" symbols like the ones you can type on a US English keyboard.

There's a full list on the Wikipedia page for ASCII here: https://en.wikipedia.org/wiki/ASCII#ASC ... characters

If you look at the table, you'll see each "glyph" (aka character) in the ASCII printable character set corresponds with a number between 32 (hexadecimal 0x20) and 126 (hexadecimal 0x7E). Sleurhutje's post is showing that if you use the MAC address (a sequence of numbers) to generate the host name by using each number as a character in the name, it's possible some of them will be from outside the printable range, so you get something unexpected (and maybe unusable) as the host name.

- Angus

scotto
Posts: 1
Joined: Sat Jan 25, 2014 5:05 am

Re: Ethernet fails connecting after a while

Post by scotto » Sat Jan 25, 2014 5:37 am

I'm having a similar problem that appears to be that data requested by 2 incoming sockets is replied back on a single socket.

I have an etherten with DHT22 which is polled by Zabbix every 15 seconds [poll time has been varied 5 to 30 seconds with no change in the problem].

The zabbix server polls separately for temp and humidity data [using the zabbix.agent item type], and the etherten replies with a numeric reply of format nn.nn. This can work for some time but fails after zabbix receives a response which is is a combination of both temperature and humidity. Zabbix is configured to accept a numeric response and reports the error data as and an illegal value, and then backs off polling for the particular data for a period of time. Mean whilst zabbix will continue polling for the remaining 'good' data as well as sending remote commands to the etherten [see below about remote commands].

I have trapped the data exchange with wireshark and it is clear that the reply contains both values in the data payload.

The main loop and command parsing is below:


void loop()
{
client = server.available();
if (client == true)
{
if (!connected)
{
client.flush();
connected = true;
delay(100);
}

if (client.available() > 0)
{
readTelnetCommand(client.read());
}
}
}
//--------------------------------------------
void readTelnetCommand(char c)
{

cmd += c;

if (c == '\n')
{
if (cmd.length() > 2)
{
// remove \r and \n from the string
cmd = cmd.substring(0,cmd.length() - 1);
if (debug)
Serial.println(cmd);
parseCommand();
}
}
}
//--------------------------------------------
void parseCommand() { //Commands recieved by agent on port 10050 parsing


// AGENT ping
if (cmd.equals("agent.ping"))
{
server.println("1");
client.stop();
delay(100);
}

// AGENT version
else if (cmd.equals("agent.version"))
{
server.println("ArduinZabbixVini.1.0");
client.stop();
delay(50);
}
// AGENT sensor2
else if (cmd.equals("temperature.read"))
{
t = dht.readTemperature();
server.println(t );
if (debug)
{
Serial.print("Temperature: ");
Serial.println(t );
}
client.stop();
delay(50);
}
// AGENT sensor1
else if (cmd.equals("humidity.read"))
{
h = dht.readHumidity();
server.println(h );
if (debug)
{
Serial.print("Humidity: ");
Serial.println(h );
}
client.stop();
delay(50);


Interestingly enough the etherten/wiznet doesn't hang but continues and receives remote commands from the zabbix server. For example a zabbix server trigger detects the lack of temperature data from the etherten and sends a remote command to the etherten which is parsed and sets of a local alarm, similarly another trigger detects over temperature and sends a remote temp.alarm command to the etherten.

Arduino 1.05 IDE and Ethernet2 library which has the the most recent proposed fix applied SnSR::CLOSE to EthernetClient.cpp

What I see on the analyser is that the reply data for humidity and temperature requests [which arrive on separate sockets] are sent back on a single socket.

Rudolphus
Posts: 1
Joined: Fri Apr 29, 2016 9:19 am

Re: Ethernet fails connecting after a while

Post by Rudolphus » Sat Apr 30, 2016 8:50 pm

hello,

is there anyone who solvled this problem. i have the same but have no solution.

JanHalsey
Posts: 1
Joined: Thu Jun 09, 2016 4:19 pm

Re: Ethernet fails connecting after a while

Post by JanHalsey » Thu Jun 09, 2016 5:13 pm

Hi everyone....i am new to this forum. Actually i think I've debugged it to the point where it appears the Wiznet 5100 leaves connections in the CLOSE_WAIT state, even though you called disconnect and there aren't any available bytes on the connection. I'm not 100% sure if that's a bug in the Ethernet Arduino library, or on Wiznet. I'm still working on understanding the Ethernet code enough to be able to confirm further. But when using EthernetClient I have the code change below in the connect method.

pcb turnkey china

jakejeon
Posts: 1
Joined: Tue Nov 08, 2016 8:54 am

Re: Ethernet fails connecting after a while

Post by jakejeon » Tue Nov 08, 2016 11:10 am

Sleurhutje wrote:@mr-russ: You're my hero. :ugeek:

Added the SnSR::CLOSE_WAIT to the EthernetClient.cpp (in Arduino 1.0 Ethernet Library line 44) and the EtherTen is running fine for a continuous 72 hours. Normally it would crash within 24 hours. Even in a high latency network no connection failures. Sometime the wait state takes up 60 seconds but all keeps going on without crashing.
I guess the current version(1.6.12) of Arduino IDE already includes this modification.
however, my Arduino is still hanging for other reason.

sofiakerry
Posts: 1
Joined: Sat Jul 15, 2017 5:08 am
Contact:

Re: Ethernet fails connecting after a while

Post by sofiakerry » Sat Jul 15, 2017 5:23 am

There are a few tutorials on youtube for connecting ethernet with codes. I think you should search them and watch. Hope you will get the best solution you want.

CCcam

Post Reply

Who is online

Users browsing this forum: Baidu [Spider] and 1 guest