Open theflyingmantis opened 5 years ago
I can see how the things are working. I wonder why is there an extra level of node server between client and python server?
You can create your own another API server and python server as the engine that connected your API server with whatsapp
@hadihammurabi There are 2 sides for the websockets - one which integrates with server (server side) and other which listens to it (client side).
Process: Whatsapp has their server side on wss://w1.web.whatsapp.com/ws
. Python Websocket client connects to this. Now there is a python server side websocket on port 2020. Python client sends all events to python server websocket.
There is a node client listening to python webserver on port 2020. And then another node server websocket on 2019 which receives the data from the node server client. This node server websocket is heard by another websocket client (frontend which we see when we run it) with server running on port 2018.
There is one extra layer. of Node js where the message is being transmitted.
Rephrasing my question: Is there any additional feature which middle node js server is providing? Why cannot the frontend client listen to python websocket server on port 2020?
But, I can create my own API Server to change the NodeJS Server. So, Python Socket only communicate with Whatsapp server and my NodeJS API as big API Server which is not only take care of Whatsapp Socket.
Yes , I think Node layer can be bypassed and native browser sockets can directly connect with Python socket server eliminating the need of Node.js
Use the package as an Engine for your program then use whatever you want for your socket server and API. basically there are 4 layers in the architecture here
1) Engine 2) Socket server 3) API (This is for other purpose like media uploads, etc... this is also the method whatsapp used) 4) Frontend
Frontend connects to the socket server to receive and send messages Socket server then sends the message to the engine Engine (the package itself) send your message to whatsapp socket
a more efficient way is to add another layer in the API side. split it into two... one is responsible for REST and one is responsible for the micro-services (or if you don't want to just services).
I can see how the things are working. I wonder why is there an extra level of node server between client and python server?