Main Site Documentation

Network socket connection hangs on G120HDR 2.0 with ENC28 1.1


#1

Hi all,
I’m using a G120HDR board with ENC28 1.1 module and as a part of my project I try to implement a simple webserver. Unfortunately it does not become stable.

History:
First I tried several codeshare examples based on the HttpListener. The code every time works fine for a while and then hangs. I debugged and evaluate and found out, that the line “HttpListenerContext context = listener.GetContext();” stops after a random time (sometimes after some days) giving any result. I tried several suggestions from here and reinitialized everything step by step (listener the network) but nothing solved this issue.

To exclude side effects by all the other code, I already reduced the code to the webserver only, but still the same effect.

Then I lost trust in the HttpListener implementation (sorry) and decided to implement a simple socket based webserver instead. I disconnected the USB cable from the device and did a reset. It seemed to be stable, but after some days the webserver was not reachable anymore again.

I reconnected the USB and started debugging by attaching to the NETMF device.

Because in an interval I try to get NTP time via sockets, I get the event:

[quote] #### Exception System.Net.Sockets.SocketException - CLR_E_FAIL (4) ####
#### Message:
#### Microsoft.SPOT.Net.SocketNative::getaddrinfo [IP: 0000] ####
#### System.Net.Dns::GetHostEntry [IP: 0008] ####
#### G120_Home.Network.NtpTime::GetTime [IP: 000a] ####
#### G120_Home.Network.NtpTime::GetTime [IP: 001a] ####
#### G120_Home.Network.NtpTime::RefreshThread [IP: 0038] ####
#### SocketException ErrorCode = 10060
#### SocketException ErrorCode = 10060
#### SocketException ErrorCode = 10060
#### Exception System.NullReferenceException - CLR_E_NULL_REFERENCE (4) ####
#### Message:
#### G120_Home.Network.NtpTime::GetTime [IP: 0135] ####
#### G120_Home.Network.NtpTime::GetTime [IP: 001a] ####
#### G120_Home.Network.NtpTime::RefreshThread [IP: 0038] ####[/quote]

Disconnecting and connecting the Ethernet cable didn’t solve the problem. And then I tried something the first time and was absolutely surprised: I disconnected the ENC28 gadgeteer cable from the G120HDR board and reconnected it. Afterwards NTP time was received and the webserver was reachable again.

Now I need professional help to find the bug. I would guess, that the ENC28 board is defect but maybe there are other known reasons or experiences and I would be happy to hear about.

Additionally I found this post: “Resetting ENC28 network module after IP stack failure” and ask myself, whether the TCP/IP stack is unstable und if I will use it, what the indicator is to reinitialize the whole network interface. And it would be a workaround anyway and sounds dirty. If e.g. it is a known not solved problem for G120/ENC28 and solved for other modules, I would prefere to change the hardware. Is that an option? (I investigated already so much time, that it would be easier to switch)

I use Panda II as well in other projects with network connections and its running fine since many months. So it a challenge to get the G102 as stable as its small brother.

Thanks for support!


#2

Hi andre.m,
Thank you for your reply, but the error code is well known ;). The question is, why it happens (see my first post). The timeout is only the effect we can see and not the reason.

For me it is not obvious why the ENC28 loses the connection randomly. Because reconnecting the ENC28 to the G120 board helps, it doesn’t seem to be an Ethernet cable connection problem.