Page 1 of 1

Websocket client question.

Posted: Wed Nov 24, 2021 10:11 pm
by topovich
Hello, I'm working on a project (with an ESP32-WROOM-32 board) that needs to entablish a connection and listen to a websocket, more specifically to get realtime data from the Binance websocket (not much data, only the latest prices of two or three pairs).
I found several examples and tutorials about how to code a websocket server, but almost none examples or code on how to connect as a client (in this case to the Binance websocket) and wait/listen for data from it.

Came across to this library: https://github.com/jczic/MicroWebSrv2
which looks great and have examples to code a webserver, but due to my lack of experience in websockets I cannot realize (or understand) how to connect to a websocket (as a client) with this library...or another one.

The websocket I want to connect to is: wss://stream.binance.com:9443
API Docs: https://binance-docs.github.io/apidocs/ ... et-streams

Can someone provide some example or give me some clue on how to do what I'm trying to do?

Thanks in advance.

Re: Websocket client question.

Posted: Thu Nov 25, 2021 7:28 pm
by karfas
What's wrong with google ?
Asking for "websocket client" gives me e.g. in the 5th link https://github.com/websocket-client/websocket-client (not for microypython, but enough code to steal from).

Re: Websocket client question.

Posted: Fri Nov 26, 2021 9:02 pm
by topovich
Thanks karfas for your reply.
As you said, it's not for Micropython (I couldnt be able to install it). I searched A LOT in Google, found some libraries (like the one I posted in my original question) but none of them show how to use them as client. So I though that it could be something simple to do with the available Micropython websocket libraries...I'm starting to think that I was wrong.

Sorry if it is a very simple thing, I just can't find anything related.

Thank you.

Re: Websocket client question.

Posted: Sat Nov 27, 2021 1:18 pm
by jomas
topovich wrote:
Fri Nov 26, 2021 9:02 pm
I searched A LOT in Google
Are you serious?

When I google for "micropython websocket client", the first hit gives a websocket client for micropython. (And it is a topic from this micropython forum, which you also could have searched for".