Open slowpoison4 opened 3 years ago
are you still able to ping the ESP via the ENC28J60 when this happens?
The ESP works since it communicates with the other main controller. But ENC28j60 never reconnects. It works again when i restart the ESP8266. Sometimes not immediately. takes like 3-4 resets for it to work again
what I where trying to check with this is if the ENC28j60 is still working and communicating with the ESP. ping will only work when the ENC28j60 sends the data to the ESP and the ESP instructs the ENC28j60 to answer with a ping. if ping or any other connection is not working the problem is with the ENC28j60 or the ENC28j60 lib for sure and its nothing that can be fixed a the websocket level.
one other thing to check is if you are using DHCP is if the not working comes in the same time frame with a DHCP renew.
a simple test for this is to do the config statically and it is working then its related to DHCP problems.
from looking at your code I miss the call to maintain
of UIPEthernet.h which will handle the DHCP renew
enabling the debug output ouf the lib will help too to see whats going on ;)
Hi,
I tried adding Ethernet.maintain() to my void loop. still having the same problem. Ive enabled the websockets debug output. This is what im getting:
[WS][0][sendFrame] fin: 1 opCode: 10 mask: 1 length: 0 headerToPayload: 0 09:58:14.894 -> [write] n: 6 t: 2841841 09:58:14.894 -> [WS][0][sendFrame] sending Frame Done (2511us). 09:58:31.874 -> [WS-Client] sending HB ping 09:58:31.874 -> [WS][0][sendFrame] ------- send message frame ------- 09:58:31.874 -> [WS][0][sendFrame] fin: 1 opCode: 9 mask: 1 length: 0 headerToPayload: 0 09:58:31.874 -> [write] n: 6 t: 2858797 09:58:31.874 -> [WS][0][sendFrame] sending Frame Done (2326us). 09:58:31.874 -> [WS][0][handleWebsocketWaitFor] size: 2 cWsRXsize: 0 09:58:31.874 -> [readCb] n: 2 t: 2858814 09:58:31.874 -> [WS][0][handleWebsocketWaitFor][readCb] size: 2 ok: 1 09:58:31.874 -> [WS][0][handleWebsocket] ------- read massage frame ------- 09:58:31.874 -> [WS][0][handleWebsocket] fin: 1 rsv1: 0 rsv2: 0 rsv3 0 opCode: 10 09:58:31.874 -> [WS][0][handleWebsocket] mask: 0 payloadLen: 0 09:58:31.874 -> [WS][0][handleWebsocket] get pong () 09:58:51.882 -> [WS][0][handleWebsocketWaitFor] size: 2 cWsRXsize: 0 09:58:51.882 -> [readCb] n: 2 t: 2878814 09:58:51.882 -> [WS][0][handleWebsocketWaitFor][readCb] size: 2 ok: 1 09:58:51.882 -> [WS][0][handleWebsocket] ------- read massage frame ------- 09:58:51.882 -> [WS][0][handleWebsocket] fin: 1 rsv1: 0 rsv2: 0 rsv3 0 opCode: 9 09:58:51.882 -> [WS][0][handleWebsocket] mask: 0 payloadLen: 0 09:58:51.882 -> [WS][0][handleWebsocket] ping received () 09:58:51.882 -> [WS][0][sendFrame] ------- send message frame ------- 09:58:51.882 -> [WS][0][sendFrame] fin: 1 opCode: 10 mask: 1 length: 0 headerToPayload: 0 09:58:51.882 -> [write] n: 6 t: 2878845 09:58:51.882 -> [WS][0][sendFrame] sending Frame Done (2411us). 09:59:08.862 -> [WS-Client] sending HB ping 09:59:08.862 -> [WS][0][sendFrame] ------- send message frame ------- 09:59:08.862 -> [WS][0][sendFrame] fin: 1 opCode: 9 mask: 1 length: 0 headerToPayload: 0 09:59:08.862 -> [write] n: 6 t: 2895806 09:59:08.862 -> [WS][0][sendFrame] sending Frame Done (2318us). 09:59:08.862 -> [WS][0][handleWebsocketWaitFor] size: 2 cWsRXsize: 0 09:59:08.862 -> [readCb] n: 2 t: 2895827 09:59:08.862 -> [WS][0][handleWebsocketWaitFor][readCb] size: 2 ok: 1 09:59:08.862 -> [WS][0][handleWebsocket] ------- read massage frame ------- 09:59:08.862 -> [WS][0][handleWebsocket] fin: 1 rsv1: 0 rsv2: 0 rsv3 0 opCode: 10 09:59:08.862 -> [WS][0][handleWebsocket] mask: 0 payloadLen: 0 09:59:08.862 -> [WS][0][handleWebsocket] get pong () 09:59:28.880 -> [WS][0][handleWebsocketWaitFor] size: 2 cWsRXsize: 0 09:59:28.880 -> [readCb] n: 2 t: 2915828 09:59:28.880 -> [WS][0][handleWebsocketWaitFor][readCb] size: 2 ok: 1 09:59:28.880 -> [WS][0][handleWebsocket] ------- read massage frame ------- 09:59:28.880 -> [WS][0][handleWebsocket] fin: 1 rsv1: 0 rsv2: 0 rsv3 0 opCode: 9 09:59:28.880 -> [WS][0][handleWebsocket] mask: 0 payloadLen: 0 09:59:28.880 -> [WS][0][handleWebsocket] ping received () 09:59:28.880 -> [WS][0][sendFrame] ------- send message frame ------- 09:59:28.880 -> [WS][0][sendFrame] fin: 1 opCode: 10 mask: 1 length: 0 headerToPayload: 0 09:59:28.880 -> [write] n: 6 t: 2915858 09:59:28.880 -> [WS][0][sendFrame] sending Frame Done (2411us). 09:59:45.879 -> [WS-Client] sending HB ping 09:59:45.879 -> [WS][0][sendFrame] ------- send message frame ------- 09:59:45.879 -> [WS][0][sendFrame] fin: 1 opCode: 9 mask: 1 length: 0 headerToPayload: 0 09:59:45.879 -> [write] n: 6 t: 2932815 09:59:45.879 -> [WS][0][sendFrame] sending Frame Done (2328us). 09:59:45.879 -> [WS][0][handleWebsocketWaitFor] size: 2 cWsRXsize: 0 09:59:45.879 -> [readCb] n: 2 t: 2932838 09:59:45.879 -> [WS][0][handleWebsocketWaitFor][readCb] size: 2 ok: 1 09:59:45.879 -> [WS][0][handleWebsocket] ------- read massage frame ------- 09:59:45.879 -> [WS][0][handleWebsocket] fin: 1 rsv1: 0 rsv2: 0 rsv3 0 opCode: 10 09:59:45.879 -> [WS][0][handleWebsocket] mask: 0 payloadLen: 0 09:59:45.879 -> [WS][0][handleWebsocket] get pong () 10:00:22.867 -> [WS-Client] sending HB ping 10:00:22.867 -> [WS][0][sendFrame] ------- send message frame ------- 10:00:22.867 -> [WS][0][sendFrame] fin: 1 opCode: 9 mask: 1 length: 0 headerToPayload: 0 10:00:22.867 -> [write] n: 6 t: 2969824 10:00:22.867 -> [WS][0][sendFrame] sending Frame Done (2409us). 10:00:29.832 -> [HBtimeout] pong TIMEOUT! lp=2939331 millis=2976831 pi=7001 count=1 10:00:29.866 -> [WS-Client] sending HB ping 10:00:29.866 -> [WS][0][sendFrame] ------- send message frame ------- 10:00:29.866 -> [WS][0][sendFrame] fin: 1 opCode: 9 mask: 1 length: 0 headerToPayload: 0 10:00:29.866 -> [write] n: 6 t: 2976839 10:00:29.866 -> [WS][0][sendFrame] sending Frame Done (2388us). 10:00:36.844 -> [HBtimeout] pong TIMEOUT! lp=2946346 millis=2983846 pi=7001 count=2 10:00:36.879 -> [WS-Client] sending HB ping 10:00:36.879 -> [WS][0][sendFrame] ------- send message frame ------- 10:00:36.879 -> [WS][0][sendFrame] fin: 1 opCode: 9 mask: 1 length: 0 headerToPayload: 0 10:00:36.879 -> [write] n: 6 t: 2983854 10:00:36.879 -> [WS][0][sendFrame] sending Frame Done (2313us). 10:00:43.909 -> [HBtimeout] pong TIMEOUT! lp=2953361 millis=2990861 pi=7001 count=3 10:00:43.909 -> [WS-Client] sending HB ping 10:00:43.909 -> [WS][0][sendFrame] ------- send message frame ------- 10:00:43.909 -> [WS][0][sendFrame] fin: 1 opCode: 9 mask: 1 length: 0 headerToPayload: 0 10:00:43.909 -> [write] n: 6 t: 2990869 10:00:43.909 -> [WS][0][sendFrame] sending Frame Done (2348us). 10:00:50.902 -> [HBtimeout] pong TIMEOUT! lp=2960376 millis=2997876 pi=7001 count=4 10:00:50.937 -> [WS-Client] sending HB ping 10:00:50.937 -> [WS][0][sendFrame] ------- send message frame ------- 10:00:50.937 -> [WS][0][sendFrame] fin: 1 opCode: 9 mask: 1 length: 0 headerToPayload: 0 10:00:50.937 -> [write] n: 6 t: 2997884 10:00:50.937 -> [WS][0][sendFrame] sending Frame Done (2400us). 10:00:57.921 -> [HBtimeout] pong TIMEOUT! lp=2967391 millis=3004891 pi=7001 count=5 10:00:57.921 -> [HBtimeout] count=5, DISCONNECTING 10:00:57.921 -> [WS-Client] client disconnected. 10:00:57.921 -> [WSc] Disconnected! 10:01:22.897 -> [WS-Client] connection to 192.168.0.115:8080 Failed 10:01:22.897 -> ETHWSCDISCONNECTED 10:01:22.897 -> 10:01:22.897 -> [WS-Client] client disconnected. 10:01:22.897 -> [WSc] Disconnected! 10:01:22.897 -> ETHWSCDISCONNECTED 10:01:22.897 -> 10:01:52.921 -> [WS-Client] connection to 192.168.0.115:8080 Failed 10:01:52.921 -> [WS-Client] client disconnected. 10:01:52.921 -> [WSc] Disconnected!
as you can see, it works perfectly fine and then suddenly the Ping-pong connection stops being able to send and receive.
EDIT: I put Ethernet.linkStatus() to be checked periodically in my void loop (every10s). it returns 1 even after the websocket is disconnected. do this mean that the ESP is able to communicate with the ENC? EDIT2: I removed the LAN cable from the module and the LinkStatus value returned 2. So im sure the ENC module is able to communicate with the ESP.
ok strange the log shows that the Websocket code sends a ping and the ENC says it has send it, but after 5 pings and no pongs the code declares the current connection dead and tries to create a new one and only gets failed from the ENC.
form the websocket side the code does what it is designed to do (on to many ping fails create a new connection). but why no nonnection is possible is a good question, have you used tcpdump or wireshark to check if you see any SYN/ACK or any other traffic from the ENC on you network when the problem starts?
currently this looks like a problem in the lower levels (ENC or Network) to me.
If I may, FWIW, there's another enc28j60 driver integrated with the network stack in the git version of the esp8266 arduino core.
@Links2004 ill try wireshark and check. @d-a-v Ill try the esp8266 version of the repo and get back to you
Hi @Links2004 Sorry it took me time to respond back. Was busy with work. I tried everything to see what caused the problem. Eventually i decided to try w5100 and a Mega. It works like a charm. But i am limited by the Mega's capabilities and wish to connect to either ESP8266 or ESP32.
Speaking of the integrated drivers in the git version of the esp8266 arduino core, you can use an ethernet chip (W5500, W5100, enc28j60). The esp will connect to wifi or ethernet whatever is powered on and configured - or on which a dhcpserver will answer first. These boards connect through the standards SPI GPIOs (MISO, MOSI, CLK, vcc, gnd) + the CS/SS pin (name: ChipSelect or SlaveSelect though any free GPIO pin that you chose and give to the board c++ constructor).
Hi,
I have a NodeJS ws server running and my ESP8266 connected to ENC28J60 acts as a websocket client. The connection gets established and everything works fine initially. But after 20 to 30 min the connection just drops and doesn't reconnect again. I am sending JSON packets to the server from my device. I am using the basic Websocket client code.
The ENC28J60 does run hot. I've given it external power supply of 3.3V. The supply is capable of delivering up to 1A of continuous current. I've tried 2-3 different modules but ends up with the same problem. I'm unsure what is going on. My connection is as per the following link: https://github.com/UIPEthernet/UIPEthernet/blob/master/hardware/NodeMCU_enc28j60_wiring.PNG
Ive not used the BS170 transistors. Instead i manually disconnect the D8 (cs) pin during upload and wait for the [SETUP] BOOT WAIT 4... and insert it. I get the IP Address localIP: 192.168.0.108 subnetMask: 255.255.255.0 gatewayIP: 192.168.0.1 dnsServerIP: 192.168.0.1
It connects to my websocket server and exchanges all the messages successfully for 20-30min. after which it fails. I have another ESP8266 connected to my UART0 which sends the JSON packets. The ENC28J60 system only acts as a transmitter and receiver for ETH websocket connection
My Code: