Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTTP 301 error when using GsmSSLWebClient example #129

Open
per1234 opened this issue Apr 5, 2021 · 0 comments · May be fixed by #149
Open

HTTP 301 error when using GsmSSLWebClient example #129

per1234 opened this issue Apr 5, 2021 · 0 comments · May be fixed by #149
Labels
type: imperfection Perceived defect in any part of project

Comments

@per1234
Copy link
Contributor

per1234 commented Apr 5, 2021

The GsmSSLWebClient example attempts to access https://arduino.cc/asciilogo.txt, which has been moved to https://www.arduino.cc/asciilogo.txt, resulting in the response:

Starting Arduino web client.
connecting...
connected
HTTP/1.1 301 Moved Permanently
Server: nginx
Date: Mon, 05 Apr 2021 05:08:04 GMT
Content-Type: text/html
Content-Length: 178
Connection: close
Location: https://www.arduino.cc/asciilogo.txt
Strict-Transport-Security: max-age=500; includeSubDomains
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block

<html>
<head><title>301 Moved Permanently</title></head>
<body bgcolor="white">
<center><h1>301 Moved Permanently</h1></center>
<hr><center>nginx</center>
</body>
</html>

disconnecting.

I suppose it does still provide a demonstration, but not nearly so user friendly as the previous response:

Starting Arduino web client.
connecting...
connected
HTTP/1.1 200 OK
Server: nginx
Date: Mon, 05 Apr 2021 05:10:58 GMT
Content-Type: text/plain
Content-Length: 2263
Last-Modified: Wed, 02 Oct 2013 13:46:47 GMT
Connection: close
Vary: Accept-Encoding
ETag: "524c23c7-8d7"
Strict-Transport-Security: max-age=500; includeSubDomains
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block
Accept-Ranges: bytes


           `:;;;,`                      .:;;:.           
        .;;;;;;;;;;;`                :;;;;;;;;;;:     TM 
      `;;;;;;;;;;;;;;;`            :;;;;;;;;;;;;;;;      
     :;;;;;;;;;;;;;;;;;;         `;;;;;;;;;;;;;;;;;;     
    ;;;;;;;;;;;;;;;;;;;;;       .;;;;;;;;;;;;;;;;;;;;    
   ;;;;;;;;:`   `;;;;;;;;;     ,;;;;;;;;.`   .;;;;;;;;   
  .;;;;;;,         :;;;;;;;   .;;;;;;;          ;;;;;;;  
  ;;;;;;             ;;;;;;;  ;;;;;;,            ;;;;;;. 
 ,;;;;;               ;;;;;;.;;;;;;`              ;;;;;; 
 ;;;;;.                ;;;;;;;;;;;`      ```       ;;;;;`
 ;;;;;                  ;;;;;;;;;,       ;;;       .;;;;;
`;;;;:                  `;;;;;;;;        ;;;        ;;;;;
,;;;;`    `,,,,,,,,      ;;;;;;;      .,,;;;,,,     ;;;;;
:;;;;`    .;;;;;;;;       ;;;;;,      :;;;;;;;;     ;;;;;
:;;;;`    .;;;;;;;;      `;;;;;;      :;;;;;;;;     ;;;;;
.;;;;.                   ;;;;;;;.        ;;;        ;;;;;
 ;;;;;                  ;;;;;;;;;        ;;;        ;;;;;
 ;;;;;                 .;;;;;;;;;;       ;;;       ;;;;;,
 ;;;;;;               `;;;;;;;;;;;;                ;;;;; 
 `;;;;;,             .;;;;;; ;;;;;;;              ;;;;;; 
  ;;;;;;:           :;;;;;;.  ;;;;;;;            ;;;;;;  
   ;;;;;;;`       .;;;;;;;,    ;;;;;;;;        ;;;;;;;:  
    ;;;;;;;;;:,:;;;;;;;;;:      ;;;;;;;;;;:,;;;;;;;;;;   
    `;;;;;;;;;;;;;;;;;;;.        ;;;;;;;;;;;;;;;;;;;;    
      ;;;;;;;;;;;;;;;;;           :;;;;;;;;;;;;;;;;:     
       ,;;;;;;;;;;;;;,              ;;;;;;;;;;;;;;       
         .;;;;;;;;;`                  ,;;;;;;;;:         
                                                         
                                                         
                                                         
                                                         
    ;;;   ;;;;;`  ;;;;:  .;;  ;; ,;;;;;, ;;. `;,  ;;;;   
    ;;;   ;;:;;;  ;;;;;; .;;  ;; ,;;;;;: ;;; `;, ;;;:;;  
   ,;:;   ;;  ;;  ;;  ;; .;;  ;;   ,;,   ;;;,`;, ;;  ;;  
   ;; ;:  ;;  ;;  ;;  ;; .;;  ;;   ,;,   ;;;;`;, ;;  ;;. 
   ;: ;;  ;;;;;:  ;;  ;; .;;  ;;   ,;,   ;;`;;;, ;;  ;;` 
  ,;;;;;  ;;`;;   ;;  ;; .;;  ;;   ,;,   ;; ;;;, ;;  ;;  
  ;;  ,;, ;; .;;  ;;;;;:  ;;;;;: ,;;;;;: ;;  ;;, ;;;;;;  
  ;;   ;; ;;  ;;` ;;;;.   `;;;:  ,;;;;;, ;;  ;;,  ;;;;   

disconnecting.

I don't know what is the best fix. I found that the MKR GSM 1400 can not connect if I change server to www.arduino.cc:

Starting Arduino web client.
connecting...
connection failed

disconnecting.

server must remain arduino.cc while the Host header value is changed to www.arduino.cc:

diff --git a/examples/GsmSSLWebClient/GsmSSLWebClient.ino b/examples/GsmSSLWebClient/GsmSSLWebClient.ino
index 5ed2f65..94c02a1 100644
--- a/examples/GsmSSLWebClient/GsmSSLWebClient.ino
+++ b/examples/GsmSSLWebClient/GsmSSLWebClient.ino
@@ -33,6 +33,7 @@ GSM gsmAccess;

 // URL, path and port (for example: arduino.cc)
 char server[] = "arduino.cc";
+char host[] = "www.arduino.cc";
 char path[] = "/asciilogo.txt";
 int port = 443; // port 443 is the default for HTTPS

@@ -69,7 +70,7 @@ void setup() {
     client.print(path);
     client.println(" HTTP/1.1");
     client.print("Host: ");
-    client.println(server);
+    client.println(host);
     client.println("Connection: close");
     client.println();
   } else {

Originally reported at https://forum.arduino.cc/index.php?topic=735675

@per1234 per1234 added the type: imperfection Perceived defect in any part of project label Apr 5, 2021
@per1234 per1234 linked a pull request Apr 25, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: imperfection Perceived defect in any part of project
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant