-
Notifications
You must be signed in to change notification settings - Fork 7.1k
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
esp_websocket_client ,example ,The connection between ESP32 and the server is normal. The ESP32 can receive the information sent by the server, but the server cannot receive the information reported by the ESP32. (IDFGH-2554) #4640
Comments
Could you please share the exact version of the esp-idf you use? There's an automated test in our CI that checks basic send/receive operation every master commit, so it seems unlikely to have the ws-send broken. Also as you're saying there's no error message in the ESP log then the server must accept the TCP packet (assuming that the packet was sent). |
I used the master version. I later confirmed that the message server sent by esp32 received it and successfully returned it. But the server is not displayed. I have used at least three tools to test that the server can display the reported messages, but the esp32 messages cannot be displayed. |
So do I understand correctly the the messages are correctly sent by the websocket client and received by the server? What do you mean by "not displayed"? What kind of websocket server you use? |
|
Sorry for the late reply, I cannot tell why the particular message is not displayed on your server GUI, but as if you're saying it's echo'ed back and received correctly that the server must treat it as a correct websocket message. As for the display issue, have you tried
|
Hi, i am starting to experiment with websockets and i dont know if this is the case, but i found that my websockets server is receiving data from esp32 as binary data (at least when i resend message from esp32 client in browser displays as binary data):
Maybe your server cant parse such message. This is how javascript is parsing it:
PS adding trailing 0x0 does not help |
Thank you for your reply. After reading Espressif's IDF source code, I have found this problem and reflected it to the server provider. The server is not compatible with binary data parsing and has been fixed. The default sending format of Espressif's SDK is binary file data. It also has a function for sending text data. I did not check the API carefully, which caused this problem. |
Yes, youre correct, i didnt study API too and didnt found additional functions.
|
When reading the demo, I didn't see any instructions. The sending function used in the demo is sending in binary form. I saw this problem only when checking the source code. The api has three send functions, namely send, send_bin and send_text, where the send and send_bin functions are the same |
@chenxiahuaxu Any suggestion what could be changed or could the issue be closed? |
@david-cermak I think that websocket example can be updated to use |
…lient_send_text() Closes espressif/esp-idf#4640 * Original commit: espressif/esp-idf@e5650d1
…lient_send_text() Closes espressif/esp-idf#4640 * Original commit: espressif/esp-idf@e5650d1
esp32 runs normally without error prompts. However, the server cannot receive the message reported by esp32. It is normal for the server to test with other tools.
Fix that the server can receive the message and can return it. But it can't be displayed. I wonder if there are any properties set by the esp library that caused the server to fail to display. (Other test tools test the server, the server can display the message normally, but the esp32 can't display it)
There is no error message on the ESP32 side. The sending procedure is as follows:
char data[32];
int i = 0;
while (1)
{
if (esp_websocket_client_is_connected(client))
{
int len = sprintf(data, "hello %04d", i++);
ESP_LOGI(TAG, "Sending:%s", data);
int err = esp_websocket_client_send_bin(client, data, len, portMAX_DELAY);
if (err == ESP_FAIL)
printf("ESP_FAIL\r\n");
else
printf("len:%d\r\n",err);
}
vTaskDelay(1000 / portTICK_RATE_MS);
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
ESP32 side running log is as follows:
W (252089) user_main: Received=kkjk
W (252099) user_main: Total payload length=4, data_len=4, current payload offset=0
I (252599) user_main: WEBSOCKET_EVENT_DATA
I (252599) user_main: Received opcode=1
W (252599) user_main: Received=kkjk
W (252609) user_main: Total payload length=4, data_len=4, current payload offset=0
I (252759) user_main: Sending:hello 0245
len:10
I (253759) user_main: Sending:hello 0246
len:10
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
The server-side operation log is as follows:
<----- 接收:2020-01-17 14:28:18
连接:ws://192.168.191.3:8443/ - 192.168.191.7:61271
<----- 接收:2020-01-17 14:28:18
connection:Upgrade
host:192.168.191.3:8443
sec-websocket-key:HudC7xAIDs7v7lNg99CDdg==
sec-websocket-version:13
upgrade:websocket
user-agent:ESP32 Websocket Client
-----> 发送:2020-01-17 14:32:22
192.168.191.7:61271: kkjk
-----> 发送:2020-01-17 14:32:23
192.168.191.7:61271: kkjk
-----> 发送:2020-01-17 14:32:23
192.168.191.7:61271: kkjk
The text was updated successfully, but these errors were encountered: