TinyUPnP icon indicating copy to clipboard operation
TinyUPnP copied to clipboard

TinyUPNP library makes my esp8266 crash and reset

Open mustafaosarwala opened this issue 5 years ago • 18 comments

I am trying to open a port on my router using tinyupnp library. Right now i am trying the example code given in the library. the code compiles fine but after uploading after every few seconds my esp8266 keeps resetting and shows the following error.

501` Not Implemented
Not Implemented
The HTTP Method is not implemented by this server.
called getIGDEventURLs
deviceInfo->actionPath [] deviceInfo->path [/igdevicedesc.xml]
TCP connection timeout while executing getIGDEventURLs
called getIGDEventURLs
deviceInfo->actionPath [] deviceInfo->path [/igdevicedesc.xml]

Soft WDT reset

This keeps happening on a loop continuously and i cant make out what the problem is. please help.

Log file: esp8266_tinyupnp_log.txt

mustafaosarwala avatar Jan 11 '20 04:01 mustafaosarwala

@mustafaosarwala can you please attach here the result of querying http://192.168.0.1:5431/igdevicedesc.xml?

Please also check that UPnP is enabled in your router.

ofekp avatar Jan 19 '20 18:01 ofekp

@ofekp UPNP is enabled on my router. I tried to disable it and enable it again still not working. it has a wan interface option with two options one is blank and other is "pppoe 1", i have tried with both the options. default was keeping it blank. attached is the xml file requested.

igdevicedesc.zip igdevicedesctxt.txt

mustafaosarwala avatar Jan 20 '20 03:01 mustafaosarwala

Your router does not answer back to the request to get the file igdevicedesctxt.txt which is the same file you were able to get when using your browser.

This tells me your router expects some header that we did not provide. I am guessing, though.

This happens in the method getIGDEventURLs.

Let's start with your router model, can you give me the brand and model please, I wanna see if someone had a similar issue?

ofekp avatar Jan 21 '20 19:01 ofekp

Its a D-link ADSL Router. Model : DSL-2730U If It is a router specific issue then i can try it in some other router and check if the issue persists. Hope that helps in diagnosis.

mustafaosarwala avatar Jan 22 '20 03:01 mustafaosarwala

OK, I did not find anything regarding this model. Moreover, the HTTP rfc claims that GET request should never be responded with 501 status code.

Can you give it a try with a different router please?

Also, I am assuming you did not introduce any change to the code, except for the fields that must be set in the example.

ofekp avatar Jan 22 '20 14:01 ofekp

I tried it with a portable router and it works fine with the it. I am still trying to understand what is holding it from getting the xml file from my original router. It works now but not with my original router.

mustafaosarwala avatar Jan 23 '20 09:01 mustafaosarwala

OK, we can keep trying to understand what is the issue with your other router.

Are you willing to try to update your router's firmware?

Are you familiar with Postman? It is a program that will let you issue HTTP requests while having control over the headers you send. If you want to keep trying, we will have to reproduce the issue with that program. It will take few iterations but it is worth trying.

Please start by downloading the program from their site https://www.getpostman.com/

You should do a GET request with the following parameters: Method GET

URL http://192.168.0.1:5431/igdevicedesc.xml

Headers

Content-Type: text/xml; charset="utf-8"
Host: 192.168.0.1:5431
Content-Length: 0

Fire it away and let me know what the response was. Did you get the file or the 501 Unsupported error.

ofekp avatar Jan 25 '20 10:01 ofekp

Will Surely do. Learning something new will be fun. Thanks for showing such enthusiasm Its really appreciated.

Hope this is not taking much of your time. Thanks once again.

mustafaosarwala avatar Jan 25 '20 10:01 mustafaosarwala

NP, please do not update the firmware now though. Let's start with the Postman thing.

I suspect maybe your router is not liking the Content-Length: 0 header. Since this is a GET request.

ofekp avatar Jan 25 '20 10:01 ofekp

Postman got the file. and i have not updated the router firmware.

mustafaosarwala avatar Jan 25 '20 11:01 mustafaosarwala

Can you please print screen the headers section and the url?

ofekp avatar Jan 25 '20 12:01 ofekp

Here is a screen shot of the headers section.

Screenshot (12)

mustafaosarwala avatar Jan 25 '20 14:01 mustafaosarwala

Can you expand the "Temporary Headers" please?

Can you try switching the method to POST in the top left, right before the URL? Can you also try to put Content-Length as 1 or 10 and try again?

ofekp avatar Jan 25 '20 14:01 ofekp

Here is the screenshot of the temporary headers. Post Request returns "Bad Request"

The Result is same with Content-Length as 0/1 or 10

Screenshot (13)

mustafaosarwala avatar Jan 25 '20 14:01 mustafaosarwala

Here are the rest of the screenshots. Thank you.

Screenshot (16)

Screenshot (15)

Screenshot (14)

mustafaosarwala avatar Jan 25 '20 15:01 mustafaosarwala

Thank you for that. can you expand that temporary headers section and tell me what's inside? and maybe make sure they are not sent (if possible, I am not sure Postman will let you cancel those but let's try)

ofekp avatar Jan 25 '20 17:01 ofekp

@ofekp I am really sorry for the late reply. These are the temporary headers sent by postman.

User-Agent:PostmanRuntime/7.22.0 Accept:/ Cache-Control:no-cache Postman-Token:9466445f-a24d-4e8c-afda-4130e11daa8e Accept-Encoding:gzip, deflate, br Connection:keep-alive

from which postman only allows to disable cache-control and postman-token which i did disable. still the same result nothing changed.

I also added these headers in getIGDEventURLs() but it still didnt work.

This is the screenshot of arduino serial monitor after adding the headers. (This is a different esp this one doesnt reset and go on a loop like the other one.

Screenshot (17)

Screenshot (18)

mustafaosarwala avatar Jan 27 '20 14:01 mustafaosarwala

No worries. OK, can you restore the headers to their original state and then remove only the "Content-Type" header from the code please? (remove the line _wifiClient.println(F("Content-Length: 0"));)

After that, if it does not help, let's go ahead with the firmware update please, and then see if the problem persists.

ofekp avatar Jan 27 '20 18:01 ofekp