Buy commercial curl support from WolfSSL. We help you work
out your issues, debug your libcurl applications, use the API, port to new
platforms, add new features and more. With a team lead by the curl founder
himself.
WebSocket custom port name as in JavaScript websockets
- Contemporary messages sorted: [ by date ] [ by thread ] [ by subject ] [ by author ] [ by messages with attachments ]
From: Johny Bravo via curl-library <curl-library_at_lists.haxx.se>
Date: Thu, 25 May 2023 17:23:58 +0200 (CEST)
I have tried websocket API, but I cannot get it working and receive message.
If I use the ws in JavaScript, I have:
var socket = new WebSocket( "wss://some_url", "example");
However, I dont know, how to set "example" port in libCURL API. I have tried
curl_easy_setopt(curl, CURLOPT_PROTOCOLS_STR, "example");
but I still dont receive messages.
I got stuck at res = curl_ws_recv(curl, buffer, sizeof(buffer), &nread, &
meta); where res always returns CURLE_AGAIN, no matter how long I wait.
libCURL verbose log gives me this:
* Trying <IP>:443...
* Connected to some_url (IP) port 443 (#0)
* schannel: disabled automatic use of client certificate
> GET / HTTP/1.1
Host: some_url
Accept: */*
Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Version: 13
Sec-WebSocket-Key: xxxxxx==
< HTTP/1.1 101 Switching Protocols
< Server: nginx/1.20.2
< Date: Thu, 25 May 2023 15:04:32 GMT
< Connection: upgrade
< Upgrade: WebSocket
< Sec-WebSocket-Accept: xxxx=
* Received 101, switch to WebSocket; mask 5ae99ef1
<
* Connection #0 to some_url left intact
Date: Thu, 25 May 2023 17:23:58 +0200 (CEST)
I have tried websocket API, but I cannot get it working and receive message.
If I use the ws in JavaScript, I have:
var socket = new WebSocket( "wss://some_url", "example");
However, I dont know, how to set "example" port in libCURL API. I have tried
curl_easy_setopt(curl, CURLOPT_PROTOCOLS_STR, "example");
but I still dont receive messages.
I got stuck at res = curl_ws_recv(curl, buffer, sizeof(buffer), &nread, &
meta); where res always returns CURLE_AGAIN, no matter how long I wait.
libCURL verbose log gives me this:
* Trying <IP>:443...
* Connected to some_url (IP) port 443 (#0)
* schannel: disabled automatic use of client certificate
> GET / HTTP/1.1
Host: some_url
Accept: */*
Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Version: 13
Sec-WebSocket-Key: xxxxxx==
< HTTP/1.1 101 Switching Protocols
< Server: nginx/1.20.2
< Date: Thu, 25 May 2023 15:04:32 GMT
< Connection: upgrade
< Upgrade: WebSocket
< Sec-WebSocket-Accept: xxxx=
* Received 101, switch to WebSocket; mask 5ae99ef1
<
* Connection #0 to some_url left intact
-- Unsubscribe: https://lists.haxx.se/mailman/listinfo/curl-library Etiquette: https://curl.se/mail/etiquette.htmlReceived on 2023-05-25