Code Monkey home page Code Monkey logo

Comments (98)

rugal0123 avatar rugal0123 commented on September 20, 2024 1

Hi ofekp, thanks for the response. I'm able to setup port forwarding manually and verify it's working with my router by connecting to my esp32 from outside network. But i have no luck with trying to implement the libraries. I also set the UpnP feature enable at first.
Yes, the Samsung S7 Hotspot is just the cellular network as a 2nd test case for me. I was hoping it should work with my Asus router as first.
image

from tinyupnp.

rugal0123 avatar rugal0123 commented on September 20, 2024 1

I just bought a new asus router RT-AX58U to try but still got the same result after update the firmware to latest...
image
image

I'm not sure about the 'upnpc' bash program but this is the log report from the router web page after i disabled and re-enabled the UPnP service. No idea why all Asus router keep listening on port 5351 by default...
image
image
I guess Asus routers doesn't work at all..

from tinyupnp.

rugal0123 avatar rugal0123 commented on September 20, 2024 1

Hi ofekp, i did try to mess with the port number from your source code. I just read that Asus router doesn't allow Upnp feature to the WAN, LAN devices only... I guess that's why no matter if i turn on or off Upnp feature there's no response at all...
Here's the discussion:
https://www.snbforums.com/threads/new-upnp-exploit-affecting-most-asus-routers-upnproxy-blackhat-proxies-via-nat-injections.46011/
Maybe i will swap out with another router with different brand tomorrow to see how's the library works ...

from tinyupnp.

rugal0123 avatar rugal0123 commented on September 20, 2024 1

yes, you are right. I just tried with a Netgear router and still no different... Currently, i don't have any device that using UPnP in my network.
image
image

from tinyupnp.

rugal0123 avatar rugal0123 commented on September 20, 2024 1

Hi ofekp, I just ran the tool you suggested and here's the output...
image

from tinyupnp.

rugal0123 avatar rugal0123 commented on September 20, 2024 1

Here you go !
logfile_WAN.txt
logfile_WANPP.txt
UPNP_layer3F.txt

from tinyupnp.

rugal0123 avatar rugal0123 commented on September 20, 2024 1

You are right. It's still failing with the code from master branch. Here's the log file.
Log_master_branch_error.txt

from tinyupnp.

rugal0123 avatar rugal0123 commented on September 20, 2024 1

Hi ofekp, here's the new result ( still failed though).
Log_error003.txt
UPNP_WANIPConn003.txt
Gatedesc003.txt
UPNP_WANPPP003.txt
UPNP_layer3F003.txt

from tinyupnp.

rugal0123 avatar rugal0123 commented on September 20, 2024 1

I'm not sure there is extra configuration that i set. They are all default setting at first. Here's the log when esp is connecting
image
There's no response or record in router's log when upnpc or esp sending the M-SEARCH message. Also if you look below, there are multiple errors when i ran the upnpc tool
image

from tinyupnp.

rugal0123 avatar rugal0123 commented on September 20, 2024 1

Here's the output and define setting, in case you are interested. Same result ...
log_3139bf0.txt
image

from tinyupnp.

rugal0123 avatar rugal0123 commented on September 20, 2024 1

Hi ofekp, i've changed the port to 17676 and initializing the web server with LISTEN_PORT rather than number as you suggested. Still no luck.
image

Here's the example file.
example_file_upnp_esp32.txt

from tinyupnp.

rugal0123 avatar rugal0123 commented on September 20, 2024 1

Hi ofekp, here's the result of #54
image
I also tried another test with ESP8266 and found something interesting. This time M-SEARCH message sent and received, Gatewate info is valid but it still complained about "bad request and this server does not support the operation requested by your client" ! Please check my log below. I think we are getting closer to narrow the problem.
log_ESP8266_ebf68f2.txt
log_ESP8266_master_branch.txt

from tinyupnp.

rugal0123 avatar rugal0123 commented on September 20, 2024 1

Yes, you are right. Look like the Asus worked with esp8266 board. Here's the upnpc -l output:
image
Before i swapped out the Netgear router, i did check the mapping table there're only 2 rules applied to it which from the PC and RasPi upnpc tool earlier. No port applied from ESP8266 or ESP32 at all.

from tinyupnp.

ofekp avatar ofekp commented on September 20, 2024 1

Way I see it, we can now do two things:

  1. Solve the Asus router with ESP32
  2. Solve the ESP8266 with Netgear router

Let me know which one you prefer first.

