在ngrok上找不到404

问题描述 投票:0回答:1

我对ngrok和arduino有问题,我发送一条消息,但是当我打开ngrok时说:404未找到

我认为端口可能有问题,我使用4040,因为ngrok打开localhost:4040,但我不知道这是不是真的。 Java上的服务器端应用程序使用端口80

#include <ESP8266HTTPClient.h>
#include <ESP8266WiFi.h>

/* wifi network name */
char* ssidName = "mywifi";
/* WPA2 PSK password */
char* pwd = "mypwd";
/* service IP address */ 
char* address = "http://cf3c013e.ngrok.io";

void setup() { 
  Serial.begin(115200);                                
  WiFi.begin(ssidName, pwd);
  Serial.print("Connecting...");
  while (WiFi.status() != WL_CONNECTED) {  
    delay(500);
    Serial.print(".");
  } 
  Serial.println("Connected: \n local IP: "+WiFi.localIP());
}

int sendData(String address, float value, String place){  
   HTTPClient http;    
   http.begin(address + "/api/data");      
   http.addHeader("Content-Type", "application/json");     
   String msg = 
    String("{ \"value\": ") + String(value) + 
    ", \"place\": \"" + place +"\" }";
   int retCode = http.POST(msg);   
   http.end();  

   String payload = http.getString();  
   Serial.println(payload);      
   return retCode;
}

void loop() { 
 if (WiFi.status()== WL_CONNECTED){   

   /* read sensor */
   float value = (float) analogRead(A0) / 1023.0;

   /* send data */
   Serial.print("sending "+String(value)+"...");    
   int code = sendData(address, value, "home");

   /* log result */
   if (code == 200){
     Serial.println("ok");   
   } else {
     Serial.println("error");
   }
 } else { 
   Serial.println("Error in WiFi connection");   
 }

 delay(5000);  

}
http-status-code-404 ngrok
1个回答
0
投票

http://中删除char* address = "http://cf3c013e.ngrok.io";

地址中的http声明的倍增可能导致404。

© www.soinside.com 2019 - 2024. All rights reserved.