IXWebSocket client creates a lot of threads when connecting to some urls
After start() method IXWebSocket creates around 30 threads when connecting to some urls. wss is using.
One of that threads is using to send messages, one for receiving.
How can I force IXWebSocket to use only one thread (like for other urls)?
Compiled with "cmake -DUSE_TLS=1 -DUSE_ZLIB=1 -DUSE_OPEN_SSL=1 .."
Attached screenshots
.
I don't know what goes wrong with this remote url. Can you connect to it with anothe library ? Maybe it has some SSL problem ?
You could also try an older version of ixwebsocket.
Can you connect to it with the connect ws sub-command ?
I don't know what goes wrong with this remote url. Can you connect to it with anothe library ? Maybe it has some SSL problem ?
I've tried with another ws library and it doesn't create additional threads for that url.
You could also try an older version of ixwebsocket.
I've tried v11.0.8 and v10.4.0. Same result. A lot of threads.
Can you connect to it with the connect ws sub-command ?
I don't get how to do it. What method should I use?
ws is a command line interface. Build ws like this:
mkdir -p build && (cd build ; cmake -DCMAKE_UNITY_BUILD=OFF -DUSE_TEST=OFF -DUSE_TLS=ON -DUSE_WS=ON .. ; make -j8)
Then:
$ ./build/ws/ws connect --help
Connect to a remote server
Usage: ./build/ws/ws connect [OPTIONS] url
Positionals:
url TEXT REQUIRED Connection url
Options:
-h,--help Print this help message and exit
-H TEXT Header
-d Disable Automatic Reconnection
-x Disable per message deflate
-b Send in binary mode
--max_wait UINT Max Wait Time between reconnection retries
--ping_interval INT Interval between sending pings
--subprotocol TEXT Subprotocol
-g Decompress gziped messages
--pidfile TEXT Pid file
--cert-file TEXT:PATH(existing)
Path to the (PEM format) TLS cert file
--key-file TEXT:PATH(existing)
Path to the (PEM format) TLS key file
--ca-file TEXT:PATH(existing)
Path to the (PEM format) ca roots file
--ciphers TEXT A (comma/space/colon) separated list of ciphers to use for TLS
--tls Enable TLS (server only)
--verify_none Disable peer cert verification
I tried this remote websocket test server -> https://www.piesocket.com/websocket-tester
./build/ws/ws connect 'wss://demo.piesocket.com/v3/channel_1?api_key=VCXCEuvhGcBDP7XhiJJUDvR1e1D3eiVjgZ9VRiaV¬ify_self'
Type Ctrl-D to exit prompt...
Connecting to url: wss://demo.piesocket.com/v3/channel_1?api_key=VCXCEuvhGcBDP7XhiJJUDvR1e1D3eiVjgZ9VRiaV¬ify_self
> [2022-08-03 09:18:15.955] [info] ws_connect: connected
[2022-08-03 09:18:15.955] [info] Uri: /v3/channel_1?api_key=VCXCEuvhGcBDP7XhiJJUDvR1e1D3eiVjgZ9VRiaV¬ify_self
[2022-08-03 09:18:15.955] [info] Headers:
[2022-08-03 09:18:15.955] [info] Connection: upgrade
[2022-08-03 09:18:15.955] [info] Date: Wed, 03 Aug 2022 16:18:15 GMT
[2022-08-03 09:18:15.955] [info] Sec-WebSocket-Accept: Q0GhXhe+4qTaAWniof2ye1PPPjI=
[2022-08-03 09:18:15.955] [info] sec-websocket-extensions:
[2022-08-03 09:18:15.955] [info] Upgrade: websocket
[2022-08-03 09:18:15.955] [info] X-Powered-By: Ratchet/0.4.4
[2022-08-03 09:18:15.990] [info] Received pong ixwebsocket::heartbeat::30s::0
[2022-08-03 09:18:18.664] [info] Received 12 bytes
ws_connect: received message: Hello world!
[2022-08-03 09:18:18.665] [info] Received 12 bytes
ws_connect: received message: Hello world!
[2022-08-03 09:18:18.665] [info] Received 12 bytes
ws_connect: received message: Hello world!
[2022-08-03 09:18:18.665] [info] Received 12 bytes
ws_connect: received message: Hello world!
[2022-08-03 09:18:18.782] [info] Received ping
[2022-08-03 09:18:21.879] [info]
ws_connect: connection closed: code 1000 reason Normal closure
ws_connect: stop connection completed in 38222 us
[2022-08-03 09:18:21.918] [info] Received 91 bytes
[2022-08-03 09:18:21.918] [info] Sent 0 bytes
- What OS are you using ?
- Is the URL public, can you share it ?
Can you connect to it with the connect ws sub-command ?
Connected and no problems. Two threads for ws process.
- What OS are you using ?
Ubuntu 20.04. App compiled with g++-11
2. Is the URL public, can you share it ?
It is public, but I've sent it to your email. And some messages to test with.
It seems that new threads are created not after connection to url but after sending some messages.
try adding webSocket.disableAutomaticReconnection();
try adding webSocket.disableAutomaticReconnection();
Same thing. Didn't help