amazon ec2 - Arduino Ethernet client.available() not working -


i want send request amazon ec2 server, need get request work in fashion. that, trying send request google test.

i using arduino uno ethernet shield connected internet via dhcp.

my issue although client.connect() seems work, client.available doesn't work either google or ec2 server. although, if issue lies elsewhere, please tell me.

i able ping google , telnet request simulation using: -telnet www.google.com 80 -get /search?q=arduino http/1.0

arduino code:

#include <spi.h> #include <ethernet.h>  // enter mac address , ip address controller below. // ip address dependent on local network: byte mac[] = { 0x90, 0xa2, 0xda, 0x0f, 0xd2, 0xaf };  //byte mac[] =   {0xf0, 0x1f, 0xaf, 0x33, 0x62, 0x2f };  ipaddress ip(192,168,1,11);  // initialize library instance: ethernetclient client;  //char server[] = "ec2-54-69-168-77.us-west-2.compute.amazonaws.com"; char server[] = "www.google.com";  double dummyvalue = 7.5;  void setup() {   serial.begin(9600);    // attempt dhcp connection:   serial.println("attempting ip address using dhcp:");   if (!ethernet.begin(mac)) {     // if dhcp fails, start hard-coded address:     serial.println("failed ip address using dhcp, trying manually");     ethernet.begin(mac, ip);   }    serial.print("my address:");   serial.println(ethernet.localip()); }  void loop() {     // connect server     for(int = 0;i <100 ; i++) {       if (client.connect(server, 80)) {         // print serial monitor         serial.println("connected...");         serial.println("arduino: forming http request message");          // send data server through request         //client.print("get /~sclaybon3/firstdatatest.php?reading=3 http/1.0\r\n");         client.print("get /search?q=arduino http/1.0\r\n");         serial.println("get request");         //client.print(dummyvalue);         //client.print(" http/1.1");         //client.print("host: ec2-54-69-168-77.us-west-2.compute.amazonaws.com\r\n");         client.print("host: www.google.com\r\n");         //serial.println("host:www.google.com");         //client.print("connection: close\r\n\r\n");         client.print("\r\n");           serial.println("arduino: http message sent");                  // give server time receive , store data         // before asking response         delay(1000);          // response page , print serial port         // ascertain data received         if(client.available())         {             serial.println("arduino: http message received");             serial.println("arduino: printing received headers , script response...\n");              while(client.available())             {                 char c = client.read();                 serial.print(c);             }         }         else         {             serial.println("arduino: no response received / no response received in time");         }          client.stop();     }     }       // nothing forever after:     while(true); } 

arduino output:

attempting ip address using dhcp: address:192.168.1.11 connected... arduino: forming http request message request arduino: http message sent arduino: no response received / no response received in time 


Comments

Popular posts from this blog

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -