lexiforest / curl_cffi

Python binding for curl-impersonate fork via cffi. A http client that can impersonate browser tls/ja3/http2 fingerprints.
https://curl-cffi.readthedocs.io/
MIT License
2.34k stars 255 forks source link

Send websocket text frame #337

Closed Cataphract89 closed 4 months ago

Cataphract89 commented 4 months ago

How do I send not binary data but text data over the websocket, similar to the original library? When I send messages through curl_cffi in binary formattai I get the error "Invalid frame type", but when I send through the original library there is no such error

perklet commented 4 months ago

What do you mean by original library? Can you please post you code here?

Cataphract89 commented 4 months ago

I mean "websocket-client" library (ws = websocket.WebSocketApp(url, on_message=self.on_message}) In a function "on_message" when I get a message, I respond to it ws.send('some text') And everything works fine, I get the correct response. But when I connect to the websocket via "curl_cffi" and respond with ws.send('some text'). I get an error that the message must be in binary format. I convert to binary, the code works fine, but the server tells me that I am sending the wrong frame

Cataphract89 commented 4 months ago

I fix that, my bad