Your new topic does not fit any of the above??? Check first. Then post here. Thanks.

Moderator: igrr

User avatar
By SwiCago
#21376
burkmurray wrote:
For fun, I added some debugging in DNSServer.ccp to see what Android was doing as soon as it connects. This is what it spits out.
...
DNS responds: 192.168.1.1 for connectivitycheck.android.com

Your debug responses are super handy - are you grabbing that from replyWithIP? Mind sharing a code snip?



DNSServer.ccp replyWithIP extra logging
Code: Select allvoid DNSServer::replyWithIP()
{
  _dnsHeader->QR = DNS_QR_RESPONSE;
  _dnsHeader->ANCount = _dnsHeader->QDCount;
  _dnsHeader->QDCount = 0;

  _udp.beginPacket(_udp.remoteIP(), _udp.remotePort());
  _udp.write(_buffer, _currentPacketSize);
  _udp.write((unsigned char*)&_ttl, 4);
  // Length of RData is 4 bytes (because, in this case, RData is IPv4)
  _udp.write((uint8_t)0);
  _udp.write((uint8_t)4);
  _udp.write(_resolvedIP, sizeof(_resolvedIP));
  _udp.endPacket();
//*********************************************************
  Serial.print("DNS responds: ");
  Serial.print(_resolvedIP[0]);
  Serial.print(".");
  Serial.print(_resolvedIP[1]);
  Serial.print(".");
  Serial.print(_resolvedIP[2]);
  Serial.print(".");
  Serial.print(_resolvedIP[3]);
  Serial.print(" for ");
  Serial.println(getDomainNameWithoutWwwPrefix());
}


burkmurray wrote:Also, have you tried plugging connectivitycheck.android.com into a server.on() test?
Code: Select allserver.on("connectivitycheck.android.com", handle_root);



I don't see how that will work, if it never connects to the webserver after the DNS request. To me it seems that android and windows do not understand the response from the DNS server, hence constantly repeating over and over. Neither ever attempt to connect to the webserver.

burkmurray wrote:Finally, I've been trying to figure out how to navigate Apple's CNA, and the one thing that consistently works is sending the word "Success" in the head of a message:
Code: Select all"<!DOCTYPE html><html><head><title>Success</title></head><body>"


I've read that Google uses a similar approach - might be worth a shot.


You suggest returning the above html snippet, if it actually makes contact with the websrever part?

I am starting to wonder if Android and Windows attempt to contact home via a different port? Maybe trying to contact a UDP webserver instead of a TCP webserver???
I may have to setup up a TCPDUMP at home on my wifi and see what the heck Android does as soon as wifi is enabled.
User avatar
By burkmurray
#21435
I don't see how that will work, if it never connects to the webserver after the DNS request. To me it seems that android and windows do not understand the response from the DNS server, hence constantly repeating over and over. Neither ever attempt to connect to the webserver.

How are you detecting whether it's trying to connect? Your "Page served" message only prints if the client makes it to handle_root(), but any request with a URI fails and doesn't have a handler.

I managed to get a cup of coffee and an hour without my kids and had a closer look at knovoselic's code - try adding:
Code: Select allserver.onNotFound(handleNotFound);
before your server.begin();

Then add a handler function - this one prints the URI on your console:
Code: Select allvoid handleNotFound() {
  Serial.print("\t\t\t\t URI Not Found: ");
  Serial.println(server.uri());
  server.send ( 200, "text/plain", "URI Not Found" );
}

Also, uncomment
Code: Select all#define DEBUG
in ESP8266WebServer.cpp - it's showing me that the iPad is connecting as a client, but failing to find a request handler.

Hope that helps,

B
User avatar
By SwiCago
#21437
burkmurray wrote:
I don't see how that will work, if it never connects to the webserver after the DNS request. To me it seems that android and windows do not understand the response from the DNS server, hence constantly repeating over and over. Neither ever attempt to connect to the webserver.

How are you detecting whether it's trying to connect? Your "Page served" message only prints if the client makes it to handle_root(), but any request with a URI fails and doesn't have a handler.

I managed to get a cup of coffee and an hour without my kids and had a closer look at knovoselic's code - try adding:
Code: Select allserver.onNotFound(handleNotFound);
before your server.begin();

Then add a handler function - this one prints the URI on your console:
Code: Select allvoid handleNotFound() {
  Serial.print("\t\t\t\t URI Not Found: ");
  Serial.println(server.uri());
  server.send ( 200, "text/plain", "URI Not Found" );
}

Also, uncomment
Code: Select all#define DEBUG
in ESP8266WebServer.cpp - it's showing me that the iPad is connecting as a client, but failing to find a request handler.

Hope that helps,

B


Tried server.on("connectivitycheck.android.com", handle_root);
Never get "Page served" or "New client"
Tried "server.onNotFound(handleNotFound);" and added the function exactly as you pasted above.
Never enters this, when I type any URI...so never get "New client"
The browser just keeps spinning and spinning and eventually times out.

