Wifi Client connection failed after reboot

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
Brommander
New user
Posts: 3
Joined: 16 Jun 2022, 14:54

Wifi Client connection failed after reboot

#1 Post by Brommander » 16 Jun 2022, 15:27

Hello,
I've started a new project. My aim is to read out an inverter using modbus. I use the ESP32 and start an WifiClient to connect to the inverter. My plugin is ready so far. However, there is a problem. The connection cannot be reestablished when the ESP is restarted (wificlient.connect(lIP, 1502) always returns false). If the plugin is "Disabled" and "Enabled", everything works again.
So I think I have to restart or free anything.

Has anyone an idea how to work with WifiClient after use or to restart. Just client.stop() is not enough.

Thank you

regards
Peter

User avatar
Ath
Normal user
Posts: 3416
Joined: 10 Jun 2018, 12:06
Location: NL

Re: Wifi Client connection failed after reboot

#2 Post by Ath » 16 Jun 2022, 15:46

- What build of ESPEasy are you using?
- Are you building your own plugin, or using an existing one?
/Ton (PayPal.me)

Brommander
New user
Posts: 3
Joined: 16 Jun 2022, 14:54

Re: Wifi Client connection failed after reboot

#3 Post by Brommander » 16 Jun 2022, 16:10

I use the custom_ESP32_4M316k build. As a basis I used the mega branch of 19.05.22.
It's a new plugin.

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Wifi Client connection failed after reboot

#4 Post by TD-er » 16 Jun 2022, 16:33

Sounds like your plugin is causing a crash.
Do you see the unit rebooting when observing the log?

If you post the code of the plugin, we can have a peek of what might be happening here.

Also you may want to check whether there is a network connection, using the available functions in src/Helpers/Networking.cpp (and .h of course)

Brommander
New user
Posts: 3
Joined: 16 Jun 2022, 14:54

Re: Wifi Client connection failed after reboot

#5 Post by Brommander » 17 Jun 2022, 12:29

I found the problem.
As a workaround a tried to "enable" and "disable" with the rules. But although the rule worked, the connection could not be reestablished. So I checked the settings of the plugin.
In short, the IP address was not stored correctly. When pushing on "save" the IP address was rewritten. Then it worked again.

So thanks for your help

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Wifi Client connection failed after reboot

#6 Post by TD-er » 17 Jun 2022, 20:36

Where is the IP address stored that you need?
If it is in your own code, please show how the data structure is made and how you have your save function implemented (and the webform load)

Post Reply

Who is online

Users browsing this forum: No registered users and 23 guests