android - Issue using HTTP POST/PUT through no-ip -


i have project i'm controlling arduino @ house using android app through wan. i'm using mit's app inventor design app , i'm using http put/post (i've tried both) send string of information "hellothere" arduino. has been fine while broadcasting directly ip address , port number. arduino output (i've obfusticated ip , port):

put / http/1.1 user-agent: dalvik/1.6.0 (linux; u; android 4.4.4; gt-i9305 build/ktu84p) host: xx.xx.xx.xx:xxxx connection: keep-alive accept-encoding: gzip content-type: application/x-www-form-urlencoded content-length: 10  hellothere 

the problem arises when use ddns (no-ip) refer ip address (as dynamic). reason put/post request not carried out when getting relayed through this. output arduino shown below when using ddns:

get / http/1.1 user-agent: dalvik/1.6.0 (linux; u; android 4.4.4; gt-i9305 build/ktu84p) host: xx.xxx.xx.xx:xxxx connection: keep-alive accept-encoding: gzip 

somehow changing request instead of put/post, still contacting device. i'll honest, i'm not web guy i'm pretty confused this, ddns not supposed relay whatever send it? i've had around , can't find on this, or explanation appreciated.

edit: after doing lot of further research have figured out ddns server returns ip address of desired hostname when queried. have idea address , port no ip use this? aware windows uses "nslookup" perform this, have no idea how achieved on arduino. on udp or http. again, has experience in area appreciated.

alright, solved issue of interested. here's arduino code retrieve ip:

char server1[] = "xxxxxxxxxxxx.ddns.net"; //server ping external ip address if (currentmillis - previousmillis >= interval) { previousmillis = currentmillis; if (client1.connect(server1, 80)) { // if connection output serial:   serial.println("connected");   client1.println("get / http/1.0");  //make http request:   client1.println("host: xxxxxxxxxxxx.ddns.net");   client1.println("connection: close");   client1.println();   delay(1200); } while (client1.available()) { //loop read html external server , take ip   char c = client1.read();   httparray [counter] = c; // copy data buffer array   counter++; } 

Comments

Popular posts from this blog

how to insert data php javascript mysql with multiple array session 2 -

multithreading - Exception in Application constructor -

windows - CertCreateCertificateContext returns CRYPT_E_ASN1_BADTAG / 8009310b -