Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HandleWiFi() Sometimes Doesn't Send Parameters (Question) #1302

Open
bwjohns4 opened this issue Oct 21, 2021 · 14 comments
Open

HandleWiFi() Sometimes Doesn't Send Parameters (Question) #1302

bwjohns4 opened this issue Oct 21, 2021 · 14 comments
Labels
Branch This applies to a branch bug Validated BUG Discussion Further Discussion ongoing QA Quality Assurance testing needed 📶 WiFi WiFi or connection related issue

Comments

@bwjohns4
Copy link

I forked this a while back this year off the master (at the time). It's worked flawlessly using a smartphone, but I've recently noticed that when using a Windows computer to connect that it seems to flood the captive portal server and somehow my params are getting dumped out of the html response back to user which allows them to configure my params. Has there been a fix or anything about this? Any insight?

@tablatronix
Copy link
Collaborator

no idea use the latest version

@tablatronix tablatronix added the Question User Question member to member support label Nov 3, 2021
@bwjohns4
Copy link
Author

I merged the latest master with my version and am still seeing similar issues. Where can I look to try to understand this better? There seem to be two related but different issues

  • Sometimes the captive portal just instantly closes. Maybe too many requests from my iphone (it's what I've been testing with) that just trigger my captive portal to close? Then I have to disconnect and reconnect to the SSID to re-trigger the captive portal and hope it stays alive during it's lifecycle
  • Sometimes it doesn't send the full response even though they are just additions to the page string using page +=. I don't understand how it could possibly make it down the list of page += x; page+=y; page+=z then in the response sometimes y isn't in there!

Is there somewhere I can look to better understand what's going on here? Like a wireshark view into the requests that the webserver is actually getting and a log of the responses it's sending?

@tablatronix
Copy link
Collaborator

tablatronix commented Dec 13, 2021

Why the fork ?

Yeah mine does that, flood, you are supposed to disconnect other connections when using captive portals. I was looking into adding better filtering for specific cp checks, but they are such a moving target and there is no standard, right now we redirect everything.

Also page variable is on heap and not allocated, so it can overflow, I have been meaning to try to pre allocate its size or use a better buffer

Also make sure you are not remembering the ssid for the device, forget network etc

From my understanding the cp check has to get an ip and a response fast enough or it closes, usually it will open back up. But why it is so flaky I have no idea. I think if we specifically listed for apples cp check maybe it will help.

There are some other cp projects that have attempted this, might be worth checking, maybe espeasy or something I forget

@tablatronix tablatronix added 📶 WiFi WiFi or connection related issue Discussion Further Discussion ongoing QA Quality Assurance testing needed labels Dec 13, 2021
@bwjohns4
Copy link
Author

I forked it just because I'm not a good enough programmer to make everything elegant so I hack my way through my forked copy making WM work to suit my needs by just modifying things directly, changing HTML directly, etc. I do understand most of these concepts, just not elegant in making them simple and minimum. If a number of simultaneous requests come in that get redirected, are they handled sequentially and then destroyed before the next request is handled? Or are they more concurrent causing memory issues?

@bwjohns4
Copy link
Author

As further troubleshooting, here is my code and output. I had the problem when using getParamsOut() before, then I removed the params altogether to embed my HTML config directly into WM (not elegant, but easier to edit the HTML directly rather than build through params).

Sometimes pitem gets added in, then sometimes it doesn't!!! How can this be? I added size checks below to show that pitem is not empty but somehow doesn't get added to page via page += pitem

  page += FPSTR(HTTP_FORM_WIFI_END);

  pitem = getBwjohns4StoredHTML(FPSTR(HTTP_CONFIG_HTML), useDefaults);
          Serial.print("Size of Pitem: ");
          Serial.println(pitem.length());
          Serial.print("Page Size Before: ");
          Serial.println(page.length());
  page += pitem;
          Serial.print("Page Size After: ");
          Serial.println(page.length());
  page += FPSTR(HTTP_FORM_END);
  page += FPSTR(HTTP_BACKBTN);
  page += FPSTR(HTTP_END);

Then here is the output:

*wm:[2] AP: -86 Deathstar
*wm:[2] AP: -86 SpectrumSetup-18
*wm:[2] AP: -87 SpectrumSetup-04
Size of Pitem: 7776
Page Size Before: 6230
Page Size After: 6230
*wm:[2] <- Request redirected to captive portal
*wm:[2] <- HTTP Root
*wm:[2] <- Request redirected to captive portal
*wm:[2] <- HTTP Root

@bwjohns4
Copy link
Author

I think changing it to chunked response solved the problem!

@tablatronix
Copy link
Collaborator

Ah you seem to be hitting some kind of packet resp limit maybe?

@tablatronix tablatronix added bug Validated BUG and removed Question User Question member to member support labels Dec 14, 2021
@bwjohns4
Copy link
Author

I don't think it's a limit at the packet level, but rather a memory limit when trying to concat large strings when building the response string with a lot of adding onto the end of page. Chunking it allows to first send the wifi scan results, then send the parameters (if there are any) and then whatever is left after that. That way, String page can be reset to page = "" periodically so that it doesn't grow to be too large. I submitted a pull request based upon how I fixed it. This will actually be my first PR, so let me know if I didn't do that correctly.

@tablatronix
Copy link
Collaborator

Can you show me your code? I thought I saw it but cant find it

@tablatronix
Copy link
Collaborator

oh nm, #1319

@tablatronix
Copy link
Collaborator

What webserver has these methods? Not compiling for me

@bwjohns4
Copy link
Author

ESP8266Webserver... What compile errors are you getting? Has the master changed webservers?

@tablatronix
Copy link
Collaborator

Esp32 does not have chunked methods it seems

@bwjohns4
Copy link
Author

I see that now. I'll look into how to reconcile that for ESP32 as well and then push that.

@tablatronix tablatronix added the Branch This applies to a branch label Feb 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Branch This applies to a branch bug Validated BUG Discussion Further Discussion ongoing QA Quality Assurance testing needed 📶 WiFi WiFi or connection related issue
Projects
None yet
Development

No branches or pull requests

2 participants