Code Monkey home page Code Monkey logo

tinyupnp's Introduction

TinyUPnP

A very small UPnP IGD implementation for ESP8266 or ESP32.

Installation

Just clone or download as zip, then simply copy the folder TinyUPnP to the Arduino IDE "libraries" folder e.g "D:\arduino-1.8.9\libraries".

Usage and More Information

Dependecies

Boards:

Libraries (Arduino IDE -> Sketch -> Include Library -> Manage Libraries):

  • EasyDDNS - For telling your DDNS server what the IP of your Gateway Router is (optional).

Include

#include "TinyUPnP.h"
#include <EasyDDNS.h>  // optional

Declare

TinyUPnP *tinyUPnP = new TinyUPnP(20000);  // -1 for blocking (preferably, use a timeout value in [ms])

Setup

// you may repeat 'addPortMappingConfig' more than once
tinyUPnP->addPortMappingConfig(WiFi.localIP(), LISTEN_PORT, RULE_PROTOCOL_TCP, LEASE_DURATION, FRIENDLY_NAME);

// finally, commit the port mappings to the IGD
portMappingAdded = tinyUPnP->commitPortMappings();

Loop

// update UPnP port mapping every ms internal
// you can provide an optional method for reconnecting to the WiFi (otherwise leave as NULL)
tinyUPnP->updatePortMappings(600000, &connectWiFi);  // 10 minutes

API

This is specific for the example code, you can do what you like here

http://<IP or DDNS>:<LISTEN_PORT>/?percentage=<0..100>

Print

// print all the port mappings that were configured using 'addPortMappingConfig' in the setup step
tinyUPnP->printPortMappingConfig();

// print all the current port mappings from the IGD
tinyUPnP->printAllPortMappings();

Debug

You can turn off debug prints by setting UPNP_DEBUG to false in TinyUPnP.h#L16

Issues

When reporting issues, attach full log (i.e UPNP_DEBUG is set to true) and add the serial output to the issue as a text file attachment.

Donation

Donate If you like what I got, you can consider donating here, you can change the amount as you like.

โญ If not, starring this project will go a long way to help me too!

For anyone interested in how the library works

  1. It sends an M_SEARCH message to UPnP UDP multicast address.
  2. The gateway router will respond with a message including an HTTP header called Location.
  3. Location is a link to an XML file containing the IGD (Internet Gateway Device) API in order to create the needed calls which will add the new port mapping to your gateway router.
  4. One of the services that is depicted in the XML is <serviceType>urn:schemas-upnp-org:service:WANPPPConnection:1</serviceType> which is what the library is looking for.
  5. That service will include a eventSubURL tag which is a link to your router's IGD API. (The base URL is also depicted in the same file under the tag URLBase)
  6. Using the base URL and the WANPPPConnection link you can issue an HTTP query to the router that will add the UPnP rule.
  7. As a side note, the service depicted in the XML also includes a SCPDURL tag which is a link to another XML that depicts commands available for the service and their parameters. The package skips this stage as I assumed the query will be similar for many routers, this may very well not be the case, though, so it is up to you to check.
  8. From this stage the package will issue the service command using an HTTP query to the router. The actual query can be seen in the code quite clearly but for anyone interested: Headers:
"POST " + <link to service command from XML> + " HTTP/1.1"
"Content-Type: text/xml; charset=\"utf-8\""
"SOAPAction: \"urn:schemas-upnp-org:service:WANPPPConnection:1#AddPortMapping\""
"Content-Length: " + body.length()
Body:

"<?xml version=\"1.0\"?>\r\n"
"<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\" s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\">\r\n"
"<s:Body>\r\n"
"<u:AddPortMapping xmlns:u=\"urn:schemas-upnp-org:service:WANPPPConnection:1\">\r\n"
"  <NewRemoteHost></NewRemoteHost>\r\n"
"  <NewExternalPort>" + String(rulePort) + "</NewExternalPort>\r\n"
"  <NewProtocol>" + ruleProtocol + "</NewProtocol>\r\n"
"  <NewInternalPort>" + String(rulePort) + "</NewInternalPort>\r\n"
"  <NewInternalClient>" + ipAddressToString(ruleIP) + "</NewInternalClient>\r\n"
"  <NewEnabled>1</NewEnabled>\r\n"
"  <NewPortMappingDescription>" + ruleFriendlyName + "</NewPortMappingDescription>\r\n"
"  <NewLeaseDuration>" + String(ruleLeaseDuration) + "</NewLeaseDuration>\r\n"
"</u:AddPortMapping>\r\n"
"</s:Body>\r\n"
"</s:Envelope>\r\n";
I hope this helps.

Referenced from my answer here: https://stackoverflow.com/a/46267791/4295037

Detailed Document Released by UPnP Forum

http://upnp.org/specs/arch/UPnP-arch-DeviceArchitecture-v2.0.pdf

DDNS

You will also need a DDNS update service I use this https://github.com/ayushsharma82/EasyDDNS You can also see its usage in my example code PWM_LEDServer.ino

Special thanks

@ajwtech - for contributing to the package by noting the need to use constrolURL instead of eventSubURL

@Lan-Hekary - for improving the API

@GIPdA - for adding ESP32 support

tinyupnp's People

Contributors

lan-hekary avatar nullstalgia avatar ofekp avatar per1234 avatar toomone avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

tinyupnp's Issues

XML parsing fixes

Hello,

Found a small issue in the XML parsing that happens when the XML has multiple <serviceType> tags, like with my router.
It's just a matter of passing a "from" index to some String::indexOf() calls, and the right substring to getTagContent(). The issue might repeat elsewhere, I didn't checked everything. But it worked for me after this fix.

Line 702-ish in getIGDEventURLs(), TinyUPnP.cpp:

int service_type_index_start = 0;

int service_type_1_index = line.indexOf(UPNP_SERVICE_TYPE_TAG_START + UPNP_SERVICE_TYPE_1);
if (service_type_1_index >= 0) {
	service_type_index_start = service_type_1_index;
	service_type_1_index = line.indexOf(UPNP_SERVICE_TYPE_TAG_END, service_type_1_index);
}

int service_type_2_index = line.indexOf(UPNP_SERVICE_TYPE_TAG_START + UPNP_SERVICE_TYPE_2);
if (service_type_2_index >= 0) {
	service_type_index_start = service_type_2_index;
	service_type_2_index = line.indexOf(UPNP_SERVICE_TYPE_TAG_END, service_type_2_index);
}

if (!upnpServiceFound && service_type_1_index >= 0) {
	index_in_line += service_type_1_index;
	upnpServiceFound = true;
	deviceInfo->serviceTypeName = getTagContent(line.substring(service_type_index_start), UPNP_SERVICE_TYPE_TAG_NAME);
	debugPrintln(deviceInfo->serviceTypeName + " service found!");
	// will start looking for 'controlURL' now
} else if (!upnpServiceFound && service_type_2_index >= 0) {
	index_in_line += service_type_2_index;
	upnpServiceFound = true;
	deviceInfo->serviceTypeName = getTagContent(line.substring(service_type_index_start), UPNP_SERVICE_TYPE_TAG_NAME);
	debugPrintln(deviceInfo->serviceTypeName + " service found!");
	// will start looking for 'controlURL' now
}

ESP32 arduino with Ethernet.

I'am using the Ethernet library with my esp32. In the TinyUPnP.cpp file i replaced the calls for WiFi.localIP() and WiFi.gatewayIP() with ETH.localIP() and ETH.gatewayIP(). After that i commented out the wifi connectivity test inside the cpp file like this:

boolean TinyUPnP::testConnectivity(unsigned long startTime) {
    debugPrint(F("Testing WiFi connection for ["));
    debugPrint(ETH.localIP().toString());
    debugPrint("]");
    /*
    while (WiFi.status() != WL_CONNECTED) {
        if (_timeoutMs > 0 && startTime > 0 && (millis() - startTime > _timeoutMs)) {
            debugPrint(F(" ==> Timeout expired while verifying WiFi connection"));
            _wifiClient.stop();
            return false;
        }
        delay(200);
        debugPrint(".");
    }*/
    debugPrintln(" ==> GOOD");  // \n

    debugPrint(F("Testing internet connection"));
    _wifiClient.connect(connectivityTestIp, 80);
    while (!_wifiClient.connected()) {
        if (startTime + TCP_CONNECTION_TIMEOUT_MS > millis()) {
            debugPrintln(F(" ==> BAD"));
            _wifiClient.stop();
            return false;
        }
    }

    debugPrintln(F(" ==> GOOD"));
    _wifiClient.stop();
    return true;
}

I'am calling the setup function of the UPNP after i got an IP from ETH. Like this:

boolean Can_Init_UPNP = false;
void WiFiEvent(WiFiEvent_t event){
    switch(event) {
        case SYSTEM_EVENT_ETH_START:
            //set eth hostname here
            ETH_setHostname(hostName);
            break;
        case SYSTEM_EVENT_ETH_CONNECTED:
            //ethernet connected (if manual IP)
            //WiFi.enableIpV6();
            //tcpip_adapter_create_ip6_linklocal(TCPIP_ADAPTER_IF_ETH);
            break;
        case SYSTEM_EVENT_ETH_GOT_IP:
            ETH_Got_IP = true;
            Display_UI();
            vTaskDelete(ETH_Timeout_Task_Handle);
            Can_Init_UPNP = true;
            break;
        case SYSTEM_EVENT_ETH_DISCONNECTED:
            ETH_Got_IP = false;
            NoIp_Kiir();
            ETH_Ip_Timeout_Start();
            vTaskDelete(Weather_API_Task_Handle);
            vTaskDelete(HoliDay_API_Task_Handle);
            break;
        default:
            break;
    }
}

static const inline void Init_UPNP(int LISTEN_PORT, int LEASE_DURATION, String FRIENDLY_NAME){
    portMappingResult portMappingAdded;
    tinyUPnP->addPortMappingConfig(ETH_localIP(), LISTEN_PORT, RULE_PROTOCOL_TCP, LEASE_DURATION, FRIENDLY_NAME);
    portMappingAdded = tinyUPnP->commitPortMappings();
/*
    tinyUPnP->addPortMappingConfig(ETH_localIP(), LISTEN_PORT, RULE_PROTOCOL_TCP, LEASE_DURATION, FRIENDLY_NAME);
    while (portMappingAdded != SUCCESS && portMappingAdded != ALREADY_MAPPED) {
        portMappingAdded = tinyUPnP->commitPortMappings();
        if (portMappingAdded != SUCCESS && portMappingAdded != ALREADY_MAPPED) {
            tinyUPnP->printAllPortMappings();
            //Error_iras("This was printed because adding the required port mapping failed");
        }
    }
    portMappingAdded = tinyUPnP->commitPortMappings();*/
    //EasyDDNS.service("HITEC_MyHome");
    //EasyDDNS.client("HITEC", "admin", "admin");
}

static const inline void UPNP_Loop(){
    //EasyDDNS.update(300000);
    tinyUPnP->updatePortMappings(600000);
}

void loop() {
  ArduinoOTA.handle();
  if(Can_Init_UPNP){
    Can_Init_UPNP = false;
    Init_UPNP(80, 20000, "HITEC_MyHome");
  }
  UPNP_Loop();
}

And here is the DUMP that i got in a TXT file:
UPNP Dump.txt

LATEST esp crash exception separately:

