Problem in soapSSDPquery
Closed this issue · 6 comments
First of all, thanks for sharing this great library!
For a start I just tried the ScanForMediaServers examle and run into a problem. Here is the relevant part of my log:
[E][SoapESP32.cpp:248] soapSSDPquery(): SSDP packet content:
HTTP/1.1 200 OK
LOCATION: http://192.168.0.104:6661/
EXT:
SERVER: DNS-320L, UPnP/1.0, POSIX/1.0
USN: uuid:60eefbcf-0d18-1321-bc47-ec2280a4cb7e::urn:schemas-upnp-org:device:MediaServer:1
CACHE-CONTROL: max-age=1811
ST: urn:schemas-upnp-org:device:MediaServer:1
Date: Sun, 06 Feb 2022 18:13:42 GMT
[D][SoapESP32.cpp:269] soapSSDPquery(): scanned ip=192.168.0.104, port=6661, location=EXT:
The probelm is that location become "EXT" instead of an empty string, so later the program tries to open http://192.168.0.104:6661/EXT instead of http://192.168.0.104:6661/ and get a HTTP 404 error.
I think the problem is somewhere here:
snprintf(format, sizeof(format), "http://%%[0-9.]:%%d/%%%ds", SSDP_LOCATION_BUF_SIZE - 1);
if (sscanf(p + 10, format, address, &port, location) != 3) continue;
but I am a beginner in c and can't find the solution. Any idea?
Tx for the info. That "location:" string is highly unusual but I smell where the problem is.
Will come back to you.
If its not too much trouble for you: Please connect to "http://192.168.0.104:6661/" with any web browser and log the whole request/answer sequence with wireshark for me (Follow->TCP stream).
Thanks !
dlink_follow.txt
I hope it helps. Please let me know, If you need more info.
Attached a modified SoapESP32.cpp for you to try. Pls set CORE_DEBUG_LEVEL=5 and provide me the serial output.
Tx Th
SoapESP32.zip
This solved the problem, thank you!
Here is the serial output:
rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0018,len:4
load:0x3fff001c,len:1044
load:0x40078000,len:10124
load:0x40080400,len:5828
entry 0x400806a8
Connecting to WiFi network [D][WiFiGeneric.cpp:374] _eventCallback(): Event: 0 - WIFI_READY
[D][WiFiGeneric.cpp:374] _eventCallback(): Event: 2 - STA_START
.....[D][WiFiGeneric.cpp:374] _eventCallback(): Event: 4 - STA_CONNECTED
[D][WiFiGeneric.cpp:374] _eventCallback(): Event: 7 - STA_GOT_IP
[D][WiFiGeneric.cpp:419] _eventCallback(): STA IP: 192.168.0.13, MASK: 255.255.255.0, GW: 192.168.0.1
Connected successfully.
IP address: 192.168.0.13
Scanning local network for DLNA media servers...
[I][SoapESP32.cpp:478] seekServer(): SSDP search for media servers started
[D][SoapESP32.cpp:241] soapSSDPquery(): received SSDP packet within 25 ms: packet size: 306
[V][SoapESP32.cpp:247] soapSSDPquery(): SSDP packet content:
HTTP/1.1 200 OK
LOCATION: http://192.168.0.104:6661/
EXT:
SERVER: DNS-320L, UPnP/1.0, POSIX/1.0
USN: uuid:60eefbcf-0d18-1321-bc47-ec2280a4cb7e::urn:schemas-upnp-org:device:MediaServer:1
CACHE-CONTROL: max-age=1811
ST: urn:schemas-upnp-org:device:MediaServer:1
Date: Tue, 08 Feb 2022 06:40:53 GMT
[D][SoapESP32.cpp:268] soapSSDPquery(): scanned ip=192.168.0.104, port=6661, location=""
[W][SoapESP32.cpp:269] soapSSDPquery(): empty location string!
[D][SoapESP32.cpp:241] soapSSDPquery(): received SSDP packet within 2068 ms: packet size: 306
[V][SoapESP32.cpp:247] soapSSDPquery(): SSDP packet content:
HTTP/1.1 200 OK
LOCATION: http://192.168.0.104:6661/
EXT:
SERVER: DNS-320L, UPnP/1.0, POSIX/1.0
USN: uuid:60eefbcf-0d18-1321-bc47-ec2280a4cb7e::urn:schemas-upnp-org:device:MediaServer:1
CACHE-CONTROL: max-age=1811
ST: urn:schemas-upnp-org:device:MediaServer:1
Date: Tue, 08 Feb 2022 06:40:55 GMT
[D][SoapESP32.cpp:268] soapSSDPquery(): scanned ip=192.168.0.104, port=6661, location=""
[W][SoapESP32.cpp:269] soapSSDPquery(): empty location string!
[I][SoapESP32.cpp:481] seekServer(): SSDP query discovered 1 media servers
[I][SoapESP32.cpp:484] seekServer(): checking all discovered media servers for service ContentDirectory
[D][SoapESP32.cpp:1155] soapGet(): 192.168.0.104:6661 GET / HTTP/1.1
[I][SoapESP32.cpp:498] seekServer(): connected successfully to server 192.168.0.104:6661
[V][SoapESP32.cpp:312] soapReadHttpHeader(): header line: HTTP/1.1 200 OK
[V][SoapESP32.cpp:329] soapReadHttpHeader(): header line: CONTENT-TYPE: text/xml; charset="utf-8"
[V][SoapESP32.cpp:329] soapReadHttpHeader(): header line: Server: POSIX, UPnP/1.0, DNS-320L/1.0
[V][SoapESP32.cpp:329] soapReadHttpHeader(): header line: Date: Tue, 08 Feb 2022 06:40:57 GMT
[V][SoapESP32.cpp:329] soapReadHttpHeader(): header line: Transfer-Encoding: chunked
[V][SoapESP32.cpp:329] soapReadHttpHeader(): header line:
[D][SoapESP32.cpp:348] soapReadHttpHeader(): HTTP-Header ok, trailing content is chunked, no size announced
[D][SoapESP32.cpp:398] soapReadXML(): announced chunk size: 0x8a5, 2213
[D][SoapESP32.cpp:527] seekServer(): scanned friendly name: dlink-NAS
[D][SoapESP32.cpp:537] seekServer(): server offers service: urn:schemas-upnp-org:service:ContentDirectory:1
[D][SoapESP32.cpp:554] seekServer(): assigned controlURL: ContentDirectory/control
[I][SoapESP32.cpp:555] seekServer(): ok, this server delivers media content
Number of discovered servers that deliver content: 1
Server[1]: IP address: 192.168.0.104, port: 6661, name: dlink-NAS
-> controlURL: ContentDirectory/control
Sketch finished.
Thats great, tx for the info. If you like the library, please give it a star. Regards Thomas