Page 1 of 1
error while connecting to server via WebSocket, esp-wrover-b
Posted: Tue May 16, 2023 3:51 pm
by SauliusJ
Hello,
while connecting to a TCP server with a websocket, i am unable to receive a handshake. esp_transport_connect() function fails, errno = 128, esp-tls error code - 0x8008, ESP_ERR_ESP_TLS_TCP_CLOSED_FIN. Logs "Error read response for Upgrade header GET / HTTP/1.1".
Could someone lead me towards elimination of this problem? I am unable to find a lot of information about this error and not able to understand it completely. Is there something crucial I could be missing?
Using esp-idf v5.0 framework, have migrated the espressif esp_websocket_client library.
Any help is appreciated, thanks in advance
Saulius J
Re: error while connecting to server via WebSocket, esp-wrover-b
Posted: Wed May 17, 2023 10:00 am
by MicroController
connecting to a TCP server with a websocket
You mean "HTTP server", right?
https://en.wikipedia.org/wiki/HTTP/1.1_ ... _WebSocket
Does the server support WebSockets?
Re: error while connecting to server via WebSocket, esp-wrover-b
Posted: Thu May 18, 2023 10:10 am
by SauliusJ
in my knowledge, a HTTP server is a TCP server, just one level higher.
Yes, the server is able to receive WS connections. However, when connecting to the correct uri, the server does not see the connection, however, the error is, as mentioned before, ESP_ERR_ESP_TLS_TCP_CLOSED_FIN. From what I google'd, "<..> 0x8008 means ESP_ERR_ESP_TLS_TCP_CLOSED_FIN. In other words, a TCP connection had been established successfully but unexpectedly, the connection has been closed by the server. This is often caused by the server software crashing, or restarting in some way. When a server process is terminated, the operating system will cleanup after it and close all connections.<...>"
I am unable to find a solution to this problem. Any (even the smallest of) tips are appreciated !
Re: error while connecting to server via WebSocket, esp-wrover-b
Posted: Thu May 18, 2023 3:02 pm
by SauliusJ
I think I found my problem - I was trying to upgrade TCP to WS, without going TCP -> HTTP first.
Going to check whether that was the problem.
Re: error while connecting to server via WebSocket, esp-wrover-b
Posted: Thu May 18, 2023 10:27 pm
by MicroController
connection had been established successfully but unexpectedly, the connection has been closed by the server. This is often caused by
client and server getting "out-of-sync" with a common protocol, or using incompatible protocols, where the client sends a certain request to the server and expects a certain response, while the server does not understand the request, possibly returns an error response (which the client does not recognize), and then closes the connection.
trying to upgrade TCP to WS, without going TCP -> HTTP first.
Not sure what you mean by that. Normally, you'd use an HTTP client to connect and communicate with an HTTP server, without ever touching the TCP layer (aside from potentially specifying a (TCP) port number with the URL). The HTTP client should also handle the TLS layer between TCP and HTTP for you, which you really don't want to do yourself.
Maybe check out
https://components.espressif.com/compon ... ket_client