jakobilobi / wsstat

Check the status of a WebSocket endpoint.
MIT License
5 stars 1 forks source link

counter intuitive user experience using -text as parameter to json #10

Open erik78se opened 1 month ago

erik78se commented 1 month ago

It is a bit counter intuitive user experience when run against a polkadot websocket.

This was my call: wsstat -text '{"id": 1, "jsonrpc": "2.0", "method": "mmr_generateProof", "params": [[1021312]]}' ws://192.168.109.179:9933

It returns:

Target: 192.168.109.179
IP: 192.168.109.179
WS version: 13

  DNS Lookup    TCP Connection    WS Handshake    Message RTT
|      0ms  |            6ms  |         15ms  |       11ms   |
|           |                 |               |              |
|  DNS lookup:0ms             |               |              |
|                 TCP connected:6ms           |              |
|                                       WS done:15ms         |
-                                                        Total:27ms    

Response: [123 34 106 115 111 110 114 112 99 34 58 34 50 46 48 34 44 34 114 101 115 117 108 116 34 58 123 34 98 108 111 99 98 98 54 55 98 56 53 101 99 98 54 48 54 48 48 48 48 48 48 48 48 48 48 48 48 50 99 48 48 48 48 48 48 52 100 101 57 51 54 50 55 102 125]
jakobilobi commented 1 month ago

Automatic conversion should be possible for -text, for sure.

The -json option at the moment assumes just an input method, e.g. -json mmr_generateProof. Perhaps it would be better to have an option -json which takes a raw JSON string as in your example, and another -method which accepts just a method.

Thoughts?

erik78se commented 1 month ago
jakobilobi commented 1 month ago

Started addressing this issue, PR with initial changes: https://github.com/jakobilobi/wsstat/pull/11

Planning to add in the near future:

jakobilobi commented 1 month ago

PR https://github.com/jakobilobi/wsstat/pull/12 adds "raw" output as an option, and automatically decodes responses into JSON.

I'll make another sweep to improve the --help command before closing this issue.