from tinyupnp.

rugal0123 avatar rugal0123 commented on September 20, 2024 1

I think the model is ESP-WROOM-32. the board name is esp32 devkit v1

from tinyupnp.

rugal0123 avatar rugal0123 commented on September 20, 2024 1

No problem, i just tried the new ino file but same result though.
log_65bbf63_new_ino.txt

from tinyupnp.

rugal0123 avatar rugal0123 commented on September 20, 2024 1

Just tried with master branch, specifically with two additions in the ino file as you suggested. Same result. Don't give up !
image

image

from tinyupnp.

rugal0123 avatar rugal0123 commented on September 20, 2024 1

Yes, both of them are dual band routers. I tried with new branch but no luck ...
image

from tinyupnp.

rugal0123 avatar rugal0123 commented on September 20, 2024 1

So i read one of your closed issues "ESP32 support - crashs #38" and tried comment out UPNP_DEBUG. The result getting better.
image
Now my esp32 only crashed once before succeed mapping when addPortMappingEntry, exact on same line as well:
"String line = _wifiClient.readStringUntil('\r');"
image
We're starting to see interesting pattern here.

from tinyupnp.

ofekp avatar ofekp commented on September 20, 2024 1

Oh, I am so glad to read that :)
That's great!

I might consider turning it off by default due to this.

Thank you very much for letting me know.

from tinyupnp.

rugal0123 avatar rugal0123 commented on September 20, 2024 1

Yup. Now if you have any suggestion so that we can reduce the # of reset/crash to 0 it would be even better !

from tinyupnp.

ofekp avatar ofekp commented on September 20, 2024

No device on your network responded to the M-SEARCH message.

Can you confirm that your internal network is 192.168.29.0? do the routers have the same address format (except for the last number)?
Can you please check that you router has UPnP enabled?

I do not know Samsung S7 Mobile HotSpot but I am guessing it is cellular network? I am not sure this can work since cellular networks to not give you much control, so I am not sure you will be able to check what I asked on this router.

from tinyupnp.

ofekp avatar ofekp commented on September 20, 2024

This seems to be related to issue #35
I have merged the code few week ago, but it is not deployed to the Arduino Library Manager yet.

Can you take the code from master branch and try again?
Simply use the code as you see it GitHub rather than use the library from the Library Manager.

Let me know how it went please.

from tinyupnp.

rugal0123 avatar rugal0123 commented on September 20, 2024

I just deleted the libraries and used the latest from GitHub as you recommended but still no luck. Same result again, my router completely ignored the M-SEARCH message...
image
I've checked the router log to verify the Upnp feature is enabled
image

from tinyupnp.

ofekp avatar ofekp commented on September 20, 2024

why is it listening on 5351?
Is that the UPnP? should be 1900...
Do you have access to 'upnpc' bash program? If so please show me the output for upnpc -l

Make sure it looks like this:
image

I did see a post about issues with UPnP specifically with your router:
https://community.t-mobile.com/thread/140179

Have you tried that firmware update?

from tinyupnp.

ofekp avatar ofekp commented on September 20, 2024

I am not yet sure it actually means they listen on that port, it might mean something else.

Can you please read this short post and perform the actions described in it?
https://zapek.com/blog/how-to-fix-upnp-igd-not-working-on-asus-rt-ac87u/

from tinyupnp.

rugal0123 avatar rugal0123 commented on September 20, 2024

Yes i've tried that also but not working either. For the RT-AX58U router, look like they have the "IGMP snooping" feature enabled by default.
image

from tinyupnp.

ofekp avatar ofekp commented on September 20, 2024

Can you change this line to the 5351 port:
https://github.com/ofekp/TinyUPnP/blob/master/src/TinyUPnP.h#L16

If that does not work, please restore 1900 port.

Then, we'll need to set you up with upnpc tool.
Do you have a linux env somewhere? Old computer, Raspberry Pi? Anything?

from tinyupnp.

ofekp avatar ofekp commented on September 20, 2024

That looks unfortunate...
But since you are contacting the router from the LAN I still don't think it should be a problem. The router should respond to M-SEARCH messages coming from the LAN, wifi or not...

I am willing to keep looking for the issue, but we will need to execute upnpc commands from within the LAN.

Do you have any other device in your network that is using UPnP and puts rules dynamically in your router?

from tinyupnp.

ofekp avatar ofekp commented on September 20, 2024

