thunder-client-support icon indicating copy to clipboard operation
thunder-client-support copied to clipboard

Add RSocket/Web Socket support

Open naiyerasif opened this issue 3 years ago • 13 comments

As an API developer, I often work on streaming APIs based on RSocket. It'd be useful if Thunder Client can add support for this.

naiyerasif avatar Apr 01 '21 15:04 naiyerasif

I will do some research on how to implement this.

rangav avatar Apr 01 '21 17:04 rangav

Hi @naiyerasif what client currently you are using to test rsocket?

if anyone know how to implement this in node, they can contribute to the project.

rangav avatar Apr 04 '21 14:04 rangav

I use an internal client app that consumes a dev version of the RSocket server. Unfortunately, it is very specific to the server and needs some serious thumb-twiddling for any changes (which is why I raised this request)

There's rsocket/rsocket-js package that provides several client and server packages.

naiyerasif avatar Apr 04 '21 15:04 naiyerasif

Hope to support websocket

shenghui0779 avatar Jun 01 '22 03:06 shenghui0779

@shenghui0779 its in roadmap

rangav avatar Jun 01 '22 04:06 rangav

That's great !

shenghui0779 avatar Jun 02 '22 00:06 shenghui0779

@shenghui0779 its in roadmap

Where can I find the roadmap to get the state?

DerOetzi avatar Sep 26 '22 14:09 DerOetzi

Just a basic interface to connect to a websocket with some headers would be enough for some rapid prototyping. After the connection was established just show a logging window with all incoming data (only show if it was encoded with something readable like utf-8) and a message window where you can send (json) data.

Later some protocols like secure websockets and stuff could be added.

How about that?

UliPrantz avatar Mar 03 '23 00:03 UliPrantz

Hi @UliPrantz sounds good

Can you share sample url or node project for testing.

will look into when I got it time.

rangav avatar Mar 03 '23 07:03 rangav

@rangav basically the same as this plugin is doing it. It's called WebSocket-Client. I don't know what all the clutter with STOMP and SocketJS is but as far as I can tell STOMP is only a subprotocol which can be used once the WebSocket connection is established and SocketJS seems to be some JS library. I don't think these two things are necessary for a first little feature demo but probably can come in handy later down the road.

The project has no license means it would be illegal to use the code but at least it's a good starting point and when you ask @MoNouri97 he will probably update the license and maybe he will also agree to merge the project?!

UliPrantz avatar Mar 10 '23 13:03 UliPrantz

@UliPrantz thanks for sharing info, Will look into it.

rangav avatar Mar 10 '23 13:03 rangav

@rangav I also find out that the Chrome/Firefox dev tools offer something similar just not that conveniently usable.

const serverUrl = 'localhost:8000';
const someUriPart = 'xxxxxxx';

const socket = new WebSocket(`ws://${serverUrl}/rooms/${someUriPart}/player/`);

socket.addEventListener('open', (event) => {
  console.log('WebSocket connection established.');
  
  const message = {
    value: 'key'
 };
  
  socket.send(JSON.stringify(message));
});

socket.addEventListener('message', (event) => {
  console.log('Received message:', event.data);
});

socket.addEventListener('close', (event) => {
  console.log('WebSocket connection closed.');
});

socket.addEventListener('error', (error) => {
  console.error('WebSocket error:', error);
});

After executing this in the console tab of the chrome/firefox dev tools you can switch to the network tab - there should be a connection with the name: player/ , status: 101 , protocol: websocket . Select it by clicking on the name and then clicking on Messages in the newly opened tabbar. Unfortunately to send JSON message you have to execute this line socket.send(JSON.stringify(message)); in the console tab again (ofc you can use different messages) but it's really inconvenient that it isn't possible to just write json inside the Message tab of the websocket or any other type of text data.

The different event listeners aren't needed since all of this information shows up in the Messages tab too. It's only there to make this example work - same goes for the socket.send inside of the first event listener.

Wrapping this in an easy to use UI would make a lot of things easier I guess.

UliPrantz avatar Mar 15 '23 00:03 UliPrantz

Thanks @UliPrantz for sharing sample code.

Currently working on few other tasks, Will look into this feature next month.

rangav avatar Mar 15 '23 07:03 rangav

This feature has been implemented and published to the marketplace. Please update to v2.19.0.

You can see all the features released in this update https://github.com/rangav/thunder-client-support/releases/tag/v2.19.0

Please test it and let me know your feedback

rangav avatar Mar 04 '24 14:03 rangav