Comments (7)
@jeffpkamp
Can you please try the code from the branch issue10
FYI, there is a better API soon from the branch newApi
you can try this too if you prefer, for me it works better because of some timeouts that I changed and also fixed a few debug prints that might help us now.
In case you're interested, in the method addPortMapping
you're stopping here https://github.com/ofekp/TinyUPnP/blob/master/src/TinyUPnP.cpp#L58
This is probably because waitForUnicastResponseToMSearch
failed. Not sure why yet, since I do see the required urn:schemas-upnp-org:device:InternetGatewayDevice:1
in the output you attached.
There's a chance this is related to issue10
since the size of the packets from your router exceed 255 byte.
Anyway, let's give it a try please.
Ofek.
from tinyupnp.
I changed the UDP read length to max with no effect. When I get the specific error it runs into during port mapping, it says it fails due to all three conditions. Is this just an issue of it failing to parse the info from the xml file? I tried setting the values manually when they failed (ie _gwinfo.port = 1900, _gwinfo.host = IPAddress(239,255,255,250), _gwinfo.path="http://192.168.0.1:1900/igd.xml"
, but this just times out waiting for the igd.
from tinyupnp.
The new API seems to be working. Its a little delayed but it gets the job done in a minute or so. I'm a little confused because it keeps cranking out information to the Serial Connection after the connection is established. Is there a way to make it less verbose once it succeeds?
from tinyupnp.
Glad it works!
Just curious, when you used newApi, did you also use the new UDP packet size?
You can turn off all the prints that originate from the package by changing:
#define IS_DEBUG true
to false in the .h
file.
Other prints in the .ino
file will have to be removed manually.
from tinyupnp.
okay, so looking at it as it runs it sort of works. But it hangs when looking for port mapping
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>
#include <ESP8266mDNS.h>
#include <WiFiUdp.h>
#include <ESP8266SSDP.h>
#include "TinyUPnP.h"
const char* ssid = "SSID";
const char* password = "password";
#define LISTEN_PORT 40
#define LEASE_DURATION 300 // seconds
#define FRIENDLY_NAME "test"
unsigned long lastUpdateTime = 0;
TinyUPnP *tinyUPnP = new TinyUPnP(10000); // -1 means blocking, preferably, use a timeout value (ms)
ESP8266WebServer server(LISTEN_PORT);
void setup() {
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());
if (tinyUPnP->addPortMapping(WiFi.localIP(), LISTEN_PORT, RULE_PROTOCOL_TCP, LEASE_DURATION, FRIENDLY_NAME)) {
lastUpdateTime = millis();
}
Serial.println();
tinyUPnP->printAllPortMappings();
Serial.println();
program stalls here
port mapping works because I can see it on my routers UPnP page, but it never reaches my loop function. Just keeps printing SSDS info, which I assume is from the printAllPortMappings()
function.
Serial.println("UPnP done");
}
void loop(void) {
// update UPnP port mapping rule if needed
if ((millis() - lastUpdateTime) > (long) (0.8D * (double) (LEASE_DURATION * 1000.0))) {
Serial.print("UPnP rule is about to be revoked, renewing lease");
if (tinyUPnP->addPortMapping(WiFi.localIP(), LISTEN_PORT, RULE_PROTOCOL_TCP, LEASE_DURATION, FRIENDLY_NAME)) {
lastUpdateTime = millis();
}
}
}
from tinyupnp.
Please make sure to use the newApi
branch.
It is updated after I merged the branch issue10
with the UDP_TX_PACKET_MAX_SIZE
issue.
It also solves what you described here. printAllPortMappings
takes a long time if you have many UPnP ports open on your IGD router. The new branch will only print this if you encounter an error upon startup.
If you prefer to use your current code (since I am still testing the code in newApi
) you can simply delete this print method from the .ino
file.
from tinyupnp.
Closing this, since the issue is resolved.
I will debug the branch newApi
a bit more before I'll put it in master.
from tinyupnp.
Related Issues (20)
- ESP-IDF Support HOT 9
- TinyUPNP library makes my esp8266 crash and reset HOT 18
- How to configure diferent internal and external port? HOT 8
- Gateway info is not valid HOT 98
- Stack overflow while reading xml HOT 4
- Use WiFi Library Events
- Option for both local and external port (with code) HOT 3
- Gateway info is not valid HOT 3
- Invalid router info HOT 10
- Implementation for knowing what all services are present on the network HOT 12
- ERROR: Invalid router info, cannot continue HOT 3
- Cannot detect NOTIFY packets HOT 3
- Timeout expired while waiting for the gateway router to respond to M-SEARCH message HOT 9
- ESP32 arduino with Ethernet. HOT 19
- UPnP Errors 714 and 718 HOT 6
- TCP timeout while retrieving port mappings (ERROR: While updating UPnP port mapping. Failed with error code [5]) HOT 2
- Device is not discovered by UPnP Browser app. HOT 2
- Add an option to provide the description XML file to make setting the rules faster
- Error in UPnP ver. 3.1.4 HOT 6
- Esp32cam UPnP and EasyDDNS to No-Ip no connection HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tinyupnp.