cli icon indicating copy to clipboard operation
cli copied to clipboard

Websocket Support

Open GRVYDEV opened this issue 2 years ago • 8 comments

Checklist

  • [x] I've searched for similar feature requests.

Enhancement request

Allow for simple websocket testing

Problem it solves

E.g. “I'm always frustrated when […]”, “I’m trying to do […] so that […]”.

I am building a websocket server and would like an easy way to connect and send messages to it. Nothing too complex.

Basic features would be:

  • Sending Messages
  • Receiving and displaying messages

Additional information, screenshots, or code examples

Here is a link to a website that does something like this https://livepersoninc.github.io/ws-test-page/

GRVYDEV avatar Mar 18 '23 19:03 GRVYDEV

Would really need this one too!

arguiot avatar Jul 13 '23 07:07 arguiot

This would be fantastic!

jhwheeler avatar Jul 24 '23 15:07 jhwheeler

That would be a great feature. Thank you.

eyayaw avatar Jul 24 '23 19:07 eyayaw

sounds great, would be willing to help with this if needed

valentin994 avatar Jul 26 '23 20:07 valentin994

So I started fiddling with it but I would like some pointers from the maintainer on how they would like this implemented.

The request to send requests isn't hard to implement but there are some ways it could be done. Do we want to implement it in a way where someone could specify the number of messages they want to send, what flags should it support, and what should one showcase after a successful connection, I suppose all headers?

As for receiving messages that would be just opening a connection to the wss and listening for messages?

valentin994 avatar Aug 01 '23 13:08 valentin994

I think we should be aiming at something similar to websocat

arguiot avatar Aug 01 '23 13:08 arguiot

Ok, so right now I have a general implementation where you can send one message or multiple messages until you close it with exit().

Example call for now is: https WSS ws://127.0.0.1:8000/ws

Now I would ask for some advice/guideance on how the maintainers would like the implementation to be plugged in.

As for now, I have plugged it in the collect_messages() where I read if the method is WSS and then branch it out to go to a function to create a websocket connection and then another function that reads user input in a while loop sends it and waits for another message until the user types in exit(). In the meantime we have a thread that sends pings to keep the connection alive. Now I would have to implement models and leverage the argsparser better.

The question for now is, do I try to plug it into the present client and request handler or do we separate it as websockets are handled differently anyway.

This is the branch https://github.com/valentin994/cli/tree/websocket-support It is quite crude for now as I am not sure what way we want to go with this.

valentin994 avatar Aug 09 '23 14:08 valentin994

I wrote a websocket plugin named httpie-websockets,https://github.com/belingud/httpie-websockets, that allows you to use http ws://localhost:8765/ establish a websocket connection, similar to websocat, listening to input and displaying messages. Pretty stable now. Welcome to try.

belingud avatar Jul 28 '24 06:07 belingud