The plot thickens!
Please describe your network to me. Nice and easy, I want to know how many routers you have specifically. How many switches, how many devices. Anything you can think of please.

I found a workaround for upnpc command in windows environment:

  • go to http://miniupnp.free.fr/files/
  • look for "latest files"
  • in the table, find the one file that is called "upnpc-exe" (upnpc-exe-win32-20150918)
  • download the folder and extract it somewhere (no installation needed)
  • open win terminal (command prompt)
  • enter the following command (change the folder path as needed):
    C:\Users\user-name>C:\Users\user-name\Downloads\upnpc-exe-win32-20150918\upnpc-shared.exe -l

Then please copy paste the output here.

I still need to know the layout of your network too.

from tinyupnp.

rugal0123 avatar rugal0123 commented on September 20, 2024

I use Comcast cable internet and have only 1 modem and 1 router. Currently running with 1 raspberry Pi that i can connect remotely with tightvnc service, 2 smart plug devices that i can control from anywhere, 1 PS4 and several mobile devices (iphones) and Smart TVs... very standard i think.

from tinyupnp.

ofekp avatar ofekp commented on September 20, 2024

OK, sounds standard, please try the upnpc for windows and and let's see what we get.

from tinyupnp.

ofekp avatar ofekp commented on September 20, 2024

Made a PR for you, if you feel adventurous (I have yet to test on my device) please give it a shot:
#53

Updated the PR. Please make sure to use commit with hash 94dc6cb, thanks.

from tinyupnp.

rugal0123 avatar rugal0123 commented on September 20, 2024

I've compiled and use the new version #94dc6cb you provided but same error...
image

from tinyupnp.

ofekp avatar ofekp commented on September 20, 2024

Darn, I made a mistake that caused it to behave the same... new hash is b375e92

But please note that the output indicates that you're using the library from Arduino Library Manager and not from the branch I created.

You'll need to go to the folder where the package is and override the code there in both .h file and .cpp file.
Folder should look something like this:
D:\arduino-1.8.9\libraries\TinyUPnP\src
There you'll find the files that you need to change.

from tinyupnp.

rugal0123 avatar rugal0123 commented on September 20, 2024

I've deleted the old library from Arduino Library Manager and use the branch that you created. The output displayed different but still no luck...

image

from tinyupnp.

ofekp avatar ofekp commented on September 20, 2024

Still timeout?
Can you please attach a text file of the output in following posts?

Seems like your Netgear router is also prone to UPnP issues:
https://community.netgear.com/t5/General-WiFi-Routers-Non/UPnP-still-broken-on-R6400/m-p/1639401

The claim that:
"UPnP is fixed by R6400 firmware version 1.0.1.46."

Can you please check what firmware you're running there?

from tinyupnp.

rugal0123 avatar rugal0123 commented on September 20, 2024

Here's the output file
output.txt
The version i got is newer 1.0.4.84.
image

from tinyupnp.

ofekp avatar ofekp commented on September 20, 2024

so no "timeout" message after the M-SEARCH is sent? Did you wait long enough?

from tinyupnp.

rugal0123 avatar rugal0123 commented on September 20, 2024

Yes, i didn't capture all of them in the text file. My bad. This is the full log.
output.txt

from tinyupnp.

ofekp avatar ofekp commented on September 20, 2024

Added another device type, please give the PR another try.

from tinyupnp.

rugal0123 avatar rugal0123 commented on September 20, 2024

Just did. Same result. Here's the log.
output2.txt

from tinyupnp.

ofekp avatar ofekp commented on September 20, 2024

Can you type in the path to the xml file in your browser that was printed by the upnpc command that you attached in this comment and attach the result here please?

from tinyupnp.

rugal0123 avatar rugal0123 commented on September 20, 2024

Hi ofekp, this is what i got after entered the info you asked
logfile.txt

from tinyupnp.

ofekp avatar ofekp commented on September 20, 2024

Now this please:
http://192.168.1.1:5000/Public_UPNP_WANIPConn.xml

And this:
http://192.168.1.1:5000/Public_UPNP_WANPPPConn.xml

And this:
http://192.168.1.1:5000/Public_UPNP_Layer3F.xml

😄

from tinyupnp.

ofekp avatar ofekp commented on September 20, 2024

