curl-impersonate icon indicating copy to clipboard operation
curl-impersonate copied to clipboard

Does this project provide a solution for connecting to a web socket?

Open NabiKAZ opened this issue 2 years ago • 5 comments

Does this project provide a solution for connecting to a web socket? For example, I need an example like this in nodejs:

var socket = new WebSocket(url);
socket.onopen = function() {
...
};
socket.onmessage = function(e) {
...
};

The url in that example is on cloudflare.

NabiKAZ avatar Apr 02 '22 19:04 NabiKAZ

Unfortunately it seems that curl doesn't implement websockets yet even though it's a highly requested feature: See here https://github.com/curl/curl/wiki/WebSockets

You can send the initial HTTP request with the 'Upgrade: websocket' header using curl but if you want to receive or send messages I think you are out of luck.

To make this work it should probably be a separate project, possibly modifying Node or another Websocket implementation to behave like curl-impersonate when opening TLS connections.

lwthiker avatar Apr 03 '22 06:04 lwthiker

Don't mean to jump the gun too hard (it's been only ~two weeks since it was released), but I've noticed that curl 7.86.0 has shipped with experimental websocket support, so just wanted to check whether it's something on your radar?

zer0def avatar Nov 12 '22 18:11 zer0def

I was aware of the work being done but wasn't aware that it already landed in a release. These are good news! I would definitely attempt to upgrade to 7.86. It would be interesting to see if the impersonation works for websockets easily.

lwthiker avatar Nov 12 '22 20:11 lwthiker

Interested if you guys are thinking about implementing this :)

OEvans117 avatar Feb 09 '23 23:02 OEvans117

Now that curl has websocket support, I'm attempting to implement it as part of #160

lwthiker avatar May 26 '23 19:05 lwthiker