W5500, webclient, а в ответ - тишина

Тема в разделе "Arduino & Shields", создана пользователем Фархад, 16 авг 2021.

  1. Фархад

    Фархад Нерд

    Всем привет! Кручу свой маленький проектик с веб сервером-клиентом. Поставил себе Postman, чтобы видеть, что отправляем и что получаем от сервера. Написал по примеру WebClient, запускаю, данные типа отправляются, а в ответ тишина... В чем причина не пойму, Postman показывает что на запрос Get сервер отдает информацию, а метод client.available() - молчит...
    Мой код:
    Код (C++):
    #include <SPI.h>
    #include <Ethernet2.h>

    // assign a MAC address for the ethernet controller.
    // fill in your address here:
    byte mac[] = {
      0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED
    };
    // fill in an available IP address on your network here,
    // for manual configuration:
    IPAddress ip(192, 10, 10, 5);

    // fill in your Domain Name Server address here:
    IPAddress myDns(192, 10, 10, 1);

    // initialize the library instance:
    EthernetClient client;

    char server[] = "sss.ru";

    unsigned long lastConnectionTime = 0;             // last time you connected to the server, in milliseconds
    const unsigned long postingInterval = 5000L; // delay between updates, in milliseconds
    // the "L" is needed to use long type numbers

    void setup() {
      // start serial port:
      Serial.begin(9600);
      while (!Serial) {
        ; // wait for serial port to connect. Needed for Leonardo only
      }

      // give the ethernet module time to boot up:
      delay(1000);
      // start the Ethernet connection using a fixed IP address and DNS server:
      Ethernet.begin(mac, ip, myDns);
      // print the Ethernet board/shield's IP address:
      Serial.print("My IP address: ");
      Serial.println(Ethernet.localIP());
    }

    unsigned long byteCount = 0;

    void loop() {
      if (client.available())
      {
        Serial.println("Data Receive");
      }

      if (millis() - lastConnectionTime > postingInterval) {
        httpRequest();
        lastConnectionTime = millis();
      }

    }

    // this method makes a HTTP connection to the server:
    void httpRequest() {
      // close any connection before send a new request.
      // This will free the socket on the WiFi shield
      client.stop();

      // if there's a successful connection:
      if (client.connect(server, 80)) {
        Serial.println("connecting...");  
        // send the HTTP PUT request:
        client.println("GET /getinfo HTTP/1.1");
        client.println("Host: sss.ru");
        client.println("User-Agent: arduino-ethernet");
        client.println("Connection: close");
        client.println();
        Serial.println("Send request OK");

        // note the time that the connection was made:
        lastConnectionTime = millis();
      }
      else {
        // if you couldn't make a connection:
        Serial.println("connection failed");
      }
    }
    А вот ответ через Postman
    HTML:

    GET http://sss.ru/getinfo
    200
    51 ms
    Network
    Request Headers
    User-Agent: PostmanRuntime/7.28.3
    Accept: */*
    Postman-Token: ac9b6e50-b24f-4df3-87dd-5f2f488af7e5
    Host: sss.ru
    Accept-Encoding: gzip, deflate, br
    Connection: keep-alive
    Response Headers
    Date: Mon, 16 Aug 2021 18:27:45 GMT
    Server: Apache/2.4.34 (Win64) OpenSSL/1.0.2o
    Content-Length: 4
    Keep-Alive: timeout=5, max=100
    Connection: Keep-Alive
    Response Body
    used
     
     
  2. Фархад

    Фархад Нерд

    Вопрос отпал.... поменял шилду - и все заработало...