I can not reach some servers

Hallo!
with my Arduino UNO and Ethernet Shield based on enc28j60 I am trying to read few bytes from a webpage.
The problem is, I can not connect to the server I need to. On some servers my code works (www.google.com, forum.arduino.cc), and on some others it doesn’t (www.seznam.cz, www.endora.cz). No matter if I use server names or IP adresses. Can someone provide a clue, what is wrong?

#include <UIPEthernet.h>
#include <SPI.h>

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
char server1[] = { "forum.arduino.cc"};
char server2[] = { "www.endora.cz"};
bool Run2nd = false;

EthernetClient client;

void setup()
{
  Serial.begin(9600);
  Serial.println("Start...");
  Ethernet.begin(mac);
}

void loop()
{
  Serial.println();
  Serial.print("connecting to ");
  if (Run2nd == false)
  {
    Run2nd = true;
    Serial.println(server1);
    client.connect(server1, 80);
  }
  else
  {
    Run2nd = false;
    Serial.println(server2);
    client.connect(server2, 80);
  }
  delay(1000);


  if (client.connected()) {
    Serial.println("connected");
    client.println("GET / HTTP/1.0");
    client.println();
  } else {
    Serial.println("connection failed");
  }


  while (client.connected())
  {
    if (client.available() > 0) {
      char c = client.read();
      // Serial.print(c);
    }

    if (!client.connected()) {
      Serial.println("Connection succesfull, disconnecting.");
      client.stop();
      delay(3000);
    }
  }
}

Problem is, servers seznam.cz and endora.cz are using HTTPS protocol (that is using encryption) port 443.
ENC28J60 (Arduino) only supports HTTP protocol, port 80. It doesnt have implementation and also CPU power to make HTTPS connection. Also you are connecting to port 80 in your sketch.
Based on that, these domains are using HSTS service (redirect to HTTPS only), you CAN NOT connect to them.

If you have project at endora.cz at freehosting, it is working under HTTP, so sketch will work for HTTP connection.
If you want encrypted connection support, switch to some WiFi microcontrollers such as ESP8266 / ESP32.
I have several projects at endora.cz freehosting, for instance: Hladinomer - prehľad posledných nameraných údajov where I can connect with Arduino and ENC28J60 via HTTP protocol without any problem.

Great clue, thank You very much. I have known, i have to avoid https. No problem for my project. What I didn't realize was, I get no conection on Port 80. Will try Port 443, thank You.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.