Websockets FreeRTOS V9.0.0 STM32F4

comulle wrote on Wednesday, May 09, 2018:

Hi all,

trying to add websockets to my project.
For a first test, I adapted the delivered freeRTOS DEMO 9.0.0 for STM32 discovery to my own f427 project.

TCP/IP works fine, I have access to my web- anf ftpserver, can read files from SD card etc, nut I am missing a websocket communication between the hardware and the ui.

Initialising a websocket via firefox console (con = new WebSocket("ws://10.77.254.113");) gets acknowledged by the project, but UDP-console says:

152.561.166 [IP-task   ] Gain: Socket 80 now has 4 / 12 children
 152.561.201 [IP-task   ] prvSocketSetMSS: 1400 bytes for 10.23.8.168:51489
 152.561.248 [IP-task   ] Socket 80 -> 10.23.8.168:51489 State eCLOSED->eSYN_FIRST
 152.561.299 [IP-task   ] MSS change 1400 -> 1460
 152.561.331 [IP-task   ] prvWinScaleFactor: uxRxWinSize 4 MSS 1400 Factor 0
 152.561.370 [IP-task   ] Socket 80 -> 10.23.8.168:51489 State eSYN_FIRST->eSYN_RECEIVED
 152.561.632 [IP-task   ] TCP: passive 80 => 10.23.8.168:51489 set ESTAB (scaling 1)
 152.561.680 [IP-task   ] Socket 80 -> 10.23.8.168:51489 State eSYN_RECEIVED->eESTABLISHED
 152.561.856 [SvrWork   ] TPC-server: new HTTP client
 152.563.059 [SvrWork   ] Open file '/websrc/': Is a directory

Whats the point? I dont get it…
Thanks for help,
Jens

heinbali01 wrote on Wednesday, May 09, 2018:

Hi Jens, what you see in the logging is that a TCP connection gets established. And then… you’re supposed to exchange data.
I know the principles of a websocket, but I haven’t used them my self.
The above socket on port 80 is created by your HTTP server, but it won’t do much: it can only respond to a GET command.

The last logging line:

    Open file '/websrc/': Is a directory

says that /websrc/ can not be opened as a file.

If your embedded device becomes a regular HTTP server, you can do a lot of interactive things. I often use web pages with JQuery and communicate by exchanging JSON expressions.

Websockets have the advantage of being full-duplex: the web-server can send a message at any moment in time, without a request for data.

Does you release of +TCP already have support for ipconfigHTTP_HAS_HANDLE_REQUEST_HOOK?
That feature is useful if you want to exchange JSON expressions.