Thank you :)
Can you now make sure the starting address for DHCP protocol that your router will distribute is 10 and above?
Meaning 192.168.1.10 will be the first address that any device on your network will receive.
Please also make sure your network mask is 255.255.255.0.
After this, I would like you to verify that the ESP's IP (from the serial log) is listed as one of the devices in your router. This can be in either the DHCP section which lists devices or under WiFi section.
Next, please run the upnpc command again and see if you get the xml file listed again (BTW, that means the router responded to M-SEARH for that particular device), send me the output too please.
Then from the same device please ping the ESP device using its IP.
Thank you!

from tinyupnp.

rugal0123 avatar rugal0123 commented on September 20, 2024

"Can you now make sure the starting address for DHCP protocol that your router will distribute is 10 and above". Done
image

"Please also make sure your network mask is 255.255.255.0". Done
"Verify that the ESP's IP (from the serial log) is listed as one of the devices in your router". Done. Device ip now is 192.168.1.22.
Here's the xml that i found:
Gatedesc.txt
UPNP_WANPPP.txt
UPNP_WANIPConn.txt
UPNP_layer3F002.txt
Pinged the ESP succesfully:
image

from tinyupnp.

ofekp avatar ofekp commented on September 20, 2024

Very good.

Can you please check serial log on the ESP after loading the code from master branch?

I am guessing you checked the PR code when you got the new 22 IP and it was still failing.

Please attach the text file.

from tinyupnp.

ofekp avatar ofekp commented on September 20, 2024

Hey, I pushed another debug line and added another header (USER_AGENT) to the PR, please give the same PR a try (hash 71ad57d).

Can you also please run the upnpc command again and send me the output. Thanks.

from tinyupnp.

ofekp avatar ofekp commented on September 20, 2024

This is starting to get rather depressing LOL
You said you have a RPi, can you ssh to it and run upnpc -l
I want to see that the router is replying to ssdp protocol over WiFi too.
You may be required to install upnpc, in that case, use this command: sudo apt-get install miniupnpc.
Can you attach the output here? Not the xmls but the output of the command. Thank! Don't give up! We'll find it!!

from tinyupnp.

rugal0123 avatar rugal0123 commented on September 20, 2024

Hi ofekp, i have installed the upnpc and here's the response.
image

from tinyupnp.

ofekp avatar ofekp commented on September 20, 2024

Thanks!

The RPi is connected with WiFi right?

Can you increase the number Advertisement Time To Live (in hops) in your UPnP section in the router?

I see it is set to 4 in this comment
Let's change it to 30 (to be on the safe side).

After you change the value, reset the router and wait for things to get back to order.
Then, please run the code with both the PR version and then the master version.

At this point, I am pretty sure this is something to do with your network configuration. I hope we will be able to find it.

I compared the UDP packet I am sending with that sent by upnpc tool (which does get a reply from the router) and it is identical down to the character.

OK, let's start with that please.

from tinyupnp.

rugal0123 avatar rugal0123 commented on September 20, 2024

Yes, the RPi is connect to Wifi. I did increase the Advertisement Time To Live (in hops) to 30 as you suggested but still no luck.
image
Maybe you are right this is something to do with network configuration but we have tried two different brands of router. I'm not sure if it's on the router side anymore...

from tinyupnp.

ofekp avatar ofekp commented on September 20, 2024

Yeah, I agree it does not seem like a router issue, rather the setup itself.
would you mind disconnecting everything, I mean everything except for the router, modem and ESP?

Few more questions:

  1. Do you have repeaters in your setup?
  2. Does the modem function as a router too? Any chance it is a fancy modem that also acts as a router?
  3. Do you use VPN on some device?

from tinyupnp.

rugal0123 avatar rugal0123 commented on September 20, 2024
  1. I only have 1 router to cover the Wifi area, no repeater.
  2. The modem is a different device, i can swap out the router easily and leave the modem alone.
  3. I don't think i ever used the VPN, only VNC to remote connect to the RPi.

from tinyupnp.

ofekp avatar ofekp commented on September 20, 2024

any other change in the router's configuration you may have made?

Can you look at the router's log while the esp is sending the M-SEARCH message?
actually, first with upnpc and then with the esp.

from tinyupnp.

ofekp avatar ofekp commented on September 20, 2024

Yeah, I have seen the errors, been trying to look for them but came up with nothing.
That said, the router does respond to M-SEARCH message from upnpc, you know that because it responded with the xml file.

Two options here:

  1. The errors are related to the problem with the ESP for some reason
  2. They are not related, in which case we will have to deal with these issues after we solve the M-SEARCH issue in the ESP.

I am guessing your windows machine might block UPnP with a firewall which should not be the case with the RPi.

