Wiznet / RP2040-HAT-MicroPython

54 stars 22 forks source link

Accept frequently fails with [Errno 107] ENOTCONN #7

Open harbaum opened 2 years ago

harbaum commented 2 years ago

I am running the v1.0.4 firmware.uf2 release with the HTTP_Server example from examples/HTTP/HTTP_Server/HTTP_Server.py

I use a Raspberry Pico connected to one of these small blue w5500 boards (https://www.az-delivery.de/products/w5500-ethernet-netzwerk-internet-modul-fuer-arduino). The W5500 reads WIZnet W5500 DQK581 2133 which seems to be quite new.

The whole setup is rather unreliable and see errors like this one:

Connect from ('192.168.1.1', 80)
HTTP_Server.py, line 55, in main
OSError: [Errno 107] ENOTCONN

This is in "accept". Sometimes also the recv or the send fail.

This doesn't always happens. Most of the time the reply is sent just fine. But occasionally errors like these happen. They happen more often the more traffic there is on the connection. On a dedicated direct connection to a PC this works better, on a network shared with many other devices it becomes quite unreliable.

Hitting the reload button on the clients browser fast breaks the connection pretty fast usually in one of the send commands:

Connect from ('192.168.1.1', 80)
HTTP_Server.py, line 70, in main
OSError: 7

I tried adding a bunch of try/except to recover. But that needs a few seconds to recover and isn't a satisfying solution.

What is the reason for these errors? How can I fix them?

irinakim12 commented 2 years ago

I think you need to change your IP address. 192.168.1.1 can also be the IP address used as the gateway address of the router on the network.

Please use the IP address of W5500 by selecting a non-conflicting IP from values between 192.168.1.2 and 192.168.1.253.

harbaum commented 2 years ago

This IP address is used in the P2P setup with 192.168.1.1 and 192.168.1.20 being the only machines on the cable.

In case of the bigger setup I configure this to use DHCP using nic.active instead of nic.ifconfig. But that doesn't affect the problem.

Both setups basically work but both frequently run into the NOCONN errors.

harbaum commented 2 years ago

To verify: If you run the HTTP_Server.py on a PICO + W5500 running 1.0.4 you can repeatedly and fast click the on/off buttons in the browser without triggering any python exceptions due to failing accept/recv/send ?

StefanKranz22 commented 2 years ago

I have the same Issue with a fresh new Pico Hat from Wiznet. In my Case the 1 Connection works. Then i get the same error.

harbaum commented 2 years ago

I have yet to try e.g. the regular c/c++ version. Is this a Micro-Python only issue? Or does the same happen in other setups as well?

StefanKranz22 commented 2 years ago

Yes, @harbaum i have test it with Micropython.

StefanKranz22 commented 2 years ago

The same Code works well on a ESP 32.

harbaum commented 2 years ago

Yes, @harbaum i have test it with Micropython.

The question was if that also happens in the c/c++ variant. So is this a Micro-Python specific problem or does this also happen in a different environment?

But since this renders the setup basically unusable I'd assume that the c/c++ setups don't exhibit this.

harbaum commented 2 years ago

Is anyone having success with the released binaries and a W5500 running e.g. the Webserver demo reliably?

UncleBee1885 commented 2 years ago

Is anyone having success with the released binaries and a W5500 running e.g. the Webserver demo reliably?

Yes. I have used them throughout the course of a project I'm working on to verify that the hardware is still functioning as normal.