Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I get data from a websocket url?

When I connect to a website who uses websockets, I can get the frames with the Google Developer Tools.

Data from the websocket url

So I would like to get the same data but in a program ( JS, C# ) but I actually have no idea how I should do.

I thought about make a http.request with NodeJS but it's not a http url :/ I thought about make a sample JS client but I couldn't get the data because I wasn't able to send the headers with the 'key'.

The headers

So, I really hope you have a way to help me and sorry for my basic English :(

like image 939
Rynelf Avatar asked Mar 31 '16 18:03

Rynelf


People also ask

How do I connect to a WebSocket server?

The URL to which to connect; this should be the URL to which the WebSocket server will respond. This should use the URL scheme wss://, although some software may allow you to use the insecure ws:// for local connections.

What is WebSocket and why do you need it?

WebSocket is especially great for services that require continuous data exchange, e.g. online games, real-time trading systems and so on. To open a websocket connection, we need to create new WebSocket using the special protocol ws in the url: There’s also encrypted wss:// protocol.

How do I get the absolute URL of a WebSocket?

The WebSocket.url read-only property returns the absolute URL of the WebSocket as resolved by the constructor. A DOMString. The compatibility table on this page is generated from structured data.

Is it possible to use WebSockets with Node JS?

It has its own protocol ws:// and wss:// (like https:// ). What you need is a proper WebSocket client to receive data from the server. The problem here is WebSockets it's not a protocol per se. There's no concept of request and response. It's like working with TCP sockets. If you want to work with WebSockets, NodeJS has Socket.IO client API.


1 Answers

WebSockets is a standard technology to implement stateful, persistent connections between clients and servers. It has its own protocol ws:// and wss:// (like https://).

What you need is a proper WebSocket client to receive data from the server.

The problem here is WebSockets it's not a protocol per se. There's no concept of request and response. It's like working with TCP sockets.

If you want to work with WebSockets, NodeJS has Socket.IO client API.

In C#, you should take a look at SignalR.

like image 72
Matías Fidemraizer Avatar answered Oct 22 '22 02:10

Matías Fidemraizer