But if I enter IP, then "Page served" and DEBUG output of webserver prints "New client"
The only time it prints "request handler not found" is when the stupid browser attempts to get favicon.ico after entering IP address only!
Page served
New client
request handler not found
URI Not Found: /favicon.ico



All samples I have seen for server.on start with "/"..the webserver listens on port 80 on ip 192.168.1.1. A browser does not do http://www.test.com/ALL , but rather does DNS http://www.test.com => 192.168.1.1 and then 192.168.1.1/ALL ...this is all transparent to us on the browser level. on the browser it shows uri, but behind the scenes it is IP. the webserver does not care about full uri, just what is after the first /...this is same for apache etc...yes you can detect domain via headers and forward to virtual hosts within apache, but this is not apache.

So, did a TCPdump and this is the result

tcpdump -vvv -s 0 -l -n port 53

//LOOKING FOR connectivitycheck.android.com
23:44:01.503097 IP (tos 0x0, ttl 64, id 0, offset 0, flags [DF], proto UDP (17), length 91)
192.168.1.12.53 > 192.168.1.72.35857: [bad udp cksum d32d!] 4642 q: A?
connectivitycheck.android.com. 1/0/0 connectivitycheck.android.com. [55s] A 216.58.216.78 (63)
0x0000: 4500 005b 0000 4000 4011 b6ed c0a8 010c E..[..@.@.......
0x0010: c0a8 0148 0035 8c11 0047 83fd 1222 8180 ...H.5...G..."..
0x0020: 0001 0001 0000 0000 1163 6f6e 6e65 6374 .........connect
0x0030: 6976 6974 7963 6865 636b 0761 6e64 726f ivitycheck.andro
0x0040: 6964 0363 6f6d 0000 0100 01c0 0c00 0100 id.com..........
0x0050: 0100 0000 3700 04d8 3ad8 4e ....7...:.N
//responds that connectivitycheck.android.com is really http://www.google.com
23:44:01.551537 IP (tos 0x0, ttl 64, id 1460, offset 0, flags [DF], proto UDP (17), length 60)
192.168.1.72.35462 > 192.168.1.12.53: [udp sum ok] 61036+ A? http://www.google.com. (32)
0x0000: 4500 003c 05b4 4000 4011 b158 c0a8 0148 E..<..@.@..X...H
0x0010: c0a8 010c 8a86 0035 0028 7429 ee6c 0100 .......5.(t).l..
0x0020: 0001 0000 0000 0000 0377 7777 0667 6f6f .........www.goo
0x0030: 676c 6503 636f 6d00 0001 0001 gle.com.....
//LOOKING FOR http://www.google.com and gets IP response "d83ad8c4" which is 216.58.216.196, no trailing
23:44:01.552676 IP (tos 0x0, ttl 64, id 0, offset 0, flags [DF], proto UDP (17), length 76)
192.168.1.12.53 > 192.168.1.72.35462: [bad udp cksum fe69!] 61036 q: A? http://www.google.com. 1/0/0 http://www.google.com. [29s] A 216.58.216.196 (48)
0x0000: 4500 004c 0000 4000 4011 b6fc c0a8 010c E..L..@.@.......
0x0010: c0a8 0148 0035 8a86 0038 83ee ee6c 8180 ...H.5...8...l..
0x0020: 0001 0001 0000 0000 0377 7777 0667 6f6f .........www.goo
0x0030: 676c 6503 636f 6d00 0001 0001 c00c 0001 gle.com.........
0x0040: 0001 0000 001d 0004 d83a d8c4 .........:..

DNSServer.ccp from what I can tell ends also with just IP, but if it is 100% identical I have no clue...after this point android connects to 216.58.216.196 on port 443

ANd to re-iterate CaptivePortal.ino from
https://github.com/knovoselic/Arduino/b ... Portal.ino (I uploaded it again to the ESP01) works fine in iOS, but not Android or Windows ...again, DNS lookups repeat and browser just spins till it times out!
User avatar
By burkmurray
#21439
Tried server.on("connectivitycheck.android.com", handle_root);

That makes sense - it's not a URI.

Tried "server.onNotFound(handleNotFound);" and added the function exactly as you pasted above.
Never enters this, when I type any URI...so never get "New client"
The browser just keeps spinning and spinning and eventually times out.

Hmm - this is with your Nexus/Android? With my iPad, I see "New client" and "request handler not found" on my console as soon as it connects to the AP and tries to connect to Apple. Not sure it makes a difference, but I also have
Code: Select allSerial.setDebugOutput(true);

right after my serial.begin().

I'll have a closer look at your dump later tonight. Were you able to extract a URI from the "connectivitycheck.android.com" request? The Apple ones are long and random, but all point to success.html.