Websocket for os 6

Hi,
Is there an updated client example for mbed websocket implementation.

The official one does not work on os6.
Please advise. Most of our code is on os6 and we are having tough time trying to fit 3rd party c++ websocket libraries like websocketcpp, uwebsockets.

Any help is much appreciated,

Regards,

Hello,

I think no. All APIs what are officially supported are here - Full API list - API references and tutorials | Mbed OS 6 Documentation.
Do you talking about HTML5 Websockets | Mbed? That is not supported anymore, but maybe it can be fixed easily.

BR, Jan

HI Jan,
Good Morning. Thanks for the quick reply. Below are more details about this:

APPLICATION NEEDS:
Mbed device needs to be in secured comms bi-directionally with a central server, all the time. Security should be TLS, and then messaging needs to utilize websockets, either ws or wss.

SO FAR: We have a nodejs server running that is able to accept secured connections on 443 port. We have also used, (https://github.com/ARMmbed/mbed-os-example-sockets.git) example to get a secured transport layer socket established between device ( Nucleo-144 STM32F56 ) and our server. The TLS handshake works, and the root ca is validated etc etc.The example allowed us to SEND & RECEIVE http requests on a stateless mechanism, once a secured Transport Layer socket is opened. The OS is latest, mbed6.10 ( i believe).

OUR UNDERSTANDING:
At this point, we ought to open an APPLICATION LAYER (OSI Model LAYER 7) socket and establish a stateful connection between device and server. The OS5 HTML5 websocket seemed to do the job. We need to send a HTTP GET 1.1, from device, and then have that upgraded to a Websocket. Once websocket (App Layer) connection pipe is created, then messages should flow both ways via On.Message, On.Event, OnClose etc etc. ( the standard methods). Basically as per RFC6455.

This is where we need help please.

THE FILES:
I uploaded the main.cpp at this location. https://github.com/sparks2021/mbed.git
The websocket.cpp, and websocket.h are downloaded from mbed websocketclient example:

Can you please help us with right direction. Your help is much appreciated.

Regards,
Sparks21

I am not sure I am able to help you with this but I can try to help you modify the websocket.cpp file for MbedOS6.

WebSocketClient - Fork of… | Mbed

BR, Jan

HI Jan,

Thanks for the quick reply. Yes, initial tests with the new forked cpp works.
we are able to send open and send a websocket to a server.

Do you know if there is a wss implementation available in OS6 ?
Any examples etc would be very helpful. I saw the Sharklist ssl example, but its on OS2.
Nevertheless, we are going to give that a try.

If you can suggest where we can see a wss implementation using mbed os6, thats very helpful.

regards,

You can replace the TCP socket with a TLS socket.

https://os.mbed.com/docs/mbed-os/v6.10/apis/tlssocket.html

Nope, I do not know.

The wss protocol establishes a WebSocket over an encrypted TLS connection, while the ws protocol uses an unencrypted connection.

So how Cameron wrote, the TLSSocket must be implemented for that.

I tried to implement it but I am not able to test it. You can test new version on same link above. Change schema to “wss” and place certificate as third parameter in to the constructor.

BR, Jan