Please run the following command from your windows machine, which should try to open a port in your router and let's see if it made it (I will still want to see the output for every command of course):
upnpc -e 'try1' -r 17998 TCP (windows machine)

Please run this command from RPi:
upnpc -e 'try2' -r 17999 TCP (rpi)

In addition, please run this command (from your RPi):
ip route | head -1 | awk '{print $3}' (rpi)

from tinyupnp.

rugal0123 avatar rugal0123 commented on September 20, 2024

Here's the result for the first command from window machine
image
From the RPi:
image
image

from tinyupnp.

ofekp avatar ofekp commented on September 20, 2024

If upnpc has trouble adding a port mapping (please check in the router that it actually failed) then I don't think we should be debugging TinyUPnP for now.
I suggest a hard reset for the router, and then let me know exactly what settings you changed.
Also give the command a try until you see the upnpc is succeeding.
I also suggest disconnecting every device, wired or not wired except for the pc.
I can also suggest (and help with) opening an issue to miniupnpc repo. They may be very helpful in this case.
First start by looking into similar issues in the repo.
I will sign off for now, but may take a look myself tomorrow.
For now, do as much of this as you can please.

from tinyupnp.

rugal0123 avatar rugal0123 commented on September 20, 2024

Hi ofekp, good news. I checked the Upnp menu in the router and look like the table has been mapped. I guess the upnpc tool is working somehow...
image

from tinyupnp.

ofekp avatar ofekp commented on September 20, 2024

Good thing we checked that :)
Please try to flash the code from this new PR
Please attach the output as text, and wait at least 4 cycles of M-SEARCH message.
Thanks

from tinyupnp.

ofekp avatar ofekp commented on September 20, 2024

can you change the listen port to 17676 and then try again?
notice that you changed a few things in the example, for one, the web server should be initialized with LISTEN_PORT rather than 80. So please change that before testing.

For completeness, can you send me the example file you're using? (remove the password before sending)

After changing the port, please also make sure you get a response from the esp when using the port in your browser.

from tinyupnp.

ofekp avatar ofekp commented on September 20, 2024

It's a long shot, but can you try to change in this line:
TinyUPnP tinyUPnP(20000); // -1 means blocking, preferably, use a timeout value (ms)
to use -1 instead. Meaning:
TinyUPnP tinyUPnP(-1); // -1 means blocking, preferably, use a timeout value (ms)

Can you run this in the last PR I sent you and also in master and attach the log files here please?
Please make sure to run for at least 2 minutes (it may seem stuck, but keep going)

Another question, do you happen to have another ESP of some version at home?

from tinyupnp.

rugal0123 avatar rugal0123 commented on September 20, 2024

I've set to -1 as you suggest. After waiting for at least 5 mins just to make sure and here's the result.
image
image
log_3139bf0_blocking.txt
log_master_blocking.txt
I've tried with another ESP board. Not sure if they are different version but look like they behave with the same results. Here's the screenshot of the 2nd esp device.
image

from tinyupnp.

ofekp avatar ofekp commented on September 20, 2024

please try to update all libraries and packages through the Arduino IDE and try again with master and latest branch.
What board are you choosing in the IDE when loading the code please?

from tinyupnp.

rugal0123 avatar rugal0123 commented on September 20, 2024

I have updated all the libraries such as Wifi libraries and esp32 libraries and Arduino IDE to the latest 1.8.12.
I'm using ESP32 Dev Module Board in the Board Selection Menu. I still don't see any difference in the output result...

from tinyupnp.

ofekp avatar ofekp commented on September 20, 2024

Can you try this #54 (same last PR with few changes).

from tinyupnp.

ofekp avatar ofekp commented on September 20, 2024

This is great news :) I was running out of ideas, LOL

So looks like it is related to the ESP32, I was starting to change code related to it, but the last try was unsuccessful as you know.

We can focus on ESP8266 for now, but if it is OK with you, I would like to pin-point the ESP32 issue later on.

Regarding the output, slight chance that this is why upnpc got all the errors, and since I see the request to add the port has been made by the package, can you check your router for the rule after the ESP has been running for a while?

Also, your router responds with "This server does not support the operation requested by your client." which is in contradiction to what the XML files it publishes are depicting. Any chance you can check the other router too?

Thanks!

from tinyupnp.

rugal0123 avatar rugal0123 commented on September 20, 2024

