问题描述
我一直试图将ESP8266连接到Web套接字,但到目前为止还没有运气。排除的事情是:
- ESP8266已连接到Wi-Fi并可以访问Internet(已通过HTTP请求检查)。
- 套接字服务器没有问题,我启动了自己的Web套接字服务器,但没有成功。
- 尝试使用端口80和443。
我的代码如下,继续打印
未连接!
:
#include <Arduino.h>
#include "WebSocketClient.h"
#include "ESP8266WiFi.h"
WebSocketClient ws(true);
void setup() {
Serial.begin(115200);
WiFi.begin("SSID","PASSWORD");
Serial.print("Connecting");
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
}
void loop() {
if (!ws.isConnected()) {
ws.connect("echo.websocket.org","/",80);
Serial.println("Not connected!");
} else {
ws.send("hello");
String msg;
if (ws.getMessage(msg)) {
Serial.println(msg);
}
}
delay(500);
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)