getting a 404 not found error. [SOLVED]
ajwtech opened this issue ยท 7 comments
@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
I modified the TinyUPnP.cpp to search for and use the controlURL instead of the eventSubURL and it worked like a charm!
One more thing that should be pointed out. As I understand it any lease duration above 0 will not show up in upnp. nor will it be reported out from upnp. If I set my lease duration to 0 I do see the port when all the ports are returned.
I also have noticed that quite a few routers respond with a 500 error when your index is outside the bounds of existing upnp mappings. I added
} else if (line.indexOf("HTTP/1.1 500 Internal Server Error") >= 0) {
debugPrint("internal server error (likely because we have shown all the mappings");
reachedEnd = true;
to printallportmappings to fix this.
@ajwtech
Thank you, sir, for the contribution! :) I will add these changes to the emptyUrlBase
branch.
I would appreciate if you can tell me whether you used the master
branch or the emptyUrlBase
branch.
If it is the latter I will merge it (and will be able to close an issue too).
After that I will be able to add a few more changes, better API and adding a DDNS update service to the example which might be helpful too.
This is really awesome that you shared this with me, again, thank you.
@ofekp I used the emptyUrlBase
branch, but I made all of my changes locally. I also wanted to point out that I am running custom firmware on my router. It is running DD-wrt So I would think would would be able to hit a pretty large market by making these changes.
Thank you @ajwtech
Aready added the changes to the branch, I will run it on my device and will merge.
Then I will add the DDNS support and better API which also validates the insertion of the rule.
Thanks again for the help! :)