Here's the result for the other router (Asus). For the Asus router page setting, hard to tell if the upnp table has been mapped or no. Look like it failed to me...
log_ESP8266_Asus_router.txt
Hope you can find the root of the problem, it would be nice to see it's working on eps32 too because all my boards are esp32, only 1 esp8266 left :).

from tinyupnp.

ofekp avatar ofekp commented on September 20, 2024

Looks like the Asus worked:
"All port mappings were already found in the IGD, not doing anything"
Can you please check if the mapping is in the router?
Alternatively, upnpc -l should show you all the mappings in the router if you don't have a section in the router that clearly shows them to you.

BTW, did you check if the Netgear mappings maybe, even though it seems to fail it might have made the mapping in the router. Like we had with upnpc tool.

I will make a few more tries for the ESP32 in the coming days, hope you will be able to test them out.

from tinyupnp.

rugal0123 avatar rugal0123 commented on September 20, 2024

What intrigued me most would be the ESP32, why it cannot detect any gateway info :) It doesn't work on Asus or Netgear router either.

from tinyupnp.

ofekp avatar ofekp commented on September 20, 2024

(1) it is!
This issue is right up there with why the universe has more matter than antimatter. But I am sure we can figure this out ;)

I need some time to explore a few actions we can take, I hope it is a matter of code issue.
Since I do know, from a previous feature request that this should work for ESP32, I need you to give me the exact model of your ESP32 so I can check if it has known issues.

Meanwhile, if you can find some other ESP32 device from a friend or what not, please borrow it for a test against master branch.

from tinyupnp.

ofekp avatar ofekp commented on September 20, 2024

Please give this PR another try.

from tinyupnp.

rugal0123 avatar rugal0123 commented on September 20, 2024

Hi ofekp, i just did. Here's the result.
log_65bbf63.txt

from tinyupnp.

ofekp avatar ofekp commented on September 20, 2024

Oh, I failed to mention that the code change is in the ino file.
Can you please take the code changes from the PR specifically for the ino file?

You can also test it with master branch if it will fail, but take the code from the ino file in any case.

Sorry about that, thanks.

from tinyupnp.

ofekp avatar ofekp commented on September 20, 2024

Can you give it a try with master branch but with the two changes in the ino file?
Until I'll find new things to check, which is getting pretty hard BTW 😄

Just to be clear, talking about these two additions in the ino file:

  1. #include "esp_wifi.h" // needed to call esp_wifi_set_ps`
  2. esp_wifi_set_ps(WIFI_PS_NONE)

from tinyupnp.

ofekp avatar ofekp commented on September 20, 2024

Is this a dual band router? If so, can you try to disable 5Ghz band and try again?
If that won't work (which I guess it won't) please try this new branch.

from tinyupnp.

ofekp avatar ofekp commented on September 20, 2024

Please try the same PR again, this should do the trick this time.

I extended the ino example for ESP32 too, so feel free to use that too.

from tinyupnp.

rugal0123 avatar rugal0123 commented on September 20, 2024

Hi ofekp, i tried the new PR and look like it worked with some conditions after a few hit and miss. Would you take a look at the error_log. It caused the esp32 processor reset a few times with error "Guru Meditation Error: Core 1 panic'ed (LoadProhibited). Exception was unhandled." It worked when i use Listen_port 17996 but no luck with port 80.
log_db37355_new_ino.txt
image

from tinyupnp.

ofekp avatar ofekp commented on September 20, 2024

Did you mean that no issue and no exception occurred when using port 17996, and that flakiness was only when using port 80, meaning port 80 sometimes was OK? Can you elaborate on this if I got it wrong?

Can you check this for me:

  1. Keep using #define LISTEN_PORT 80
  2. In the ino file, in the line WebServer server(LISTEN_PORT); change the port to hard coded 17996

This will tell us if the exception is from TinyUPnP or from ESP32 WebServer package.

The decoded stack trace made no sense to me:

Decoding stack results
0x4014da42: tcp_receive at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/lwip/lwip/src/core/tcp_in.c line 1206
0x400db0b1: TinyUPnP::getIGDEventURLs(_gatewayInfo*) at D:\arduino-1.8.9\libraries\TinyUPnP\src\TinyUPnP.cpp line 768
0x400db149: TinyUPnP::getIGDEventURLs(_gatewayInfo*) at D:\arduino-1.8.9\libraries\TinyUPnP\src\TinyUPnP.cpp line 783
0x400d8316: TinyUPnP::upnpRuleToString(_upnpRule*) at D:\arduino-1.8.9\libraries\TinyUPnP\src\TinyUPnP.cpp line 1045
0x400da2d6: TinyUPnP::printAllPortMappings() at D:\arduino-1.8.9\libraries\TinyUPnP\src\TinyUPnP.cpp line 985
0x400dbf7b: HTTPClient::beginInternal(String, char const*) at Arduino15\packages\esp32\hardware\esp32\1.0.4\libraries\HTTPClient\src\HTTPClient.cpp line 271
0x40088b7d: spi_flash_protected_read_mmu_entry at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/spi_flash/flash_mmap.c line 303

