使用AT命令的ESP8266 websocket

时间:2017-08-05 16:42:00

标签: websocket esp8266 at-command

我正在尝试使用AT命令在ESP8266上实现websocket,并发送以下命令:

AT+CIPSTART = "TCP","My_IP_Address", 80

回应没问题

AT+CIPSEND = length_of Data\r\n

回应是     好     >

GET ws://My_IP_Address/ HTTP/1.1
Origin: http://My_IP_Address\r\n
Connection: Upgrade\r\n
Host: My_IP_Address\r\n
Upgrade: websocket\r\n
\r\n

回应如下:

+IPD,325:HTTP/1.1 400 Bad Request
Server: nginx/1.10.2
Date: Sat, 05 Aug 2017 16:04:12 GMT
Content-Type: text/html
Content-Length: 173
Connection: close

<html>
<head><title>400 Bad Request</title></head>
<body bgcolor="white">
<center><h1>400 Bad Request</h1></center>
<hr><center>nginx/1.10.2</center>
</body>
</html>
CLOSED

我收到了以下回复:

请告诉我出了什么问题?

由于 Gyanesh

1 个答案:

答案 0 :(得分:-1)

GET / HTTP / 1.1 \ r \ n 主持人:My_IP_Address \ r \ n 连接:升级\ r \ n 升级:websocket \ r \ n \ r \ n

而不是 获取ws:// My_IP_Address / HTTP / 1.1 来源:http://My_IP_Address 连接:升级\ r \ n 主持人:My_IP_Address \ r \ n 升级:websocket \ r \ n

...试