In a process to port ArchEthic JS SDK (libjs) in Ruby, I'm stuck with asynchronous updates sent through WebSockets.
I reverse engineered the Absinthe Protocol to this point :
- Connect the Phoenix Server
- Send the subscription request
- Parse the responses
- Get one or two messages before being killed by hearthbeat
- How to implement Heartbeat messages (every 30s when no other message has been sent)
Client -> [null,"9","phoenix","heartbeat",{}]
Server <- [null,"9","phoenix","phx_reply",{"response":{},"status":"ok"}]
-
How to implement Subscription cancelling ?
-
How to implement reconnection on error ?
Server <- ["6","6","__absinthe__:control","phx_error",{}]
Client -> ["22","22","__absinthe__:control","phx_join",{}]
Server <- ["22","22","__absinthe__:control","phx_reply",{"response":{},"status":"ok"}]
$ git clone https://github.com/archethic-foundation/archethic-node
$ cd archethic-node
$ docker build -t archethic-node .
# Edit docker-compose.yml to comment out node2 and node3
$ docker compose up
$ open http://localhost:4000
ArchEthic Node : https://github.com/archethic-foundation/archethic-node
ArchEthic libjs : https://github.com/archethic-foundation/libjs (see https://github.com/archethic-foundation/libjs/blob/master/lib/api.js#L288) keychain example is useful to spy websocket connections
- start an ArchEthic node
- in libjs :
npm install
- in
example/keychain
:npm install && npm start
- open http://localhost:8080
- check node endpoint (http://localhost:4000)
- type anything as keychain seed
- (start browser developer extensions, go to Network and filter WebSocket)
- click "Create keychain"
Absinthe Websocket JS Client : https://github.com/absinthe-graphql/absinthe-socket