Flushing the rest of the response
port [1900] actionPort [1900]
isGatewayInfoValid [192.168.10.1] port [1900] path [/igd.xml] actionPort [1900] actionPath [/ipc] serviceTypeName [urn:schemas-upnp-org:service:WANIP
Gateway info is valid
Verify port mapping for rule [HITEC_MyHome]
16e0ae:0x3ffb1e10 0x400efc9d:0x3ffb1e40 0x400efd35:0x3ffb1e60 0x400edd72:0x3ffb1e80 0x400ef3ee:0x3ffb1f10 0x400d9b49:0x3ffb1f50 0x400f2669:0x3ffb1fb0 0x40089525:0x3ffb1fd0
  #0  0x40154728:0x3ffb1dc0 in WiFiClientRxBuffer::read(unsigned char*, unsigned int) at C:\Users\Dr.Random\.platformio\packages\framework-arduinoespressif32\libraries\WiFi\src/WiFiClient.cpp:564
  #1  0x40154ae2:0x3ffb1de0 in WiFiClient::read(unsigned char*, unsigned int) at C:\Users\Dr.Random\.platformio\packages\framework-arduinoespressif32\libraries\WiFi\src/WiFiClient.cpp:564
  #2  0x4016e0ae:0x3ffb1e10 in WiFiClient::read() at C:\Users\Dr.Random\.platformio\packages\framework-arduinoespressif32\libraries\WiFi\src/WiFiClient.cpp:564
  #3  0x400efc9d:0x3ffb1e40 in Stream::timedRead() at C:\Users\Dr.Random\.platformio\packages\framework-arduinoespressif32\cores\esp32/Stream.cpp:76 
  #4  0x400efd35:0x3ffb1e60 in Stream::readStringUntil(char) at C:\Users\Dr.Random\.platformio\packages\framework-arduinoespressif32\cores\esp32/Stream.cpp:76
  #5  0x400edd72:0x3ffb1e80 in TinyUPnP::verifyPortMapping(_gatewayInfo*, _upnpRule*) at lib\TinyUPnP-3.1.4\src/TinyUPnP.cpp:1010
  #6  0x400ef3ee:0x3ffb1f10 in TinyUPnP::commitPortMappings() at lib\TinyUPnP-3.1.4\src/TinyUPnP.cpp:135
  #7  0x400d9b49:0x3ffb1f50 in loop() at src/Own_Headers/ModBus.h:279 (discriminator 1)
      (inlined by) loop() at src/main.cpp:26 (discriminator 1)
  #8  0x400f2669:0x3ffb1fb0 in loopTask(void*) at C:\Users\Dr.Random\.platformio\packages\framework-arduinoespressif32\cores\esp32/main.cpp:19       
  #9  0x40089525:0x3ffb1fd0 in vPortTaskWrapper at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/freertos/port.c:355 (discriminator 1)

Rebooting...

ERROR: Invalid router info, cannot continue

Dear,
Trying to make the example "SimpleServerESP32" to work on a ESP32 DevKit. It looks as if the router is not cooperating, see text below.
Tried on two different routers: a Docsis 3.0 (modem router) and a (old) TL-WR340G (WiFi router), both with uPnP enabled.
I am probably doing something wrong, any clues?
Many thanks, Jean.

PS. the line with "print mappings configured & current: " and following is my attempt to have some more info out of the router by inserting a tinyUPnP.printPortMappingConfig(); and a tinyUPnP.printAllPortMappings(); statement.

..........
Connected to testingRemoteHF
IP address: 192.168.1.101
Testing WiFi connection for [192.168.1.101] ==> GOOD
Testing internet connection ==> GOOD
isGatewayInfoValid [0.0.0.0] port [0] path [] actionPort [0] actionPath [] serviceTypeName []
Gateway info is not valid

Sending M-SEARCH to [239.255.255.250] Port [1900]
M-SEARCH * HTTP/1.1
HOST: 239.255.255.250:1900
MAN: "ssdp:discover"
MX: 5
ST: urn:schemas-upnp-org:device:InternetGatewayDevice:1

M-SEARCH sent
Timeout expired while waiting for the gateway router to respond to M-SEARCH message
ERROR: Invalid router info, cannot continue

UPnP done
MDNS responder started
HTTP server started
print mappings configured & current:
TinyUPnP configured port mappings:
0. testESP32 192.168.1.101 1237 1237 TCP 36000

isGatewayInfoValid [0.0.0.0] port [0] path [] actionPort [0] actionPath [] serviceTypeName []
Gateway info is not valid
Invalid router info, cannot continue
Updating port mapping
Testing WiFi connection for [192.168.1.101] ==> GOOD
Testing internet connection ==> GOOD
isGatewayInfoValid [0.0.0.0] port [0] path [] actionPort [0] actionPath [] serviceTypeName []
Gateway info is not valid

Stack overflow while reading xml

I am novice to C++ and embedded. In fact this is my first ESP8266 project. Tried to use your library and the board keep soft resetting, with the serial dumping stack.

Took me a while to track down where the stack get overflowed and trigger a soft reset.

I believe the call stack is commitPortMappings() ==> getGatewayInfo() ==> connectToIGD ==> debugPrint(line)

did the xml response exhausted my memory? Can we make it a more memory efficient as the xml can be quite huge, and I believe all you need is the URL base tag?
error.txt

printAllPortMapping only displays UPnP mappings

Is there a way to get a list of all port mappings? printAllPortMapping only shows those that were configured with UPnP. Any manually-mapped ports are not displayed (at least on my Fios router). See attached.
log
rules

Esp32cam UPnP and EasyDDNS to No-Ip no connection

So, i am trying to get a esp32cam module to run a web server via a LTE Router with UPnP. I have created a No-Ip Account and a hostname without ddns key for my project. The router has a working sim-card with internet flatrate. The problem is i am not getting a connection to no-ip and i have no idea, why. The code looks like this (UPnP Example):

/*
Note: This example includes the library EasyDDNS. You'll have to add this package using your Arduino Library Manager.
The purpose of this package is to publish your dynamic IP to a DDNS service that will allocate a human readable
address to your current IP. If you do not need that, you can remove this dependency.
*/

#include <WiFi.h>
#include <WiFiClient.h>
#include <WebServer.h>
#include <ESPmDNS.h>
#include <TinyUPnP.h>
#include <EasyDDNS.h> // see note above

const char* ssid = "";
const char* password = "";
#define LISTEN_PORT 2222 // http://:<LISTEN_PORT>/?name=
#define LEASE_DURATION 36000 // seconds
#define FRIENDLY_NAME "" // this name will appear in your router port forwarding section
#define DDNS_USERNAME ""
#define DDNS_PASSWORD ""
#define DDNS_DOMAIN ""

TinyUPnP tinyUPnP(20000); // -1 means blocking, preferably, use a timeout value (ms)
WebServer server(LISTEN_PORT);

const int led = 13;

void handleRoot() {
digitalWrite(led, 1);
server.send(200, "text/plain", "hello from esp32!");
digitalWrite(led, 0);
}

void handleNotFound() {
digitalWrite(led, 1);
String message = "File Not Found\n\n";
message += "URI: ";
message += server.uri();
message += "\nMethod: ";
message += (server.method() == HTTP_GET) ? "GET" : "POST";
message += "\nArguments: ";
message += server.args();
message += "\n";
for (uint8_t i = 0; i < server.args(); i++) {
message += " " + server.argName(i) + ": " + server.arg(i) + "\n";
}
server.send(404, "text/plain", message);
digitalWrite(led, 0);
}

void setup(void) {
pinMode(led, OUTPUT);
digitalWrite(led, 0);
Serial.begin(115200);
WiFi.mode(WIFI_STA);
WiFi.begin(ssid, password);
Serial.println("");

// Wait for connection
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.print("Connected to ");
Serial.println(ssid);
Serial.print("IP address: ");
Serial.println(WiFi.localIP());

boolean portMappingAdded = false;
tinyUPnP.addPortMappingConfig(WiFi.localIP(), LISTEN_PORT, RULE_PROTOCOL_TCP, LEASE_DURATION, FRIENDLY_NAME);
while (!portMappingAdded) {
portMappingAdded = tinyUPnP.commitPortMappings();
Serial.println("");

if (!portMappingAdded) {
  // for debugging, you can see this in your router too under forwarding or UPnP
  tinyUPnP.printAllPortMappings();
  Serial.println(F("This was printed because adding the required port mapping failed"));
  delay(30000);  // 30 seconds before trying again
}

}

Serial.println("UPnP done");

if (MDNS.begin("esp32")) {
Serial.println("MDNS responder started");
}

server.on("/", handleRoot);

server.on("/inline", {
server.send(200, "text/plain", "this works as well");
});

server.onNotFound(handleNotFound);

server.begin();
Serial.println("HTTP server started");

}

void loop(void) {

EasyDDNS.update(300000);

tinyUPnP.updatePortMappings(600000); // 10 minutes

server.handleClient();

delay(5);
}

I was not sure which port to use so i chose 2222 not sure if thats the way to go. As all the DDNS Definitions are not used in the code i copied the code from the EasyDDNS page into my code:

EasyDDNS.service("noip");
EasyDDNS.client("DDNS_DOMAIN", "DDNS_USERNAME", "DDNS_PASSWORD");

The esp boots normally and in the serial monitor the last three lines say "UPnP done, MDNS responder started, HTTP Server started". The UPnP stuff seems to work and i am not really sure what i am doing wrong. Can anyone point me in the right direction? Thanks

TCP timeout while retrieving port mappings (ERROR: While updating UPnP port mapping. Failed with error code [5])

Hi there,

I apologize in advance for opening yet a second issue, but I am encountering a different problem when using this library when on a different SSID (and thus different router).

The point where I'm hitting the error is right after connecting to the IGD, when I see the following error on the logs:
`TCP connection timeout while retrieving port mappings
called addPortMappingEntry
Connecting to IGD with host [192.168.1.1] port [80]
Connected to IGD
deviceInfo->actionPath []
deviceInfo->serviceTypeName []
Content-Length was: 546

5123TCP5123192.168.1.231semaforito36000

TCP connection timeout while adding a port mapping
Apply action [GetSpecificPortMappingEntry] on port mapping [semaforito]
Connecting to IGD with host [192.168.1.1] port [80]
Connected to IGD

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<s:Body>
<u:GetSpecificPortMappingEntry xmlns:u="">

5123
TCP
</u:GetSpecificPortMappingEntry>
</s:Body>
</s:Envelope>`

This is perpetuated and repeated every N seconds, thus limiting greatly the processing capacity of the ESP8266 - seems it is too focused on trying to sort out the UPnP so it does not do anything else :/

I am attaching to this issue a whole log of the initialisation of my server and the attempts TinyUPnP is doing, as well as the xmls it retrieves from the router.

I guess I need to do something about the line Apply action [GetSpecificPortMappingEntry] on port mapping [semaforito], but I am unsure how to do so, may I get some assistance??

BIG thanks in advance
RootDevice.xml.txt
WFADevice.xml.txt
LaCasaDeNemoErrorLog.txt

Error in UPnP ver. 3.1.4

Testing WiFi connection for [192.168.0.19] ==> GOOD
Testing internet connection ==> GOOD
isGatewayInfoValid [(IP unset)] port [0] path [] actionPort [0] actionPath [] serviceTypeName []
Gateway info is not valid

Sending M-SEARCH to [239.255.255.250] Port [1900]
M-SEARCH sent
Received packet of size [314] ip [192.168.0.1] port [1900]
UDP packet read bytes [314] out of [314]
Gateway packet content:
HTTP/1.1 200 OK
Cache-Control: max-age=1900
Location: http://192.168.0.1:80/RootDevice.xml
Server: UPnP/1.0 UPnP/1.0 UPnP-Device-Host/1.0
ST:urn:schemas-upnp-org:device:InternetGatewayDevice:1
USN: uuid:upnp-InternetGatewayDevice-1_0-083e5d4e849c::urn:schemas-upnp-org:device:InternetGatewayDevice:1
EXT:

INTERNET_GATEWAY_DEVICE found
IGD location found [http://192.168.0.1:80/RootDevice.xml]
192.168.0.1
80
/RootDevice.xml
Connecting to IGD with host [192.168.0.1] port [80]
Connected to IGD
called getIGDEventURLs
deviceInfo->actionPath [] deviceInfo->path [/RootDevice.xml]
TCP connection timeout while executing getIGDEventURLs
called getIGDEventURLs
deviceInfo->actionPath [] deviceInfo->path [/RootDevice.xml]
TCP connection timeout while executing getIGDEventURLs
called getIGDEventURLs
deviceInfo->actionPath [] deviceInfo->path [/RootDevice.xml]
TCP connection timeout while executing getIGDEventURLs
Timeout expired while adding a new port mapping
ERROR: Invalid router info, cannot continue

isGatewayInfoValid [192.168.0.1] port [80] path [/RootDevice.xml] actionPort [80] actionPath [] serviceTypeName []
Gateway info is valid

I had already tested this library on an esp8266 to open the ports of a router. Now I am on another router (home like) and I get this error. I tried to delete a debugPrint(line); that a user had used but it didn't change. Thank you for your answer I am desperate for solutions :)

Line of code:

portMappingResult portMappingAdded;
//Setting router ports by UPnP
tinyUPnP.addPortMappingConfig(WiFi.localIP(), LISTEN_PORT, RULE_PROTOCOL_TCP, LEASE_DURATION, FRIENDLY_NAME);
while (portMappingAdded != SUCCESS && portMappingAdded != ALREADY_MAPPED) {
portMappingAdded = tinyUPnP.commitPortMappings();
Serial.println("");

if (portMappingAdded != SUCCESS && portMappingAdded != ALREADY_MAPPED) {
 
  tinyUPnP.printAllPortMappings();
  Serial.println(F("Port mapping failed"));
  delay(30000);  // 30 seconds
}

}

Serial.println("Port forwarding done");
Consts:
#define LISTEN_PORT 2400
#define LEASE_DURATION 36000
#define FRIENDLY_NAME "HidroSrv"

WDT Problem!!!

I installed the library but it shows with INCOMPATIVEL in the examples.
But, I opened the example and tried to use.
But can not find the libraries: ESP8266Ping.h and EasyDDNS, are they really necessary?
It would be better to make a simpler example. (Suggestion)
Even so after some work I was able to find and install the two libraries.
Then I was able to record the ESP and it did not work, stopped at a certain point that generates an excess of whatcdog and restarts the microcontroller.
I believe he is doing a blocking code and does not reset the WDT in time and it ends up restarting the ESP.
So, it's not working.
I'm using esp8266 (node MCU)

Here is the LOG:

Starting...
connectWiFi
......
Connected to WIFI-B240
IP address: 192.168.25.111
Testing WiFi connection for [192.168.25.111] ==> GOOD
Testing internet connection ==> GOOD
isGatewayInfoValid [0.0.0.0] port [0] path [] actionPort [0] actionPath [] serviceTypeName []
Gateway info is not valid

Sending M-SEARCH to [239.255.255.250] Port [1900]

Exception (3):
epc1=0x4020f3d8 epc2=0x00000000 epc3=0x40000f68 excvaddr=0x4024248a depc=0x00000000

ctx: cont
sp: 3fff4b00 end: 3fff4df0 offset: 01a0

stack:
3fff4ca0: 3fff3a78 3ffef0e8 3fff3d08 4020a6cf
3fff4cb0: 401071e0 faffffef 00000000 401071e0
3fff4cc0: 6f19a8c0 00006e7a 3fff4cf0 40100690
3fff4cd0: 3ffe88a9 00000163 00000163 00000001
3fff4ce0: 3fff3d08 00006e7a 3ffef0b8 4020bd3c
3fff4cf0: 00000000 00000000 00000000 4020c8a0
3fff4d00: 3ffef0b8 3ffef118 3fff3d08 40209f26
3fff4d10: 3ffef118 00000000 00000000 401071e0
3fff4d20: 00000000 3fff4d80 3fff4d80 00006e7a
3fff4d30: 3ffef118 3ffef0b8 3ffef0b8 4020bef7
3fff4d40: 3fff3ce4 0000018d 3fff3dd0 3ffef0b8
3fff4d50: 3fff3d08 3ffef180 4020d50c 3fff3dd0
3fff4d60: 3ffe8919 00ffffff 3fff3ce8 3ffef180
3fff4d70: 3fff3d08 3ffef0b8 3fff3ce8 40202a99
3fff4d80: 00000000 00000000 00000000 feefeffe
3fff4d90: 00000000 00000000 00000000 401071e0
3fff4da0: 6f19a8c0 feefeffe feefeffe feefeffe
3fff4db0: feefeffe feefeffe feefeffe feefeffe
3fff4dc0: feefeffe feefeffe feefeffe 3fff3dc8
3fff4dd0: 3fffdad0 00000000 3fff3dc1 4020d550
3fff4de0: feefeffe feefeffe 3fff3dd0 40100710
stack.

ets Jan 8 2013,rst cause:2, boot mode:(1,6)

ets Jan 8 2013,rst cause:4, boot mode:(1,6)

wdt reset

TinyUPNP library makes my esp8266 crash and reset

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

Gateway info is not valid

Hello, i'm trying to stablish an open port with the tinyupnp with my esp32 but it doesn't work no more and im not able to find out what is going on. I hope you can help me.
My guess is that the root of the problem is that the info sent by the router is not being understood by the esp, any thougths?

1

ESP32 support - crashs

Adding ESP32 support, I forked here: https://github.com/GIPdA/TinyUPnP/tree/esp32Support

It is working most of the time, when it doesn't crash.
It can crash and reboot several times (variable, 1 to 5 in my few tests, always in the same spot) and eventually it make it through the setup and runs the loop without crashing.

Here is the crash report:
crash.txt

I guess it is probably a heap/stack overflow.
The fact that each readStringUntil returns a String without any size check isn't very safe. In my case, it can buffer up to 4k characters (shouldn't run out of space with the simple example on the ESP32 though, but still).

I monitored the free heap size before crash (ESP.getFreeHeap()) and there were still plenty of space (~ 260000 bytes). Seems unlikely that memory fragmentation could be an issue here?

Also, the Arduino ESP32 is using FreeRTOS, so it might be related to that. Not sure exactly how stack & heap is handled under the hood (in a task), and the crash report isn't very helpful, I find.

Finally, enabling debug prints makes it crash very fast, every time. Certainly a memory issue. Need to comment most of the debugs to avoid the crash.

WANIPConnection - WANPPPConnection

there are explicit uses of the WANPPPConnection service even if if the serviceTypeName is WANIPConnection, I suggest to replace:

strcat_P(body_tmp, PSTR(" xmlns:u=\"urn:schemas-upnp-org:service:WANPPPConnection:1\">\r\n<NewRemoteHost></NewRemoteHost>\r\n<NewExternalPort>"));

with:

 strcat_P(body_tmp, PSTR(" xmlns:u=\""));
 strcat_P(body_tmp, deviceInfo->serviceTypeName.c_str());
 strcat_P(body_tmp, PSTR("\">\r\n<NewRemoteHost></NewRemoteHost>\r\n<NewExternalPort>"));

and:
_wifiClient.print(F("SOAPAction: \"urn:schemas-upnp-org:service:WANPPPConnection:1#"));

with:

_wifiClient.print(F("SOAPAction: \""));
_wifiClient.print(deviceInfo->serviceTypeName);
_wifiClient.print(F("#"));

also my router responds with service "WANIPConnection:2"
I swapped 1 in 2 in:

const String UPNP_SERVICE_TYPE_2 = "urn:schemas-upnp-org:service:WANIPConnection:1";

it worked for me, but I don't think it's the right solution

Gateway info not valid

When using this library I keep on getting this error.
Is there a possibility to have an example of the 'LISTEN_PORT' because I do not clearly understand how thats works and I do not find any other examples than the 2 you have made.

Example: http://:<LISTEN_PORT>/?percentage=<0..100>
Mine: http://192.168.43.46:80/?percentage=20
What am I doing wrong?

image

Timeout expired while waiting for the gateway router to respond to M-SEARCH message

Hi, I'm trying for the first time the code and of course I'm not lucky! :-(
I checked other open issues but find no help. :-(
I'm not expert with the UPnP protocol so it's even hard for me to understand which part may be wrong in the output.
Facts I know:

  1. I can confirm you that 192.168.1.1 is correct IP of the router.
  2. The router has UPnP enabled (because it's selected and also because some software is using it)
  3. I tried with 3 different "LISTEN_PORT"s: 43210, then 1900, then 11900. The output that follows it's always the same but if I check on the router I can find an active UPnP rule set to my IP for port 43210

Protocol | WAN Port | LAN Port | Destination | Description
TCP | 43210 | 43210 | 192.168.1.108 | DAIKIN-BRIDGE

As if the router accepted first request and then stop!
Any clue?

Thank you so much!!

Starting...
connectWiFi
.......
Connected to SSID_NAME_IS_CORRECT
IP address: 192.168.1.108
Testing WiFi connection for [192.168.1.108] ==> GOOD
Testing internet connection ==> GOOD
isGatewayInfoValid [(IP unset)] port [0] path [] actionPort [0] actionPath [] serviceTypeName []
Gateway info is not valid

Sending M-SEARCH to [239.255.255.250] Port [1900]
M-SEARCH * HTTP/1.1
HOST: 239.255.255.250:1900
MAN: "ssdp:discover"
MX: 2
ST: urn:schemas-upnp-org:device:InternetGatewayDevice:1
USER-AGENT: unix/5.1 UPnP/2.0 TinyUPnP/1.0


M-SEARCH packet length is [181]
endPacketRes [1]
M-SEARCH * HTTP/1.1
HOST: 239.255.255.250:1900
MAN: "ssdp:discover"
MX: 2
ST: urn:schemas-upnp-org:device:InternetGatewayDevice:2
USER-AGENT: unix/5.1 UPnP/2.0 TinyUPnP/1.0


M-SEARCH packet length is [181]
endPacketRes [1]
M-SEARCH * HTTP/1.1
HOST: 239.255.255.250:1900
MAN: "ssdp:discover"
MX: 2
ST: urn:schemas-upnp-org:service:WANIPConnection:1
USER-AGENT: unix/5.1 UPnP/2.0 TinyUPnP/1.0


M-SEARCH packet length is [176]
endPacketRes [1]
M-SEARCH * HTTP/1.1
HOST: 239.255.255.250:1900
MAN: "ssdp:discover"
MX: 2
ST: urn:schemas-upnp-org:service:WANIPConnection:2
USER-AGENT: unix/5.1 UPnP/2.0 TinyUPnP/1.0


M-SEARCH packet length is [176]
endPacketRes [1]
M-SEARCH * HTTP/1.1
HOST: 239.255.255.250:1900
MAN: "ssdp:discover"
MX: 2
ST: urn:schemas-upnp-org:service:WANPPPConnection:1
USER-AGENT: unix/5.1 UPnP/2.0 TinyUPnP/1.0


M-SEARCH packet length is [177]
endPacketRes [1]
M-SEARCH packets sent
Gateway IP [192.168.1.1]
Timeout expired while waiting for the gateway router to respond to M-SEARCH message
ERROR: Invalid router info, cannot continue

isGatewayInfoValid [(IP unset)] port [0] path [] actionPort [0] actionPath [] serviceTypeName []
Gateway info is not valid
Invalid router info, cannot continue
This was printed because adding the required port mapping failed

Gateway info is not valid

Greeting,
i tried to use your libraries to test on my esp32 and somehow end up with this error. I've tried with 2 different router, 1 is my ASUS TM- AC 1900 and the other is my Samsung S7 Mobile HotSpot and Tethering. I've double checked on the require "filled_in" info and tried with different listen port, also tried to change the LEASE_DURATION. Please help i'm getting lost...

error_UPNP

Request - help to get gateway traffic stats

Hello
I used miniupnpc library test client to get stats on my router. Below the results:

Found valid IGD : http://192.168.0.1:49152/upnp/control/WANIPConn1
Local LAN ip address : 192.168.0.72
Connection Type : IP_Routed
Status : Connected, uptime=1517831539s, LastConnectionError : ERROR_NONE
Time started : Fri Jan 1 01:00:28 1971
MaxBitRateDown : 512000 bps (512 Kbps) MaxBitRateUp 512000 bps (512 Kbps)
ExternalIPAddress = 62...***
Bytes: Sent: 128253133 Recv: 707471898
Packets: Sent: 25654392 Recv: 33017045

How can I use your library to get the last two rows of data?
below the xml schema of my router:

<scpd xmlns="urn:schemas-upnp-org:service-1-0">
<specVersion>
<major>1</major>
<minor>0</minor>
</specVersion>
<actionList>
<action>
<name>GetCommonLinkProperties</name>
<argumentList>
<argument>
<name>NewWANAccessType</name>
<direction>out</direction>
<relatedStateVariable>WANAccessType</relatedStateVariable>
</argument>
<argument>
<name>NewLayer1UpstreamMaxBitRate</name>
<direction>out</direction>
<relatedStateVariable>Layer1UpstreamMaxBitRate</relatedStateVariable>
</argument>
<argument>
<name>NewLayer1DownstreamMaxBitRate</name>
<direction>out</direction>
<relatedStateVariable>Layer1DownstreamMaxBitRate</relatedStateVariable>
</argument>
<argument>
<name>NewPhysicalLinkStatus</name>
<direction>out</direction>
<relatedStateVariable>PhysicalLinkStatus</relatedStateVariable>
</argument>
</argumentList>
</action>
<action>
<name>GetTotalBytesSent</name>
<argumentList>
<argument>
<name>NewTotalBytesSent</name>
<direction>out</direction>
<relatedStateVariable>TotalBytesSent</relatedStateVariable>
</argument>
</argumentList>
</action>
<action>
<name>GetTotalBytesReceived</name>
<argumentList>
<argument>
<name>NewTotalBytesReceived</name>
<direction>out</direction>
<relatedStateVariable>TotalBytesReceived</relatedStateVariable>
</argument>
</argumentList>
</action>
<action>
<name>GetTotalPacketsSent</name>
<argumentList>
<argument>
<name>NewTotalPacketsSent</name>
<direction>out</direction>
<relatedStateVariable>TotalPacketsSent</relatedStateVariable>
</argument>
</argumentList>
</action>
<action>
<name>GetTotalPacketsReceived</name>
<argumentList>
<argument>
<name>NewTotalPacketsReceived</name>
<direction>out</direction>
<relatedStateVariable>TotalPacketsReceived</relatedStateVariable>
</argument>
</argumentList>
</action>
</actionList>
<serviceStateTable>
<stateVariable sendEvents="no">
<name>WANAccessType</name>
<dataType>string</dataType>
<allowedValueList>
<allowedValue>DSL</allowedValue>
<allowedValue>POTS</allowedValue>
<allowedValue>Cable</allowedValue>
<allowedValue>Ethernet</allowedValue>
<allowedValue>Other</allowedValue>
</allowedValueList>
</stateVariable>
<stateVariable sendEvents="no">
<name>Layer1UpstreamMaxBitRate</name>
<dataType>ui4</dataType>
</stateVariable>
<stateVariable sendEvents="no">
<name>Layer1DownstreamMaxBitRate</name>
<dataType>ui4</dataType>
</stateVariable>
<stateVariable sendEvents="yes">
<name>PhysicalLinkStatus</name>
<dataType>string</dataType>
<allowedValueList>
<allowedValue>Up</allowedValue>
<allowedValue>Down</allowedValue>
<allowedValue>Initializing</allowedValue>
<allowedValue>Unavailable</allowedValue>
</allowedValueList>
</stateVariable>
<stateVariable sendEvents="no">
<name>WANAccessProvider</name>
<dataType>string</dataType>
</stateVariable>
<stateVariable sendEvents="no">
<name>MaximumActiveConnections</name>
<dataType>ui2</dataType>
<allowedValueRange>
<minimum>1</minimum>
<maximum/>
<step>1</step>
</allowedValueRange>
</stateVariable>
<stateVariable sendEvents="no">
<name>TotalBytesSent</name>
<dataType>ui4</dataType>
</stateVariable>
<stateVariable sendEvents="no">
<name>TotalBytesReceived</name>
<dataType>ui4</dataType>
</stateVariable>
<stateVariable sendEvents="no">
<name>TotalPacketsSent</name>
<dataType>ui4</dataType>
</stateVariable>
<stateVariable sendEvents="no">
<name>TotalPacketsReceived</name>
<dataType>ui4</dataType>
</stateVariable>
</serviceStateTable>
</scpd>

Any help would be appreciated
many thanks

connect to local server with public ip

Hello,
I create a webserver, with wifi connection that the user can select. I want to have access to that web server without the need to being connected on the same network, with a public ip. This can be done with port forwarding.
Is this possible with UPnP and this library?
Thank you in advance!

Device is not discovered by UPnP Browser app.

Hi buddies!

I'm trying to make my device discoverable by other nodes in the network using UPnP. For this purpose, I used UPnP Browser which is an android app to discover device ESP32. I've programmed ESP32 with SimpleServerESP32 example.

I can see that sometimes UPnP packets are sent from ESP32 but it does not suffice to be discoverable by the UPnP Browser app.

So my question is that does this library implement the discovery phase of protocol thoroughly?

Thanks in advance!
A. Salehy

Cannot detect NOTIFY packets

Hi, I am using your library to discover a gateway. Facing an issue when the MSEARCH packet is sent out to [239.255.255.250] Port [1900], it only proceeds further on MSEARCH response packet and waits till it gets it (Precisely this function waitForUnicastResponseToMSearch()) However, I need it to also listen for NOTIFY packets in the function which is sent out by the gateway at regular intervals.

I can see the notify packets from the gateway over other SSDP listeners. How can you enable listening to not only Msearch response packets but also notify packets in this library?

Invalid router info

Been trying to get this to work using an Wemos D1 Mini (ESP8266), IGD connection goes well then drops the ball and TCP connection times out. Using latest master (cd9771c)

21:01:38.043 -> [INFO] MDNS setup is successful!
21:01:38.077 -> [INFO] Http Station server started
21:01:38.110 -> Testing WiFi connection for [192.168.0.134] ==> GOOD
21:01:38.178 -> Testing internet connection ==> GOOD
21:01:38.760 -> isGatewayInfoValid [(IP unset)] port [0] path [] actionPort [0] actionPath [] serviceTypeName []
21:01:38.861 -> Gateway info is not valid
21:01:38.895 -> 
21:01:38.895 -> Sending M-SEARCH to [239.255.255.250] Port [1900]
21:01:38.930 -> M-SEARCH * HTTP/1.1
21:01:38.964 -> HOST: 239.255.255.250:1900
21:01:38.997 -> MAN: "ssdp:discover"
21:01:39.031 -> MX: 5
21:01:39.031 -> ST: urn:schemas-upnp-org:device:InternetGatewayDevice:1
21:01:39.102 -> 
21:01:39.102 -> 
21:01:39.102 -> M-SEARCH sent
21:01:39.102 -> Received packet of size [443] ip [192.168.0.1] port [1900]
21:01:39.169 -> UDP packet read bytes [443] out of [443]
21:01:39.202 -> Gateway packet content:
21:01:39.240 -> HTTP/1.1 200 OK
21:01:39.273 -> CACHE-CONTROL: max-age=3600
21:01:39.307 -> ST: urn:schemas-upnp-org:device:InternetGatewayDevice:1
21:01:39.307 -> USN: uuid:30343438-3030-3000-0000-1835d1a8dec5::urn:schemas-upnp-org:device:InternetGatewayDevice:1
21:01:39.446 -> EXT:
21:01:39.446 -> SERVER: RedHatEnterpriseServer/6.10 UPnP/1.1 MiniUPnPd/1.9
21:01:39.512 -> LOCATION: http://192.168.0.1:5000/rootDesc.xml
21:01:39.546 -> OPT: "http://schemas.upnp.org/upnp/1/0/"; ns=01
21:01:39.613 -> 01-NLS: 1585848159
21:01:39.613 -> BOOTID.UPNP.ORG: 1585848159
21:01:39.646 -> CONFIGID.UPNP.ORG: 1337
21:01:39.680 -> 
21:01:39.680 -> 
21:01:39.680 -> INTERNET_GATEWAY_DEVICE found
21:01:39.713 -> IGD location found [http://192.168.0.1:5000/rootDesc.xml]
21:01:39.782 -> 192.168.0.1
21:01:39.782 -> 5000
21:01:39.819 -> /rootDesc.xml
21:01:39.819 -> Connecting to IGD with host [192.168.0.1] port [5000]
21:01:39.961 -> Connected to IGD
21:01:39.961 -> called getIGDEventURLs
21:01:39.995 -> deviceInfo->actionPath [] deviceInfo->path [/rootDesc.xml]
21:01:40.195 -> HTTP/1.1 200 OK
21:01:40.195 -> Content-Type: text/xml; charset="utf-8"
21:01:40.228 -> Connection: close
21:01:40.261 -> Content-Length: 2619
21:01:40.261 -> Server: RedHatEnterpriseServer/6.10 UPnP/1.1 MiniUPnPd/1.9
21:01:40.330 -> Ext:
21:01:40.330 -> 
21:01:40.330 -> <?xml version="1.0"?>
21:01:45.280 -> <root xmlns="urn:schemas-upnp-org:device-1-0" configId="1337"><specVersion><major>1</major><minor>1</minor></specVersion><device><deviceType>urn:schemas-upnp-org:device:InternetGatewayDevice:1</deviceType><friendlyName>ARRIS TG2492LG-85 Router</friendlyName><manufacturer>ARRIS</manufacturer><manufacturerURL>http://www.arrisi.com/</manufacturerURL><modelDescription>ARRIS TG2492LG-85 Router</modelDescription><modelName>ARRIS TG2492LG-85 Router</modelName><modelNumber>4.5.5.44_0410</modelNumber><modelURL>http://www.arrisi.com/</modelURL><serialNumber>AAAP90448000</serialNumber><UDN>uuid:30343438-3030-3000-0000-1835d1a8dec5</UDN><serviceList><service><serviceType>urn:schemas-upnp-org:service:Layer3Forwarding:1</serviceType><serviceId>urn:upnp-org:serviceId:L3Forwarding1</serviceId><SCPDURL>/L3F.xml</SCPDURL><controlURL>/ctl/L3F</controlURL><eventSubURL>/evt/L3F</eventSubURL></service></serviceList><deviceList><device><deviceType>urn:schemas-upnp-org:device:WANDevice:1</deviceType><friendlyName>WANDevice</friendlyName><manufacturer>ARRIS</manufacturer><manufacturerURL>http://www.arrisi.com/</manufacturerURL><modelDescription>WANDevice</modelDescription><modelName>WANDevice</modelName><modelNumber>20190410</modelNumber><modelURL>http://www.arrisi.com/</modelURL><serialNumber>AAAP90448000</serialNumber><UDN>uuid:30343438-3030-3000-0000-1835d1a8dec6</UDN><UPC>TG2492LG-85</UPC><serviceList><service><serviceType>urn:schemas-upnp-org:service:WANCommonInterfaceConfig:1</serviceType><serviceId>urn:upnp-org:serviceId:WANCommonIFC1</serviceId><SCPDURL>/WANCfg.xml</SCPDURL><controlURL>/ctl/CmnIfCfg</controlURL><eventSubURL>/evt/CmnIfCfg</eventSubURL></service></serviceList><deviceList><device><deviceType>urn:schemas-upnp-org:device:WANConnectionDevice:1</deviceType><friendlyName>WANConnectionDevice</friendlyName><manufacturer>ARRIS</manufacturer><manufacturerURL>http://www.arrisi.com/</manufacturerURL><modelDescription>Residential Gateway</modelDescription><modelName>TG2492LG-85</modelName><modelNumber>20190410</modelNumber><modelURL>http://www.arrisi.com/</modelURL><serialNumber>AAAP90448000</serialNumber><UDN>uuid:30343438-3030-3000-0000-1835d1a8dec7</UDN><UPC>TG2492LG-85</UPC><serviceList><service><serviceType>urn:schemas-upnp-org:service:WANIPConnection:1</serviceType><serviceId>urn:upnp-org:serviceId:WANIPConn1</serviceId><SCPDURL>/WANIPCn.xml</SCPDURL><controlURL>/ctl/IPConn</controlURL><eventSubURL>/evt/IPConn</eventSubURL></service></serviceList></device></deviceList></device></deviceList><presentationURL>http://192.168.0.1/</presentationURL></device></root>called getIGDEventURLs
21:01:48.370 -> deviceInfo->actionPath [] deviceInfo->path [/rootDesc.xml]
21:01:54.370 -> TCP connection timeout while executing getIGDEventURLs
21:01:54.849 -> called getIGDEventURLs
21:01:54.849 -> deviceInfo->actionPath [] deviceInfo->path [/rootDesc.xml]
21:02:00.846 -> TCP connection timeout while executing getIGDEventURLs
21:02:00.879 -> Timeout expired while adding a new port mapping
21:02:00.947 -> ERROR: Invalid router info, cannot continue
21:02:00.981 -> 

Any help is appreciated :)

Publish the library to Arduino Library Manager

As suggested by @lucasromeiro in #14:

What do you think about simplifying it to make it more professional to get into Library Manager?
I can help you!
I already did that and I have a library there.
I like to do this because like me, there are many other people who need ...
The goal is to make it as simple as possible. And efficient!
People love simple things that work well.
If you accept, we can:

List of things to do:

    • Take all Prints in the serial and by a #define that enables them.
    • By return in this unique function so that the user knows when everything is OK or if he had some type of problem.
    • Take as much dependence from other libraries as possible.
    • Add these 3 functions to one (EasyDDNS.update (300000); tinyUPnP.updatePortMapping (600000, & connectWiFi); server.handleClient ();)
    • Make a non-blocking code without delay if possible. For other functions can occur in parallel.
    • Verify that the request parameters (GET and POST) are all present.
    • Optimize memory.
    • Test on other routers

M-SEARCH timeout

Sometimes timeout can occur before InternetGatewayDevice detection, especially in networks with many UPnP devices

INTERNET_GATEWAY_DEVICE was not found
Timeout expired while waiting for the gateway router to respond to M-SEARCH message
ERROR: Invalid router info, cannot continue

To solve the issue and make communication with the right device more efficient I propose to change the M-SEARCH Search Target (ST) by replacing

strcat_P(body_tmp, PSTR("ST: ssdp:all\r\n\r\n"));

with

strcat_P(body_tmp, PSTR("ST: urn:schemas-upnp-org:device:InternetGatewayDevice:1\r\n"));

as specified in http://upnp.org/specs/arch/UPnP-arch-DeviceArchitecture-v1.1.pdf (PDF pag38 ~ printed pag31)

PWM_LEDServer example not compiling

Hello,

the pwm_ledserver example is not compiling on my machine.
i am using esp82266, arduino framework 2.5.0.

error is
'class TinyUPnP' has no member named 'updatePortMapping'

when calling function tinyUPnP.updatePortMapping(600000, &connectWiFi); in loop

Auto-select LISTEN_PORT

This is more of a feature request than an issue.

It would be great if we (well, you actually) could automatically select a LISTEN_PORT that is free/available instead of having to manually select one.

Option for both local and external port (with code)

Currently this library seems only to support one port number for both local external. It would be nice to be able to specifiy both an internal and external port.

E.g. I'm running a web server at machine X which should me accessible on outside port 80. Also, I'm running an IOT project which runs on port 80 (local), but should have a different external port.

I'm running a modified version of the TinyUPNP library myself, with a couple of little changes:

TinyUPnP.cpp

line 54 from:

void TinyUPnP::addPortMappingConfig(IPAddress ruleIP, int rulePort, String ruleProtocol, int ruleLeaseDuration, String ruleFriendlyName)

to:

void TinyUPnP::addPortMappingConfig(IPAddress ruleIP, int internalPort, int externalPort, String ruleProtocol, int ruleLeaseDuration, String ruleFriendlyName) {

line 59 from:

newUpnpRule->internalPort = rulePort;

to:

newUpnpRule->internalPort = internalPort;

line 60 from:

newUpnpRule->externalPort = rulePort;

to

newUpnpRule->externalPort = externalPort;

line 436 from:

sprintf(integer_string, "%d", rule_ptr->internalPort);

to:

sprintf(integer_string, "%d", rule_ptr->externalPort);

line 810 from:

sprintf(integer_string, "%d", rule_ptr->internalPort);

to:

sprintf(integer_string, "%d", rule_ptr->externalPort);

TinyUPnP.h

line 107 from:

void addPortMappingConfig(IPAddress ruleIP /* can be NULL */, int rulePort, String ruleProtocol, int ruleLeaseDuration, String ruleFriendlyName);

to:

void addPortMappingConfig(IPAddress ruleIP /* can be NULL */ ,int internalPort, int externalPort, String ruleProtocol, int ruleLeaseDuration, String ruleFriendlyName);

Tested and working on my ESP8266 firmware.

UPnP Errors 714 and 718

Hi, I'm trying to use this library on my ESP8266, but I am getting some error on it, attaching the logs I get.

After some different M-SEARCH messages (I understand it is trying to find the correct one), I see there is a response from my router to the controller.
Then, I guess it checks if the UPnP entry has been inputted, and gets a 714 response (I've found it means "No such entry in array").
Following, I see the controller tries to add a new entry (addPortMappingEntry), and gets a 718 response ("mapping already exists").

I've checked on the router settings and I don't see any UPnP entry created by the controller, so I don't know what is happening.

Is this an issue on TinyUPnP? Can I get some assistance?

Library version: #65
Microcontroller: WeMos D1 R1 with ESP8266
Router: Sagemcom Livebox F@st 5656

Thank you!

debugUPnP.txt

Invalid router info

Trying this out on the esp8266 and I get the "Invalid router info, cannot continue" message when I give it a time out. Looking at the source code, there are three conditions that lead to this but I'm not sure which one is mine. below is the output from the program. UPnP is enabled because I can get it to work with pythons miniUPnP.

Connected to network
IP address: 192.168.0.122
Sending M-SEARCH to [4211081199] Port [1900]
M-SEARCH sent
Received packet of size [260] ip [192.168.0.1] port [1900]
Gateway packet content:
HTTP/1.1 200 OK
CACHE-CONTROL: max-age=100
DATE: Sat, 16 Jun 2018 22:32:09 GMT
EXT:
LOCATION: http://192.168.0.1:1900/igd.xml
SERVER: ipos/7.0 UPnP/1.0 TL-WR841N/9.0
ST: upnp:rootdevice
USN: uuid:060b7353-fca6-4070-85f4-1fbfb9add62c::upnp:rootdevic
Received packet of size [269] ip [192.168.0.1] port [1900]
Gateway packet content:
HTTP/1.1 200 OK
CACHE-CONTROL: max-age=100
DATE: Sat, 16 Jun 2018 22:32:09 GMT
EXT:

LOCATION: http://192.168.0.1:1900/igd.xml
SERVER: ipos/7.0 UPnP/1.0 TL-WR841N/9.0
ST: uuid:060b7353-fca6-4070-85f4-1fbfb9add62c
USN: uuid:060b7353-fca6-4070-85f4-1f
Received packet of size [332] ip [192.168.0.1] port [1900]
Gateway packet content:
HTTP/1.1 200 OK
CACHE-CONTROL: max-age=100
DATE: Sat, 16 Jun 2018 22:32:09 GMT
EXT:
LOCATION: http://192.168.0.1:1900/igd.xml
SERVER: ipos/7.0 UPnP/1.0 TL-WR841N/9.0
ST: urn:schemas-upnp-org:device:InternetGatewayDevice:1
USN: uuid:060b7353-fca6-40
Received packet of size [324] ip [192.168.0.1] port [1900]
Gateway packet content:
HTTP/1.1 200 OK
CACHE-CONTROL: max-age=100
DATE: Sat, 16 Jun 2018 22:32:09 GMT
EXT:
LOCATION: http://192.168.0.1:1900/igd.xml
SERVER: ipos/7.0 UPnP/1.0 TL-WR841N/9.0
ST: urn:schemas-upnp-org:service:Layer3Forwarding:1
USN: uuid:060b7353-fca6-4070-8
Received packet of size [269] ip [192.168.0.1] port [1900]
Gateway packet content:
HTTP/1.1 200 OK
CACHE-CONTROL: max-age=100
DATE: Sat, 16 Jun 2018 22:32:10 GMT
EXT:
LOCATION: http://192.168.0.1:1900/igd.xml
SERVER: ipos/7.0 UPnP/1.0 TL-WR841N/9.0
ST: uuid:254e9977-8964-49f3-b8d5-51acb7bd40fc
USN: uuid:254e9977-8964-49f3-b8d5-51
Received packet of size [308] ip [192.168.0.1] port [1900]
Gateway packet content:
HTTP/1.1 200 OK
CACHE-CONTROL: max-age=100
DATE: Sat, 16 Jun 2018 22:32:10 GMT
EXT:
LOCATION: http://192.168.0.1:1900/igd.xml
SERVER: ipos/7.0 UPnP/1.0 TL-WR841N/9.0
ST: urn:schemas-upnp-org:device:WANDevice:1
USN: uuid:254e9977-8964-49f3-b8d5-51ac
Received packet of size [340] ip [192.168.0.1] port [1900]
Gateway packet content:
HTTP/1.1 200 OK
CACHE-CONTROL: max-age=100
DATE: Sat, 16 Jun 2018 22:32:10 GMT
EXT:

OCATION: http://192.168.0.1:1900/igd.xml
SERVER: ipos/7.0 UPnP/1.0 TL-WR841N/9.0
ST: uuid:9f0865b3-f5da-4ad5-85b7-7404637fdf37
USN: uuid:9f0865b3-f5da-4ad5-85b7-74
Received packet of size [328] ip [192.168.0.1] port [1900]
Gateway packet content:
HTTP/1.1 200 OK
CACHE-CONTROL: max-age=100
DATE: Sat, 16 Jun 2018 22:32:10 GMT
EXT:
LOCATION: http://192.168.0.1:1900/igd.xml
SERVER: ipos/7.0 UPnP/1.0 TL-WR841N/9.0
ST: urn:schemas-upnp-org:device:WANConnectionDevice:1
USN: uuid:9f0865b3-f5da-4ad5
Received packet of size [322] ip [192.168.0.1] port [1900]
Gateway packet content:
HTTP/1.1 200 OK
CACHE-CONTROL: max-age=100
DATE: Sat, 16 Jun 2018 22:32:10 GMT
EXT:
LOCATION: http://192.168.0.1:1900/igd.xml
SERVER: ipos/7.0 UPnP/1.0 TL-WR841N/9.0
ST: urn:schemas-upnp-org:service:WANIPConnection:1
USN: uuid:9f0865b3-f5da-4ad5-85
Received packet of size [269] ip [192.168.0.1] port [1900]
Gateway packet content:
HTTP/1.1 200 OK
CACHE-CONTROL: max-age=100
DATE: Sat, 16 Jun 2018 22:32:10 GMT
EXT:
LOCATION: http://192.168.0.1:1900/igd.xml
SERVER: ipos/7.0 UPnP/1.0 TL-WR841N/9.0
ST: uuid:565aa949-67c1-4c0e-aa8f-f349e6f59311
USN: uuid:565aa949-67c1-4c0e-aa8f-f3
Received packet of size [324] ip [192.168.0.1] port [1900]
Gateway packet content:
HTTP/1.1 200 OK
CACHE-CONTROL: max-age=100
DATE: Sat, 16 Jun 2018 22:32:10 GMT
EXT:
LOCATION: http://192.168.0.1:1900/igd.xml
SERVER: ipos/7.0 UPnP/1.0 TL-WR841N/9.0
ST: urn:schemas-wifialliance-org:device:WFADevice:1
USN: uuid:565aa949-67c1-4c0e-a
Received packet of size [334] ip [192.168.0.1] port [1900]
Gateway packet content:
HTTP/1.1 200 OK
CACHE-CONTROL: max-age=100
DATE: Sat, 16 Jun 2018 22:32:10 GMT
EXT:
LOCATION: http://192.168.0.1:1900/igd.xml
SERVER: ipos/7.0 UPnP/1.0 TL-WR841N/9.0
ST: urn:schemas-wifialliance-org:service:WFAWLANConfig:1
USN: uuid:565aa949-67c1-4
Received packet of size [264] ip [192.168.0.1] port [40163]
Gateway packet content:
NOTIFY * HTTP/1.1
HOST: 239.255.255.250:1900
CACHE-CONTROL: max-age=100
LOCATION: http://192.168.0.1:1900/igd.xml
NT: upnp:rootdevice
NTS: ssdp:alive
SERVER: ipos/7.0 UPnP/1.0 TL-WR841N/9.0
USN: uuid:060b7353-fca6-4070-85f4-1fbfb9add62c::upnp:rootd
Received packet of size [273] ip [192.168.0.1] port [40163]
Gateway packet content:
NOTIFY * HTTP/1.1
HOST: 239.255.255.250:1900
CACHE-CONTROL: max-age=100
LOCATION: http://192.168.0.1:1900/igd.xml
NT: uuid:060b7353-fca6-4070-85f4-1fbfb9add62c
NTS: ssdp:alive
SERVER: ipos/7.0 UPnP/1.0 TL-WR841N/9.0
USN: uuid:060b7353-fca6-4070-85f
Received packet of size [336] ip [192.168.0.1] port [40163]
Gateway packet content:
NOTIFY * HTTP/1.1
HOST: 239.255.255.250:1900
CACHE-CONTROL: max-age=100
LOCATION: http://192.168.0.1:1900/igd.xml
NT: urn:schemas-upnp-org:device:InternetGatewayDevice:1
NTS: ssdp:alive
SERVER: ipos/7.0 UPnP/1.0 TL-WR841N/9.0
USN: uuid:060b7353-fca
Received packet of size [328] ip [192.168.0.1] port [40163]
Gateway packet content:
NOTIFY * HTTP/1.1
HOST: 239.255.255.250:1900
CACHE-CONTROL: max-age=100
LOCATION: http://192.168.0.1:1900/igd.xml
NT: urn:schemas-upnp-org:service:Layer3Forwarding:1
NTS: ssdp:alive
SERVER: ipos/7.0 UPnP/1.0 TL-WR841N/9.0
USN: uuid:060b7353-fca6-40
Received packet of size [273] ip [192.168.0.1] port [40163]
Gateway packet content:

NOTIFY * HTTP/1.1
HOST: 239.255.255.250:1900
CACHE-CONTROL: max-age=100
LOCATION: http://192.168.0.1:1900/igd.xml
NT: uuid:254e9977-8964-49f3-b8d5-51acb7bd40fc
NTS: ssdp:alive
SERVER: ipos/7.0 UPnP/1.0 TL-WR841N/9.0
USN: uuid:254e9977-8964-49f3-b8d
Received packet of size [312] ip [192.168.0.1] port [40163]
Gateway packet content:
NOTIFY * HTTP/1.1
HOST: 239.255.255.250:1900
CACHE-CONTROL: max-age=100
LOCATION: http://192.168.0.1:1900/igd.xml
NT: urn:schemas-upnp-org:device:WANDevice:1
NTS: ssdp:alive
SERVER: ipos/7.0 UPnP/1.0 TL-WR841N/9.0
USN: uuid:254e9977-8964-49f3-b8d5-
Received packet of size [344] ip [192.168.0.1] port [40163]
Gateway packet content:
NOTIFY * HTTP/1.1
HOST: 239.255.255.250:1900
CACHE-CONTROL: max-age=100
LOCATION: http://192.168.0.1:1900/igd.xml
NT: urn:schemas-upnp-org:service:WANCommonInterfaceConfig:1
NTS: ssdp:alive
SERVER: ipos/7.0 UPnP/1.0 TL-WR841N/9.0
USN: uuid:254e9977
Received packet of size [273] ip [192.168.0.1] port [40163]
Gateway packet content:
NOTIFY * HTTP/1.1
HOST: 239.255.255.250:1900
CACHE-CONTROL: max-age=100
LOCATION: http://192.168.0.1:1900/igd.xml
NT: uuid:9f0865b3-f5da-4ad5-85b7-7404637fdf37
NTS: ssdp:alive
SERVER: ipos/7.0 UPnP/1.0 TL-WR841N/9.0
USN: uuid:9f0865b3-f5da-4ad5-85b
Received packet of size [332] ip [192.168.0.1] port [40163]
Gateway packet content:
NOTIFY * HTTP/1.1
HOST: 239.255.255.250:1900
CACHE-CONTROL: max-age=100
LOCATION: http://192.168.0.1:1900/igd.xml
NT: urn:schemas-upnp-org:device:WANConnectionDevice:1
NTS: ssdp:alive
SERVER: ipos/7.0 UPnP/1.0 TL-WR841N/9.0
USN: uuid:9f0865b3-f5da-
Received packet of size [326] ip [192.168.0.1] port [40163]
Gateway packet content:
NOTIFY * HTTP/1.1
HOST: 239.255.255.250:1900
CACHE-CONTROL: max-age=100
LOCATION: http://192.168.0.1:1900/igd.xml
NT: urn:schemas-upnp-org:service:WANIPConnection:1
NTS: ssdp:alive
SERVER: ipos/7.0 UPnP/1.0 TL-WR841N/9.0
USN: uuid:9f0865b3-f5da-4ad
Received packet of size [273] ip [192.168.0.1] port [40163]
Gateway packet content:
NOTIFY * HTTP/1.1

OST: 239.255.255.250:1900
CACHE-CONTROL: max-age=100
LOCATION: http://192.168.0.1:1900/igd.xml
NT: uuid:565aa949-67c1-4c0e-aa8f-f349e6f59311
NTS: ssdp:alive
SERVER: ipos/7.0 UPnP/1.0 TL-WR841N/9.0
USN: uuid:565aa949-67c1-4c0e-aa8
Received packet of size [328] ip [192.168.0.1] port [40163]
Gateway packet content:
NOTIFY * HTTP/1.1
HOST: 239.255.255.250:1900
CACHE-CONTROL: max-age=100
LOCATION: http://192.168.0.1:1900/igd.xml
NT: urn:schemas-wifialliance-org:device:WFADevice:1
NTS: ssdp:alive
SERVER: ipos/7.0 UPnP/1.0 TL-WR841N/9.0
USN: uuid:565aa949-67c1-4c
Received packet of size [338] ip [192.168.0.1] port [40163]
Gateway packet content:
NOTIFY * HTTP/1.1
HOST: 239.255.255.250:1900
CACHE-CONTROL: max-age=100
LOCATION: http://192.168.0.1:1900/igd.xml
NT: urn:schemas-wifialliance-org:service:WFAWLANConfig:1
NTS: ssdp:alive
SERVER: ipos/7.0 UPnP/1.0 TL-WR841N/9.0
USN: uuid:565aa949-67
Received packet of size [272] ip [192.168.0.1] port [36961]
Gateway packet content:
HTTP/1.1 200 OK
CACHE-CONTROL: max-age=1801
DATE: Sat, 16 Jun 2018 22:32:13 GMT
EXT:
LOCATION: http://192.168.0.1:49152/wps_device.xml
SERVER: Unspecified, UPnP/1.0, Unspecified
ST: upnp:rootdevice
USN: uuid:00000000-0000-1000-0000-60e3275d7898::up
Received packet of size [272] ip [192.168.0.1] port [36961]
Gateway packet content:
HTTP/1.1 200 OK
CACHE-CONTROL: max-age=1801
DATE: Sat, 16 Jun 2018 22:32:13 GMT
EXT:
LOCATION: http://192.168.0.1:49152/wps_device.xml
SERVER: Unspecified, UPnP/1.0, Unspecified
ST: upnp:rootdevice
USN: uuid:00000000-0000-1000-0000-60e3275d7898::up
Received packet of size [281] ip [192.168.0.1] port [36961]
Gateway packet content:
HTTP/1.1 200 OK
CACHE-CONTROL: max-age=1801
DATE: Sat, 16 Jun 2018 22:32:13 GMT
EXT:
LOCATION: http://192.168.0.1:49152/wps_device.xml
SERVER: Unspecified, UPnP/1.0, Unspecified
ST: uuid:00000000-0000-1000-0000-60e3275d7898
USN: uuid:00000000-0000-
Received packet of size [281] ip [192.168.0.1] port [36961]
Gateway packet content:
HTTP/1.1 200 OK
CACHE-CONTROL: max-age=1801
DATE: Sat, 16 Jun 2018 22:32:13 GMT
EXT:

LOCATION: http://192.168.0.1:49152/wps_device.xml
SERVER: Unspecified, UPnP/1.0, Unspecified
ST: uuid:00000000-0000-1000-0000-60e3275d7898
USN: uuid:00000000-0000-
Received packet of size [336] ip [192.168.0.1] port [36961]
Gateway packet content:
HTTP/1.1 200 OK
CACHE-CONTROL: max-age=1801
DATE: Sat, 16 Jun 2018 22:32:13 GMT
EXT:
LOCATION: http://192.168.0.1:49152/wps_device.xml
SERVER: Unspecified, UPnP/1.0, Unspecified
ST: urn:schemas-wifialliance-org:device:WFADevice:1
USN: uuid:00000000
Received packet of size [336] ip [192.168.0.1] port [36961]
Gateway packet content:
HTTP/1.1 200 OK
CACHE-CONTROL: max-age=1801
DATE: Sat, 16 Jun 2018 22:32:13 GMT
EXT:
LOCATION: http://192.168.0.1:49152/wps_device.xml
SERVER: Unspecified, UPnP/1.0, Unspecified
ST: urn:schemas-wifialliance-org:device:WFADevice:1
USN: uuid:00000000

Printing Port Mappings!
Port Mappings:
Invalid router info, cannot continue

UPnP done
Gateway Address: 192.168.0.1
Network Mask: 255.255.255.0

Invalid router info error

I keep getting the invalid router info error on a router that should support UPnP forwarding. I get lots of output via serial that looks like it should be working then it fails (different from the first time I tried on a router that didn't support UPnP). Ultimately after it fails I then can no longer access my web server even via the normal local addresses

Here's the serial output

Sending M-SEARCH to [4211081199] Port [1900]
M-SEARCH sent
Received packet of size [336] ip [192.168.0.1] port [1900]
Gateway packet content:
HTTP/1.1 200 OK
Cache-Control: max-age=600
Date: Sun, 15 Oct 2017 13:51:36 GMT
Ext: 
Location: http://192.168.0.1:1990/WFADevice.xml
Server: POSIX UPnP/1.0 UPnP Stack/6.37.14.62
ST: urn:schemas-wifialliance-org:device:WFADevice:1
USN: uuid:c66f9a05
Received packet of size [281] ip [192.168.0.1] port [1900]
Gateway packet content:
HTTP/1.1 200 OK
Cache-Control: max-age=600
Date: Sun, 15 Oct 2017 13:51:36 GMT
Ext: 
Location: http://192.168.0.1:1990/WFADevice.xml
Server: POSIX UPnP/1.0 UPnP Stack/6.37.14.62
ST: uuid:c66f9a05-c453-ceac-a86c-865190fa5739
USN: uuid:c66f9a05-c453-
Received packet of size [272] ip [192.168.0.1] port [1900]
Gateway packet content:
HTTP/1.1 200 OK
Cache-Control: max-age=600
Date: Sun, 15 Oct 2017 13:51:36 GMT
Ext: 
Location: http://192.168.0.1:1990/WFADevice.xml
Server: POSIX UPnP/1.0 UPnP Stack/6.37.14.62
ST: upnp:rootdevice
USN: uuid:c66f9a05-c453-ceac-a86c-865190fa5739::up
Received packet of size [346] ip [192.168.0.1] port [1900]
Gateway packet content:
HTTP/1.1 200 OK
Cache-Control: max-age=600
Date: Sun, 15 Oct 2017 13:51:36 GMT
Ext: 
Location: http://192.168.0.1:1990/WFADevice.xml
Server: POSIX UPnP/1.0 UPnP Stack/6.37.14.62
ST: urn:schemas-wifialliance-org:service:WFAWLANConfig:1
USN: uuid:c66
Received packet of size [269] ip [192.168.0.1] port [1900]
Gateway packet content:
HTTP/1.1 200 OK
CACHE-CONTROL: max-age=100
DATE: Sun, 15 Oct 2017 13:51:36 GMT
EXT:
LOCATION: http://192.168.0.1:1900/igd.xml
SERVER: ipos/7.0 UPnP/1.0 Archer_C8/1.0
ST: uuid:060b7353-fca6-4070-85f4-1fbfb9add62c
USN: uuid:060b7353-fca6-4070-85f4-1f
Received packet of size [332] ip [192.168.0.1] port [1900]
Gateway packet content:
HTTP/1.1 200 OK
CACHE-CONTROL: max-age=100
DATE: Sun, 15 Oct 2017 13:51:36 GMT
EXT:
LOCATION: http://192.168.0.1:1900/igd.xml
SERVER: ipos/7.0 UPnP/1.0 Archer_C8/1.0
ST: urn:schemas-upnp-org:device:InternetGatewayDevice:1
USN: uuid:060b7353-fca6-40
Received packet of size [324] ip [192.168.0.1] port [1900]
Gateway packet content:
HTTP/1.1 200 OK
CACHE-CONTROL: max-age=100
DATE: Sun, 15 Oct 2017 13:51:37 GMT
EXT:
LOCATION: http://192.168.0.1:1900/igd.xml
SERVER: ipos/7.0 UPnP/1.0 Archer_C8/1.0
ST: urn:schemas-upnp-org:service:Layer3Forwarding:1
USN: uuid:060b7353-fca6-4070-8
Received packet of size [269] ip [192.168.0.1] port [1900]
Gateway packet content:
HTTP/1.1 200 OK
CACHE-CONTROL: max-age=100
DATE: Sun, 15 Oct 2017 13:51:37 GMT
EXT:
LOCATION: http://192.168.0.1:1900/igd.xml
SERVER: ipos/7.0 UPnP/1.0 Archer_C8/1.0
ST: uuid:254e9977-8964-49f3-b8d5-51acb7bd40fc
USN: uuid:254e9977-8964-49f3-b8d5-51
Received packet of size [308] ip [192.168.0.1] port [1900]
Gateway packet content:
HTTP/1.1 200 OK
CACHE-CONTROL: max-age=100
DATE: Sun, 15 Oct 2017 13:51:37 GMT
EXT:
LOCATION: http://192.168.0.1:1900/igd.xml
SERVER: ipos/7.0 UPnP/1.0 Archer_C8/1.0
ST: urn:schemas-upnp-org:device:WANDevice:1
USN: uuid:254e9977-8964-49f3-b8d5-51ac
Received packet of size [340] ip [192.168.0.1] port [1900]
Gateway packet content:
HTTP/1.1 200 OK
CACHE-CONTROL: max-age=100
DATE: Sun, 15 Oct 2017 13:51:37 GMT
EXT:
LOCATION: http://192.168.0.1:1900/igd.xml
SERVER: ipos/7.0 UPnP/1.0 Archer_C8/1.0
ST: urn:schemas-upnp-org:service:WANCommonInterfaceConfig:1
USN: uuid:254e9977-896
Received packet of size [269] ip [192.168.0.1] port [1900]
Gateway packet content:
HTTP/1.1 200 OK
CACHE-CONTROL: max-age=100
DATE: Sun, 15 Oct 2017 13:51:37 GMT
EXT:
LOCATION: http://192.168.0.1:1900/igd.xml
SERVER: ipos/7.0 UPnP/1.0 Archer_C8/1.0
ST: uuid:9f0865b3-f5da-4ad5-85b7-7404637fdf37
USN: uuid:9f0865b3-f5da-4ad5-85b7-74
Received packet of size [328] ip [192.168.0.1] port [1900]
Gateway packet content:
HTTP/1.1 200 OK
CACHE-CONTROL: max-age=100
DATE: Sun, 15 Oct 2017 13:51:37 GMT
EXT:
LOCATION: http://192.168.0.1:1900/igd.xml
SERVER: ipos/7.0 UPnP/1.0 Archer_C8/1.0
ST: urn:schemas-upnp-org:device:WANConnectionDevice:1
USN: uuid:9f0865b3-f5da-4ad5
Received packet of size [322] ip [192.168.0.1] port [1900]
Gateway packet content:
HTTP/1.1 200 OK
CACHE-CONTROL: max-age=100
DATE: Sun, 15 Oct 2017 13:51:37 GMT
EXT:
LOCATION: http://192.168.0.1:1900/igd.xml
SERVER: ipos/7.0 UPnP/1.0 Archer_C8/1.0
ST: urn:schemas-upnp-org:service:WANIPConnection:1
USN: uuid:9f0865b3-f5da-4ad5-85
Received packet of size [269] ip [192.168.0.1] port [1900]
Gateway packet content:
HTTP/1.1 200 OK
CACHE-CONTROL: max-age=100
DATE: Sun, 15 Oct 2017 13:51:37 GMT
EXT:
LOCATION: http://192.168.0.1:1900/igd.xml
SERVER: ipos/7.0 UPnP/1.0 Archer_C8/1.0
ST: uuid:565aa949-67c1-4c0e-aa8f-f349e6f59311
USN: uuid:565aa949-67c1-4c0e-aa8f-f3
Received packet of size [324] ip [192.168.0.1] port [1900]
Gateway packet content:
HTTP/1.1 200 OK
CACHE-CONTROL: max-age=100
DATE: Sun, 15 Oct 2017 13:51:37 GMT
EXT:
LOCATION: http://192.168.0.1:1900/igd.xml
SERVER: ipos/7.0 UPnP/1.0 Archer_C8/1.0
ST: urn:schemas-wifialliance-org:device:WFADevice:1
USN: uuid:565aa949-67c1-4c0e-a
Received packet of size [334] ip [192.168.0.1] port [1900]
Gateway packet content:
HTTP/1.1 200 OK
CACHE-CONTROL: max-age=100
DATE: Sun, 15 Oct 2017 13:51:38 GMT
EXT:
LOCATION: http://192.168.0.1:1900/igd.xml
SERVER: ipos/7.0 UPnP/1.0 Archer_C8/1.0
ST: urn:schemas-wifialliance-org:service:WFAWLANConfig:1
USN: uuid:565aa949-67c1-4

Port Mappings:
Invalid router info, cannot continue

Check IP when verifying the port mappings are in the IGD

If the device changes its IP address it will still recognize the rules in the IGD as valid since the IP address is not checked.
The device should verify that the port mapping in the IGD is directing to the correct (current) IP address of the device.
Also, adding the rule to the IGD after the IP was changed (and the device did not restart) causes the old IP to be added to the rule instead of the new IP.
Should verify that the current IP will be updated before adding a rule. The port can be updated in the device's memory when it is detected that it changed when verifying the rules in the IGD.

getting a 404 not found error. [SOLVED]

@ofekp
Using the example outright, failed for me. I made a few changes trying to get it to work but nothing fixed the issue I am having.

Starting...

Connected to dd-wrt_EXT
IP address: 192.168.1.126
Sending M-SEARCH to [4211081199] Port [1900]
M-SEARCH sent
Received packet of size [351] ip [192.168.1.1] port [1900]
Gateway packet content:
HTTP/1.1 200 OK
Cache-Control: max-age=300
Date: Thu, 29 Mar 2018 21:24:56 GMT
Ext: 
Location: http://192.168.1.1:1780/InternetGatewayDevice.xml
Server: POSIX UPnP/1.0 DD-WRT Linux/V24
ST: urn:schemas-upnp-org:device:InternetGatewayDevice:1
USN: uu
IGD location found [http://192.168.1.1:1780/InternetGatewayDevice.xml]
192.168.1.1
1780
/InternetGatewayDevice.xml
Connected to IGD
HTTP/1.1 200 OK
Content-Type: text/xml
Content-Length: 3747
Connection: close
Pragma: no-cache

<?xml version="1.0"?>
<root xmlns="urn:schemas-upnp-org:device-1-0">
	<specVersion>
		<major>1</major>
		<minor>0</minor>
	</specVersion>
	<device>
		<deviceType>urn:schemas-upnp-org:device:InternetGatewayDevice:1</deviceType>
		<manufacturer>DD-WRT</manufacturer>
		<manufacturerURL>http://www.dd-wrt.com</manufacturerURL>
		<modelDescription>Gateway</modelDescription>
		<friendlyName>Netgear R8000:DD-WRT</friendlyName>
		<modelName>Netgear R8000</modelName>
		<modelNumber>V24</modelNumber>
		<serialNumber>0000001</serialNumber>
		<modelURL>http://www.dd-wrt.com</modelURL>
		<UDN>uuid:1663857C-D3A1-6002-475E-05A68F8958B2</UDN>
		<serviceList>
			<service>
				<serviceType>urn:schemas-upnp-org:service:Layer3Forwarding:1</serviceType>
				<serviceId>urn:upnp-org:serviceId:L3Forwarding1</serviceId>
				<SCPDURL>/x_layer3forwarding.xml</SCPDURL>
				<controlURL>/control?Layer3Forwarding</controlURL>
				<eventSubURL>/event?Layer3Forwarding</eventSubURL>
			</service>
		</serviceList>
		<deviceList>
			<device>
				<deviceType>urn:schemas-upnp-org:device:WANDevice:1</deviceType>
				<friendlyName>WANDevice</friendlyName>
				<manufacturer>DD-WRT</manufacturer>
				<manufacturerURL>http://www.dd-wrt.com</manufacturerURL>
				<modelDescription>Gateway</modelDescription>
				<modelName>router</modelName>
				<modelURL>http://www.dd-wrt.com</modelURL>
				<UDN>uuid:18202E31-ADCB-A755-D294-99DF10A6FE3E</UDN>
				<serviceList>
					<service>
						<serviceType>urn:schemas-upnp-org:service:WANCommonInterfaceConfig:1</serviceType>
						<serviceId>urn:upnp-org:serviceId:WANCommonIFC1</serviceId>
						<SCPDURL>/x_wancommoninterfaceconfig.xml</SCPDURL>
						<controlURL>/control?WANCommonInterfaceConfig</controlURL>
						<eventSubURL>/event?WANCommonInterfaceConfig</eventSubURL>
					</service>
				</serviceList>
				<deviceList>
					<device>
						<deviceType>urn:schemas-upnp-org:device:WANConnectionDevice:1</deviceType>
						<friendlyName>WAN Connection Device</friendlyName>
						<manufacturer>DD-WRT</manufacturer>
						<manufacturerURL>http://www.dd-wrt.com</manufacturerURL>
						<modelDescription>Gateway</modelDescription>
						<modelName>router</modelName>
						<modelURL>http://www.dd-wrt.com</modelURL>
						<UDN>uuid:14F4BB03-F945-3E0F-4732-6388A639FD4B</UDN>
						<serviceList>
							<service>
								<serviceType>urn:schemas-upnp-org:service:WANIPConnection:1</serviceType>WANIPPConnection service found!

								<serviceId>urn:upnp-org:serviceId:WANIPConn1</serviceId>
								<SCPDURL>/x_wanipconnection.xml</SCPDURL>
								<controlURL>/control?WANIPConnection</controlURL>
								<eventSubURL>/event?WANIPConnection</eventSubURL>eventSubURL tag found! addPortMappingEventUrl [/event?WANIPConnection]

							</service>
						</serviceList>
					</device>
				</deviceList>
			</device>
			<device>
				<deviceType>urn:schemas-upnp-org:device:LANDevice:1</deviceType>
				<friendlyName>LANDevice</friendlyName>
				<manufacturer>DD-WRT</manufacturer>
				<manufacturerURL>http://www.dd-wrt.com</manufacturerURL>
				<modelDescription>Gateway</modelDescription>
				<modelName>router</modelName>
				<modelURL>http://www.dd-wrt.com</modelURL>
				<UDN>uuid:22D60480-676E-1516-609E-A8595B2F0E0E</UDN>
				<serviceList>
					<service>
						<serviceType>urn:schemas-upnp-org:service:LANHostConfigManagement:1</serviceType>
						<serviceId>urn:upnp-org:serviceId:LANHostCfg1</serviceId>
						<SCPDURL>/x_lanhostconfigmanagement.xml</SCPDURL>
						<controlURL>/control?LANHostConfigManagement</controlURL>
						<eventSubURL>/event?LANHostConfigManagement</eventSubURL>
					</service>
				</serviceList>
			</device>
		</deviceList>
		<presentationURL>http://192.168.1.1</presentationURL>
	</device>
</root>



Port Mappings:
Connected to IGD
Sending query for index [0]
POST /event?WANIPConnection HTTP/1.1Connection: keep-aliveContent-Type: text/xml; charset="utf-8"SOAPAction: "urn:schemas-upnp-org:service:WANIPPConnection:1#GetGenericPortMappingEntry"Content-Length: 356<?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:GetGenericPortMappingEntry xmlns:u="urn:schemas-upnp-org:service:WANIPPConnection:1">
  <NewPortMappingIndex>0</NewPortMappingIndex>
</u:GetGenericPortMappingEntry>
</s:Body>
</s:Envelope>

HTTP1.1 404 Not Found
Content-Type: text/xml

<title>404 Not Found</title><body>404 Not Found</body>

192.168.1.1:1780/event?WANIPConnection is just a blank page, nothing in source.

http://192.168.1.1:1780/InternetGatewayDevice.xml is

<root xmlns="urn:schemas-upnp-org:device-1-0">
<specVersion>
<major>1</major>
<minor>0</minor>
</specVersion>
<device>
<deviceType>
urn:schemas-upnp-org:device:InternetGatewayDevice:1
</deviceType>
<manufacturer>DD-WRT</manufacturer>
<manufacturerURL>http://www.dd-wrt.com</manufacturerURL>
<modelDescription>Gateway</modelDescription>
<friendlyName>Netgear R8000:DD-WRT</friendlyName>
<modelName>Netgear R8000</modelName>
<modelNumber>V24</modelNumber>
<serialNumber>0000001</serialNumber>
<modelURL>http://www.dd-wrt.com</modelURL>
<UDN>uuid:1663857C-D3A1-6002-475E-05A68F8958B2</UDN>
<serviceList>
<service>
<serviceType>urn:schemas-upnp-org:service:Layer3Forwarding:1</serviceType>
<serviceId>urn:upnp-org:serviceId:L3Forwarding1</serviceId>
<SCPDURL>/x_layer3forwarding.xml</SCPDURL>
<controlURL>/control?Layer3Forwarding</controlURL>
<eventSubURL>/event?Layer3Forwarding</eventSubURL>
</service>
</serviceList>
<deviceList>
<device>
<deviceType>urn:schemas-upnp-org:device:WANDevice:1</deviceType>
<friendlyName>WANDevice</friendlyName>
<manufacturer>DD-WRT</manufacturer>
<manufacturerURL>http://www.dd-wrt.com</manufacturerURL>
<modelDescription>Gateway</modelDescription>
<modelName>router</modelName>
<modelURL>http://www.dd-wrt.com</modelURL>
<UDN>uuid:18202E31-ADCB-A755-D294-99DF10A6FE3E</UDN>
<serviceList>
<service>
<serviceType>
urn:schemas-upnp-org:service:WANCommonInterfaceConfig:1
</serviceType>
<serviceId>urn:upnp-org:serviceId:WANCommonIFC1</serviceId>
<SCPDURL>/x_wancommoninterfaceconfig.xml</SCPDURL>
<controlURL>/control?WANCommonInterfaceConfig</controlURL>
<eventSubURL>/event?WANCommonInterfaceConfig</eventSubURL>
</service>
</serviceList>
<deviceList>
<device>
<deviceType>urn:schemas-upnp-org:device:WANConnectionDevice:1</deviceType>
<friendlyName>WAN Connection Device</friendlyName>
<manufacturer>DD-WRT</manufacturer>
<manufacturerURL>http://www.dd-wrt.com</manufacturerURL>
<modelDescription>Gateway</modelDescription>
<modelName>router</modelName>
<modelURL>http://www.dd-wrt.com</modelURL>
<UDN>uuid:14F4BB03-F945-3E0F-4732-6388A639FD4B</UDN>
<serviceList>
<service>
<serviceType>urn:schemas-upnp-org:service:WANIPConnection:1</serviceType>
<serviceId>urn:upnp-org:serviceId:WANIPConn1</serviceId>
<SCPDURL>/x_wanipconnection.xml</SCPDURL>
<controlURL>/control?WANIPConnection</controlURL>
<eventSubURL>/event?WANIPConnection</eventSubURL>
</service>
</serviceList>
</device>
</deviceList>
</device>
<device>
<deviceType>urn:schemas-upnp-org:device:LANDevice:1</deviceType>
<friendlyName>LANDevice</friendlyName>
<manufacturer>DD-WRT</manufacturer>
<manufacturerURL>http://www.dd-wrt.com</manufacturerURL>
<modelDescription>Gateway</modelDescription>
<modelName>router</modelName>
<modelURL>http://www.dd-wrt.com</modelURL>
<UDN>uuid:22D60480-676E-1516-609E-A8595B2F0E0E</UDN>
<serviceList>
<service>
<serviceType>
urn:schemas-upnp-org:service:LANHostConfigManagement:1
</serviceType>
<serviceId>urn:upnp-org:serviceId:LANHostCfg1</serviceId>
<SCPDURL>/x_lanhostconfigmanagement.xml</SCPDURL>
<controlURL>/control?LANHostConfigManagement</controlURL>
<eventSubURL>/event?LANHostConfigManagement</eventSubURL>
</service>
</serviceList>
</device>
</deviceList>
<presentationURL>http://192.168.1.1</presentationURL>
</device>
</root>

I do not see a baseURL in the IGD XML so I also tried changing:
if (!(upnpServiceFound && eventSubURLFound) && line.indexOf("") >= 0)
if (!(upnpServiceFound && eventSubURLFound) && line.indexOf("") >= 0)

I also tried using your other branch. here is the output from that.


Connected to dd-wrt_EXT
IP address: 192.168.1.126
Sending M-SEARCH to [4211081199] Port [1900]
M-SEARCH sent
Received packet of size [351] ip [192.168.1.1] port [1900]
Gateway packet content:
HTTP/1.1 200 OK
Cache-Control: max-age=300
Date: Thu, 29 Mar 2018 21:47:10 GMT
Ext: 
Location: http://192.168.1.1:1780/InternetGatewayDevice.xml
Server: POSIX UPnP/1.0 DD-WRT Linux/V24
ST: urn:schemas-upnp-org:device:InternetGatewayDevice:1
USN: uu
IGD location found [http://192.168.1.1:1780/InternetGatewayDevice.xml]
192.168.1.1
1780
/InternetGatewayDevice.xml
Connecting to IGD with host [192.168.1.1] port [1780]
Connected to IGD
HTTP/1.1 200 OK
Content-Type: text/xml
Content-Length: 3747
Connection: close
Pragma: no-cache

<?xml version="1.0"?>
<root xmlns="urn:schemas-upnp-org:device-1-0">
	<specVersion>
		<major>1</major>
		<minor>0</minor>
	</specVersion>
	<device>
		<deviceType>urn:schemas-upnp-org:device:InternetGatewayDevice:1</deviceType>
		<manufacturer>DD-WRT</manufacturer>
		<manufacturerURL>http://www.dd-wrt.com</manufacturerURL>
		<modelDescription>Gateway</modelDescription>
		<friendlyName>Netgear R8000:DD-WRT</friendlyName>
		<modelName>Netgear R8000</modelName>
		<modelNumber>V24</modelNumber>
		<serialNumber>0000001</serialNumber>
		<modelURL>http://www.dd-wrt.com</modelURL>
		<UDN>uuid:1663857C-D3A1-6002-475E-05A68F8958B2</UDN>
		<serviceList>
			<service>
				<serviceType>urn:schemas-upnp-org:service:Layer3Forwarding:1</serviceType>
				<serviceId>urn:upnp-org:serviceId:L3Forwarding1</serviceId>
				<SCPDURL>/x_layer3forwarding.xml</SCPDURL>
				<controlURL>/control?Layer3Forwarding</controlURL>
				<eventSubURL>/event?Layer3Forwarding</eventSubURL>
			</service>
		</serviceList>
		<deviceList>
			<device>
				<deviceType>urn:schemas-upnp-org:device:WANDevice:1</deviceType>
				<friendlyName>WANDevice</friendlyName>
				<manufacturer>DD-WRT</manufacturer>
				<manufacturerURL>http://www.dd-wrt.com</manufacturerURL>
				<modelDescription>Gateway</modelDescription>
				<modelName>router</modelName>
				<modelURL>http://www.dd-wrt.com</modelURL>
				<UDN>uuid:18202E31-ADCB-A755-D294-99DF10A6FE3E</UDN>
				<serviceList>
					<service>
						<serviceType>urn:schemas-upnp-org:service:WANCommonInterfaceConfig:1</serviceType>
						<serviceId>urn:upnp-org:serviceId:WANCommonIFC1</serviceId>
						<SCPDURL>/x_wancommoninterfaceconfig.xml</SCPDURL>
						<controlURL>/control?WANCommonInterfaceConfig</controlURL>
						<eventSubURL>/event?WANCommonInterfaceConfig</eventSubURL>
					</service>
				</serviceList>
				<deviceList>
					<device>
						<deviceType>urn:schemas-upnp-org:device:WANConnectionDevice:1</deviceType>
						<friendlyName>WAN Connection Device</friendlyName>
						<manufacturer>DD-WRT</manufacturer>
						<manufacturerURL>http://www.dd-wrt.com</manufacturerURL>
						<modelDescription>Gateway</modelDescription>
						<modelName>router</modelName>
						<modelURL>http://www.dd-wrt.com</modelURL>
						<UDN>uuid:14F4BB03-F945-3E0F-4732-6388A639FD4B</UDN>
						<serviceList>
							<service>
								<serviceType>urn:schemas-upnp-org:service:WANIPConnection:1</serviceType>urn:schemas-upnp-org:service:WANIPConnection:1 service found!

								<serviceId>urn:upnp-org:serviceId:WANIPConn1</serviceId>
								<SCPDURL>/x_wanipconnection.xml</SCPDURL>
								<controlURL>/control?WANIPConnection</controlURL>
								<eventSubURL>/event?WANIPConnection</eventSubURL>eventSubURL tag found! setting actionPath to [/event?WANIPConnection]

							</service>
						</serviceList>
					</device>
				</deviceList>
			</device>
			<device>
				<deviceType>urn:schemas-upnp-org:device:LANDevice:1</deviceType>
				<friendlyName>LANDevice</friendlyName>
				<manufacturer>DD-WRT</manufacturer>
				<manufacturerURL>http://www.dd-wrt.com</manufacturerURL>
				<modelDescription>Gateway</modelDescription>
				<modelName>router</modelName>
				<modelURL>http://www.dd-wrt.com</modelURL>
				<UDN>uuid:22D60480-676E-1516-609E-A8595B2F0E0E</UDN>
				<serviceList>
					<service>
						<serviceType>urn:schemas-upnp-org:service:LANHostConfigManagement:1</serviceType>
						<serviceId>urn:upnp-org:serviceId:LANHostCfg1</serviceId>
						<SCPDURL>/x_lanhostconfigmanagement.xml</SCPDURL>
						<controlURL>/control?LANHostConfigManagement</controlURL>
						<eventSubURL>/event?LANHostConfigManagement</eventSubURL>
					</service>
				</serviceList>
			</device>
		</deviceList>
		<presentationURL>http://192.168.1.1</presentationURL>
	</device>
</root>

port [1780] actionPort [1780]
Connecting to IGD with host [192.168.1.1] port [1780]
Connected to IGD
called addPortMappingEntry
deviceInfo->actionPath [/event?WANIPConnection]
deviceInfo->serviceTypeName [urn:schemas-upnp-org:service:WANIPConnection:1]
Content-Length was: 589
<?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:AddPortMapping xmlns:u="urn:schemas-upnp-org:service:WANIPConnection:1"><NewRemoteHost></NewRemoteHost><NewExternalPort>9999</NewExternalPort><NewProtocol>TCP</NewProtocol><NewInternalPort>9999</NewInternalPort><NewInternalClient>192.168.1.126</NewInternalClient><NewEnabled>1</NewEnabled><NewPortMappingDescription>happy name</NewPortMappingDescription><NewLeaseDuration>0</NewLeaseDuration></u:AddPortMapping></s:Body></s:Envelope>
HTTP1.1 404 Not Found

Content-Type: text/xml



<title>404 Not Found</title><body>404 Not Found</body>




Port Mappings:
Connecting to IGD with host [192.168.1.1] port [1780]
Connected to IGD
Sending query for index [0]
HTTP1.1 404 Not Found
Content-Type: text/xml

<title>404 Not Found</title><body>404 Not Found</body>
Connecting to IGD with host [192.168.1.1] port [1780]
Connected to IGD
Sending query for index [1]
HTTP1.1 404 Not Found
Content-Type: text/xml

Use as client for iptv server, wifi to HDMI tv dongle.

Hi there !

I am not very technical...but this looks cool ๐Ÿ˜›

  1. So can I use this as ESP client to stream iptv from a public ( Cloud) server?

That is, IPTV server > home ESP+ mini upnp > WiFi > HDMI dongle on TV set.

Example TV dongle:
https://m.aliexpress.com/wholesale/ezcast-dongles.html?spider=y

These cheap dongles do a variation of the Miracast dlna protocol and I have streamed from YouTube on my smartphone to a TV set with such HDMI dongle.

Much cheaper than Firestick or Chromecast !

  1. If not, is there a similar ESP project I might look at.

TCP connection timeout while connecting to the IDG

I'm using a Verizon/Frontier Fios router. Every few seconds, I see the message "TCP connection timeout while connecting to the IDG". From the logs, you'll see that it correctly found the IDG. I have also included the output from rootDesc.xml. I think it is supposed to contain the string defined by UPNP_SERVICE_TYPE (urn:schemas-upnp-org:service:WANPPPConnection:1) which is not in rootDesc.xml. That's just a guess though.

Just in case it is working but doesn't appear to, I turned off WiFi on my phone and tried to connect to the device anyway. No joy.
serial_logs.txt
rootDesc.txt

NO Work addPort

I'm try to run this library.

only get this log.

never work..

Sending M-SEARCH to [4211081199] Port [1900]
M-SEARCH sent
Received packet of size [411] ip [192.168.1.1] port [50821]
Gateway packet content:
NOTIFY * HTTP/1.1
HOST: 239.255.255.250:1900
CACHE-CONTROL: max-age=1800
LOCATION: http://192.168.1.1:52869/gatedesc.xml
OPT: "http://schemas.upnp.org/upnp/1/0/"; ns=01
01-NLS: edcfe8a0-1dd1-11b2-9332-db3332f88128
NT: upnp:rootdevice
NTS: ssdp:aliv
Received packet of size [420] ip [192.168.1.1] port [50821]
Gateway packet content:
NOTIFY * HTTP/1.1
HOST: 239.255.255.250:1900
CACHE-CONTROL: max-age=1800
LOCATION: http://192.168.1.1:52869/gatedesc.xml
OPT: "http://schemas.upnp.org/upnp/1/0/"; ns=01
01-NLS: edcfe8a0-1dd1-11b2-9332-db3332f88128
NT: uuid:20809696-105a-3721-e8b8-44
Received packet of size [483] ip [192.168.1.1] port [50821]
Gateway packet content:
NOTIFY * HTTP/1.1
HOST: 239.255.255.250:1900
CACHE-CONTROL: max-age=1800
LOCATION: http://192.168.1.1:52869/gatedesc.xml
OPT: "http://schemas.upnp.org/upnp/1/0/"; ns=01
01-NLS: edcfe8a0-1dd1-11b2-9332-db3332f88128
NT: urn:schemas-upnp-org:device:Int
Received packet of size [465] ip [192.168.1.1] port [47111]
Gateway packet content:
NOTIFY * HTTP/1.1
HOST: 239.255.255.250:1900
CACHE-CONTROL: max-age=1800
LOCATION: http://192.168.1.1:52869/gatedesc.xml
OPT: "http://schemas.upnp.org/upnp/1/0/"; ns=01
01-NLS: edcfe8a0-1dd1-11b2-9332-db3332f88128
NT: urn:schemas-microsoft-com:servi
Received packet of size [420] ip [192.168.1.1] port [46433]
Gateway packet content:
NOTIFY * HTTP/1.1
HOST: 239.255.255.250:1900
CACHE-CONTROL: max-age=1800
LOCATION: http://192.168.1.1:52869/gatedesc.xml
OPT: "http://schemas.upnp.org/upnp/1/0/"; ns=01
01-NLS: edcfe8a0-1dd1-11b2-9332-db3332f88128
NT: uuid:20809696-205a-3721-e8b8-44
Received packet of size [459] ip [192.168.1.1] port [46433]
Gateway packet content:
NOTIFY * HTTP/1.1
HOST: 239.255.255.250:1900
CACHE-CONTROL: max-age=1800
LOCATION: http://192.168.1.1:52869/gatedesc.xml
OPT: "http://schemas.upnp.org/upnp/1/0/"; ns=01
01-NLS: edcfe8a0-1dd1-11b2-9332-db3332f88128
NT: urn:schemas-upnp-org:device:WAN
Received packet of size [491] ip [192.168.1.1] port [59709]
Gateway packet content:
NOTIFY * HTTP/1.1
HOST: 239.255.255.250:1900
CACHE-CONTROL: max-age=1800
LOCATION: http://192.168.1.1:52869/gatedesc.xml
OPT: "http://schemas.upnp.org/upnp/1/0/"; ns=01
01-NLS: edcfe8a0-1dd1-11b2-9332-db3332f88128
NT: urn:schemas-upnp-org:service:WA
Received packet of size [420] ip [192.168.1.1] port [50375]
Gateway packet content:
NOTIFY * HTTP/1.1
HOST: 239.255.255.250:1900
CACHE-CONTROL: max-age=1800
LOCATION: http://192.168.1.1:52869/gatedesc.xml
OPT: "http://schemas.upnp.org/upnp/1/0/"; ns=01
01-NLS: edcfe8a0-1dd1-11b2-9332-db3332f88128
NT: uuid:20809696-305a-3721-e8b8-44
Received packet of size [479] ip [192.168.1.1] port [50375]
Gateway packet content:
NOTIFY * HTTP/1.1
HOST: 239.255.255.250:1900
CACHE-CONTROL: max-age=1800
LOCATION: http://192.168.1.1:52869/gatedesc.xml
OPT: "http://schemas.upnp.org/upnp/1/0/"; ns=01
01-NLS: edcfe8a0-1dd1-11b2-9332-db3332f88128
NT: urn:schemas-upnp-org:device:WAN
Received packet of size [473] ip [192.168.1.1] port [35015]
Gateway packet content:
NOTIFY * HTTP/1.1
HOST: 239.255.255.250:1900
CACHE-CONTROL: max-age=1800
LOCATION: http://192.168.1.1:52869/gatedesc.xml
OPT: "http://schemas.upnp.org/upnp/1/0/"; ns=01
01-NLS: edcfe8a0-1dd1-11b2-9332-db3332f88128
NT: urn:schemas-upnp-org:service:WA
Received packet of size [487] ip [192.168.1.1] port [55982]
Gateway packet content:
NOTIFY * HTTP/1.1
HOST: 239.255.255.250:1900
CACHE-CONTROL: max-age=1800
LOCATION: http://192.168.1.1:52869/gatedesc.xml
OPT: "http://schemas.upnp.org/upnp/1/0/"; ns=01
01-NLS: edcfe8a0-1dd1-11b2-9332-db3332f88128
NT: urn:schemas-upnp-org:service:WA

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.