from tinyupnp.

rugal0123 avatar rugal0123 commented on September 20, 2024

No, the flakiness happened on both port 17996 and 80 but port 17996 is able to mapped after multiple attempts, port 80 always failed. In both case, i noticed there are errors "Guru Meditation Error: Core 1 panic'ed (LoadProhibited).
I just checked as you suggested:
"Keep using #define LISTEN_PORT 80
In the ino file, in the line WebServer server(LISTEN_PORT); change the port to hard coded 17996"
i got the same error, here's the log file.
log_port80.txt

from tinyupnp.

ofekp avatar ofekp commented on September 20, 2024

Can you try the branch again, I added a few logs that may help.
Can you also attach here the available space on the ESP32 after flushing the the code (printed by the Arduino IDE after the code is uploaded).
Thanks.

from tinyupnp.

rugal0123 avatar rugal0123 commented on September 20, 2024

Here's the available space:

Sketch uses 779254 bytes (37%) of program storage space. Maximum is 2097152 bytes.
Global variables use 52480 bytes (16%) of dynamic memory, leaving 275200 bytes for local variables. Maximum is 327680 bytes.
Here's the log:
log_48aa06d.txt

from tinyupnp.

ofekp avatar ofekp commented on September 20, 2024

Hey, sorry for the delay, this is quite hard to figure out, since it originates from the WiFiClient package which is not mine.

Please make sure:

  1. All boards in "Boards Manager" are updated
  2. All libraries in "Library Manager" are updated
  3. No pins are connected to the ESP32

Now, please try the last branch (issue51_3) again.

from tinyupnp.

rugal0123 avatar rugal0123 commented on September 20, 2024

Hi ofekp, no problem. I just tried the last branch and made sure everything as you suggested but still no luck. Here's the log file.
log_af9fa.txt

from tinyupnp.

ofekp avatar ofekp commented on September 20, 2024

Can you do a Postman call please?

Method:

POST

URL:

192.168.29.1:57515/ctl/IPConn

Headers:

Connection:close
Content-Type:text/xml; charset="utf-8"
Host:192.168.29.1:57515
SOAPAction:"urn:schemas-upnp-org:service:WANIPConnection:1#GetSpecificPortMappingEntry"

Body:

<?xml version="1.0"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<s:Body>
<u:GetSpecificPortMappingEntry xmlns:u="urn:schemas-upnp-org:service:WANIPConnection:1">
<NewRemoteHost></NewRemoteHost>
<NewExternalPort>80</NewExternalPort>
<NewProtocol>TCP</NewProtocol>
</u:GetSpecificPortMappingEntry>
</s:Body>
</s:Envelope>

from tinyupnp.

rugal0123 avatar rugal0123 commented on September 20, 2024

This is what i got. Let me know if i missed anything with Postman setup:
image
image

image
image

from tinyupnp.

ofekp avatar ofekp commented on September 20, 2024

Good job there :) this is perfect.

  1. Are you using a good power supply? What kind please? Any way to replace it with something else just for the try?
  2. This issue was not present in ESP8266, right?
  3. Are you trying both port 80 and some other port?
  4. How many times does the process succeeds without rebooting? Can you run this for a while and give a rough probability for success?
  5. Please try the branch again, few modifications, unlikely to solve this if you ask me but let's try.

from tinyupnp.

ofekp avatar ofekp commented on September 20, 2024

Kind reminder, I hope all is well.

from tinyupnp.

rugal0123 avatar rugal0123 commented on September 20, 2024

Hi ofekp, Sorry for the late response. I hope you are doing well also. I just tried the new branch build but still experienced the crash issue when loading router information into esp32. As you can see from the log:
log_f267f593.txt
1)The power supply is good. I've never had any problem running with it.
2)I never tried this with esp8266. As far as we tried last time, the library worked with esp8266 so we focused on fixing with esp32.
3) It worked with other ports such as 17997, 17996 but only after several attempt and rebooting. Port 80 never worked.
4) 0 success on port 80. Running for a while wouldn't increase the probability of success either.

