How to specify the websocket connect timer in CPPRest SDK - c++

I'm trying to connect an websocket server with CPPRest SDK.
But as per their documentation there is no timeout in websocket_client_config compared to http_client_config.
So how do I correctly specify the timeout so that the connect pplx::task will exit after the mentioned timeout?

You can't. Actually CPPRest SDK seems to be abandoned. The websocket part was changed last time 3 years ago. Don't use in new projects. Consider using Boost.Beast or WebSocket++ by Zaphoyd.

Related

boost.asio + native windows sockets

We have a framework that communicates via native WinAPI sockets (WSASend , CompletionPorts, etc) via TCP.
Recently, we've added some classes to this framework that also async sends and receives some messages via UDP, but these classes use Boost.ASIO (io_context etc).
Since then, we noticed that WinSocks connect function fails, with the following error:
A connection attempt failed because the connected party did not
properly respond after a period of time, or established connection
failed because connected host has failed to respond. The thread 0x3038
has exited with code 0 (0x0)
This only fails when connecting to a remote computer, not locally.
When reverting to an older version without these Boost classes, everything works fine (ruling out firewall issues)
When the Boost.ASIO classes our used outside of the framework, they work fine.
We are unsure what causes this issue. My hunch is that it is a conflict on OS level between winsock and boost.ASIO.
Did anyone run into something similar? Any ideas or pointers would be really appreciated.
Ben

gRPC timeout on server side

I'm working on bidirectional stream gRPC in C++. I want to set a timeout limit on server side, and kill the connection if it exceeds a threshold.
But the only timeout mechanism I've found is on client side(https://grpc.io/blog/deadlines/#c). And I don't find any API possible to for ServerContext(https://grpc.github.io/grpc/cpp/classgrpc_1_1_server_context.html). Does someone know how to do that?
gRPC does not support server side timeout limit/setting and hence you might need to have your own implementation mechanism and update client using context.abort.

implementation of ping/pong for tornado websocket

I have a websocket client in python implemented using tornado.websocket.
WebSocketClientConnection
which connects to a server at remote end and communicate over websocket. Earlier I had implemented the ping/pong like feedback mechanism at application layer to ensure if the remote endpoint is still responsive.
I just recently updated my tornado package and I came across the ping_interval in WebSocketClientConnection. I removed the old ping/pong mechanism at application layer and added this ping_interval in my implementation.
After this updates the websocket is getting closed after the mentioned ping_interval timeout. The server at remote end handles the ping at transport layer and respond accrodingly.
currently I have not implemented the ping method so should I have to implement ping method for WebSocketClientConnection?,
should I have to send any data in ping method?
do I have to implement any method to handle the response send by remote server for the ping request?
No, It's implemented by default.
You may but don't have to.
I assume that by response you've ment pong. If you're using ping_interval you don't have to process pong, but if you're sending pings manually you have to control timeouts by yourself so you have to process pongs by implementing tornado.websocket.WebSocketClientConnection.on_pong method.

Looking for poco ssl websocket client example in C++ for Windows 7

I've been looking through the poco samples and documentation, but I couldn't find out how to use poco's websockets and SSL combined. I successfully connected a non-SSL websocket (based on the WebSocket class) to a server (the echoserver sample from Qt5.4, running on Ubuntu), but how to add SSL to the client eludes me. Poco's NetSSL_OpenSSL samples aren't all that helpful, because I don't need to know how to download, tweet, mail or write a time server. Also the latter is the only one that uses "SecureStreamSocket" objects at all (which is probably the class I need). But that sample just accesses the socket from the request object, it doesn't show how to create and configure one properly.
I just want an SSL websocket client to send and receive some simple messages, like "Hello World". Can anyone help me please?
I use Windows 7 64 Bit for the client's OS and Ubuntu 64 Bit on VirtualBox for the server's OS, but the server side is no problem. My poco version is 1.6.0 and I compiled it with Visual Studio 2013 Express. Also I use OpenSSL 1.0.1j.
Cheers
Alex
Look at WebSocket testcase. Use HTTPSClientSession (instead of HTTPClientSession).

How to set timeout in mysql c++ connector

I am using c++ connector to connect to MySQL server. When server is offline or in sleep,the statement execute method takes a while to detect the connection problem.
Is there a method or variable to control the waiting timeout period in client?
Regards
Devara Gudda
You can use the mysql_options function to set the client timeout. Full details here... http://dev.mysql.com/doc/refman/5.0/en/mysql-options.html