OkHttp 连接 ESP8266 失败

OkHttp fails to connect to ESP8266

我正在尝试从我的 Android phone 向 ESP8266 发送一个简单的 HTTP 请求。我正在关注 this tutorial. The code works for the URL used in the tutorial (https://reqres.in/api/users?page=2),但不是为了打开 ESP8266 上的 LED 的 URL。 (虽然可以通过浏览器打开 LED,所以它必须与代码有关)。 URL 是 https://192.168.137.78/led/1.
堆栈跟踪很长,但这是第一个错误,

2020-06-13 12:55:55.948 13594-13631/com.example.esp W/System.err: java.net.ConnectException: Failed to connect to /192.168.137.78:443

堆栈跟踪的其余部分:

2020-06-13 12:55:55.948 13594-13631/com.example.esp W/System.err: java.net.ConnectException: Failed to connect to /192.168.137.78:443
    2020-06-13 12:55:55.949 13594-13631/com.example.esp W/System.err:     at okhttp3.internal.connection.RealConnection.connectSocket(RealConnection.kt:285)
    2020-06-13 12:55:55.949 13594-13631/com.example.esp W/System.err:     at okhttp3.internal.connection.RealConnection.connect(RealConnection.kt:195)
    2020-06-13 12:55:55.950 13594-13631/com.example.esp W/System.err:     at okhttp3.internal.connection.ExchangeFinder.findConnection(ExchangeFinder.kt:249)
    2020-06-13 12:55:55.950 13594-13631/com.example.esp W/System.err:     at okhttp3.internal.connection.ExchangeFinder.findHealthyConnection(ExchangeFinder.kt:108)
    2020-06-13 12:55:55.950 13594-13631/com.example.esp W/System.err:     at okhttp3.internal.connection.ExchangeFinder.find(ExchangeFinder.kt:76)
    2020-06-13 12:55:55.951 13594-13631/com.example.esp W/System.err:     at okhttp3.internal.connection.RealCall.initExchange$okhttp(RealCall.kt:245)
    2020-06-13 12:55:55.951 13594-13631/com.example.esp W/System.err:     at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.kt:32)
    2020-06-13 12:55:55.951 13594-13631/com.example.esp W/System.err:     at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:100)
    2020-06-13 12:55:55.951 13594-13631/com.example.esp W/System.err:     at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.kt:96)
    2020-06-13 12:55:55.952 13594-13631/com.example.esp W/System.err:     at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:100)
    2020-06-13 12:55:55.952 13594-13631/com.example.esp W/System.err:     at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.kt:83)
    2020-06-13 12:55:55.952 13594-13631/com.example.esp W/System.err:     at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:100)
    2020-06-13 12:55:55.953 13594-13631/com.example.esp W/System.err:     at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.kt:76)
    2020-06-13 12:55:55.953 13594-13631/com.example.esp W/System.err:     at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:100)
    2020-06-13 12:55:55.953 13594-13631/com.example.esp W/System.err:     at okhttp3.internal.connection.RealCall.getResponseWithInterceptorChain$okhttp(RealCall.kt:197)
    2020-06-13 12:55:55.954 13594-13631/com.example.esp W/System.err:     at okhttp3.internal.connection.RealCall$AsyncCall.run(RealCall.kt:502)
    2020-06-13 12:55:55.954 13594-13631/com.example.esp W/System.err:     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
    2020-06-13 12:55:55.954 13594-13631/com.example.esp W/System.err:     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
    2020-06-13 12:55:55.955 13594-13631/com.example.esp W/System.err:     at java.lang.Thread.run(Thread.java:919)
    2020-06-13 12:55:55.956 13594-13631/com.example.esp W/System.err: Caused by: java.net.ConnectException: failed to connect to /192.168.137.78 (port 443) from /192.168.137.82 (port 42408) after 10000ms: isConnected failed: ECONNREFUSED (Connection refused)
    2020-06-13 12:55:55.956 13594-13631/com.example.esp W/System.err:     at libcore.io.IoBridge.isConnected(IoBridge.java:288)
    2020-06-13 12:55:55.957 13594-13631/com.example.esp W/System.err:     at libcore.io.IoBridge.connectErrno(IoBridge.java:193)
    2020-06-13 12:55:55.957 13594-13631/com.example.esp W/System.err:     at libcore.io.IoBridge.connect(IoBridge.java:135)
    2020-06-13 12:55:55.957 13594-13631/com.example.esp W/System.err:     at java.net.PlainSocketImpl.socketConnect(PlainSocketImpl.java:142)
    2020-06-13 12:55:55.957 13594-13631/com.example.esp W/System.err:     at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:390)
    2020-06-13 12:55:55.958 13594-13631/com.example.esp W/System.err:     at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:230)
    2020-06-13 12:55:55.958 13594-13631/com.example.esp W/System.err:     at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:212)
    2020-06-13 12:55:55.959 13594-13631/com.example.esp W/System.err:     at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:436)
    2020-06-13 12:55:55.959 13594-13631/com.example.esp W/System.err:     at java.net.Socket.connect(Socket.java:621)
    2020-06-13 12:55:55.959 13594-13631/com.example.esp W/System.err:     at okhttp3.internal.platform.Platform.connectSocket(Platform.kt:120)
    2020-06-13 12:55:55.960 13594-13631/com.example.esp W/System.err:     at okhttp3.internal.connection.RealConnection.connectSocket(RealConnection.kt:283)
    2020-06-13 12:55:55.960 13594-13631/com.example.esp W/System.err:   ... 18 more
    2020-06-13 12:55:55.961 13594-13631/com.example.esp W/System.err: Caused by: android.system.ErrnoException: isConnected failed: ECONNREFUSED (Connection refused)
    2020-06-13 12:55:55.961 13594-13631/com.example.esp W/System.err:     at libcore.io.IoBridge.isConnected(IoBridge.java:275)
    2020-06-13 12:55:55.961 13594-13631/com.example.esp W/System.err:   ... 28 more

您发送的是 HTTPS 请求,而不是 HTTP 请求。您尚未在 ESP8266 上共享您 运行 的代码,但我敢打赌它是 HTTP 服务器而不是 HTTPS 服务器。将您尝试连接的 URL 更改为 http:// 而不是 https://.