from tinyupnp.

rugal0123 avatar rugal0123 commented on September 20, 2024

Update for the esp8266:
_ There's no crash or reboot when running it. I'm able to map other ports such as 17997, 17996, 17995 except port 80. Not sure why but when i tried with port 80 it's registered as 17997...

log_f267f593_esp8266.txt
image

from tinyupnp.

ofekp avatar ofekp commented on September 20, 2024

Sorry for my delay.

Not sure why but when i tried with port 80 it's registered as 17997

I think it is just a rule that remained on the router, they stay there for a while before being cleaned up, do you think this is what happened?

I am unable to reconstruct this issue, even with port 80 and running for few hours. It seems to be an internal issue related to the ESP-32.

Can you try to run the code on the second core?

Refer to t this: https://techtutorialsx.com/2017/05/09/esp32-running-code-on-a-specific-core/
Relevant code (note that taskCore should be 1 as this is the second core):

static int taskCore = 1;
 
void coreTask( void * pvParameters ){
 
    String taskMessage = "Task running on core ";
    taskMessage = taskMessage + xPortGetCoreID();
 
    while(true){
        Serial.println(taskMessage);
        delay(1000);
    }
}
 
void setup() {
  Serial.begin(112500);
  delay(1000);
 
  Serial.print("Starting to create task on core ");
  Serial.println(taskCore);
 
  xTaskCreatePinnedToCore(
                    coreTask,   /* Function to implement the task */
                    "coreTask", /* Name of the task */
                    10000,      /* Stack size in words */
                    NULL,       /* Task input parameter */
                    0,          /* Priority of the task */
                    NULL,       /* Task handle. */
                    taskCore);  /* Core where the task should run */
 
  Serial.println("Task created...");
}
 
void loop() {
  Serial.println("Starting main loop...");
  while (true){}
}

from tinyupnp.

ofekp avatar ofekp commented on September 20, 2024

@rugal0123 Kind reminder :)

from tinyupnp.

rugal0123 avatar rugal0123 commented on September 20, 2024

Hi ofekp, sorry it's been a while ! I tried your latest version and it worked after a few times of hit and miss. The only issue i saw now is it crashed sometimes when reading the xml file and the esp32 had to reboot. Have you experienced this issue before ? Thanks !
image

image

from tinyupnp.

rugal0123 avatar rugal0123 commented on September 20, 2024

Here's the exception decoder:
image

from tinyupnp.

ofekp avatar ofekp commented on September 20, 2024

Please refrain from posting comments containing the references to other issues on threads that are not related to your specific problem as it may confuse other readers, I am referring to the comment I deleted in issue 70. No worries, just try to avoid that please.

What commit were you actually using?
So sometimes it works and sometimes not, right?
What is the percentage of success after a significant number of iterations?

It is falling on this line
So, this does not seem to be related to TinyUPnP as far as I can tell now.

Let's start from:

  1. Run on the second core, as I said in this comment
  2. Update all your libraries (Library Manager in Arduino IDE)
  3. Update all your boards (Board Manager in Arduino IDE)
  4. Try again

I am also noticing that you are trying a different port every time, is that correct? Maybe the issue is occurring only for specific set of ports?

from tinyupnp.

rugal0123 avatar rugal0123 commented on September 20, 2024
  1. What commit were you actually using? I'm running TinyUPnP v3.1.4 downloaded from Arduino Library Manager first then tried with branch issue 70, Arduino IDE v1.8.13.
  2. So sometimes it works and sometimes not, right? It works eventually after few times of crash and reboot, which is weird.
  3. What is the percentage of success after a significant number of iterations? After 4 or 5 times of reboot at least
  4. Yes it failed every time on this line :

"String line = _wifiClient.readStringUntil('\r');"

when running verifyPortMapping.
5) I tried to run on different core already and it failed exact on same line as mentioned above.
6) Maybe the issue is occurring only for specific set of ports? No different ports work fine, after few times of crash and reboot as mentioned above...
7) I also removed all the server code and run the upnp alone... Same result, working after few times of crash and reboot.

from tinyupnp.

ofekp avatar ofekp commented on September 20, 2024

I will try to think of something, if you happen to be able to run on a different ESP32 or even ESP8266 please do so and let me know if this was reconstructed.
let me know if you'll find out more information.

from tinyupnp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.