websocketpp | C++ websocket client/server library | Websocket library
kandi X-RAY | websocketpp Summary
kandi X-RAY | websocketpp Summary
C++ websocket client/server library
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of websocketpp
websocketpp Key Features
websocketpp Examples and Code Snippets
Community Discussions
Trending Discussions on websocketpp
QUESTION
Recently I wrote a Discord-Bot in C++ with the sleepy-discord bot library. Now, the problem here is that when I run the bot it shows me the following errors:
...ANSWER
Answered 2021-May-29 at 21:34The error triggers when you so s.remote_endpoint
on a socket that is not connected/no longer connected.
It would happen e.g. when you try to print the endpoint with the socket after an IO error. The usual way to work around that is to store a copy of the remote endpoint as soon as a connection is established, so you don't have to retrieve it when it's too late.
On the question why it's happening on the particular VM, you have to shift focus to the root cause. It might be that accept
is failing (possibly due to limits like number of filedescriptors, available memory, etc.)
QUESTION
I really hate to ask this basic question, but I'm trying to build a system that uses websocketpp
that will hopefully be deployed to an Ubuntu server at some point, and I want to use Boost Logging for the application. I figured since websocketpp
already requires boost
, i might as well use its logging.
I'm currently testing the setup on a mac, because that's all I have. My project is still only a main.cpp
file, it follows this tutorial. it looks like this:
main.cpp
...ANSWER
Answered 2021-Feb-16 at 09:15When you specify -lboost_log
, the linker tries to find a shared library by default. Only if it isn't found, it looks for a static library.
In Boost.Log, symbols in static and shared libraries are mangled differently to make them incompatible. By default, the library assumes static linking. In order to enable dynamic linking, you must define BOOST_LOG_DYN_LINK
or BOOST_ALL_DYN_LINK
when compiling your code that uses Boost.Log (the former means that only Boost.Log is linked dynamically, the latter - that all Boost libraries are linked dynamically).
A few other notes:
- You must ensure that the C++ standard library used to build Boost and your application match. For example, you cannot build Boost with libc++ and your code with libstdc++ - the two standard libraries define different symbols and have different ABIs, so your code won't link with Boost.
- You must ensure that Boost is built with the same or higher C++ version than your code. Otherwise you may not be able to link because of missing symbols (e.g. methods involving C++11 features won't be available in C++03 Boost libraries).
- You must ensure that ABI-affecting compiler options and macros are defined the same way when you build Boost and your code. Otherwise you may have ABI incompatibility issues, which are hard to diagnose and debug.
- In
b2
command line,-link=static
should be specified without a dash, and you can usecxxstd=14
instead ofcxxflags=-std=c++14
. - If you're using Boost.Log features from
boost/log/utility/setup
directory, you may need to link withboost_log_setup
library, in addition toboost_log
.boost_log_setup
depends onboost_log
and provides additional library setup helpers.
QUESTION
I need help for debugging a probabilistic issue. I built a gstreamer pipeline to stream NVENC encoded h264 bitstreams(video only) to browser. Browser seldom plays properly. In most cases only few frames are rendered then the picture gets frozen.
The NVENC settings follow "https://cloud.google.com/solutions/gpu-accelerated-streaming-using-webrtc" which are h264 high profile & low latency high quality & NVENC_INFINITE_GOPLENGTH(some settings have been tried, like rateControlMode/enableVFR/sliceMode/repeatSPSPPS/outputAUD but no help). At runtime, NVENC encodes real-time rendered opengl fbo texture to h264 bitstreams and push them into gstreamer via appsrc. Currently the texture size is 512x512 and fed at 10/20/30 fps.
I use gstreamer 1.18.2, the pipeline is defined as "appsrc name=nvenc_src do-timestamp=1 ! video/x-h264, stream-format=byte-stream, alignment=au ! rtph264pay aggregate-mode=zero-latency ! queue ! application/x-rtp,media=video,encoding-name=H264,payload=123 ! webrtcbin bundle-policy=max-compat name=backend_webrtc".
The gstreamer part codes follow the sendrecv example(replacing libsoup with websocketpp and removing the recv logics).
The application is built as MSVC 2019 32-bit. The browser decoder is NVDEC. Exe application and js codes run on the same PC(windwos 10, gtx1060, driver version 460.89). I've tried in Chrome(87.0.4280.88) and edge(87.0.664.66). I also tried running the js codes in android(chrome) and ios(safari) and get the same results.
It can be concluded that NVENC generates 'correct' h264 bitstreams. I dump the raw h264 bitstreams into file. The file plays properly in VLC. I also tried pushing the dumped h264 bitstreams into gstreamer. The frozen issue still happens.
After the picture is frozen, the playback never recovers. the browser's 'webrtc-internals' shows that bytes/headerBytes/packests_Received keep growing, while frameReceived/framesDecoded/framesDropped stay unchanged.
Since the bitwise same h264 frames behave differently at different runs, I guess rtp timestamps might cause the issue. I've tried setting appsrc's do-timestamp to 0 and manually set gstbuffer's PTS but it does not help.
...ANSWER
Answered 2021-Jan-01 at 19:31Here are few things that you need to pay attention to:
- Infinite GOP will not work - you must configure NVENC to send a key frame every 30 - 60 frames.
- Of course SPS-PPS NALs must come before each key frame.
- Prohibit B-frames: WebRTC doesn't support them because they increase latency.
- Startup codes between NALs must be 3-bytes startup codes: WebRTC doesn't respect 2-bytes startup codes. We bumped into this issue before and had to manually correct the startup codes.
QUESTION
I am creating a telemetry server using websocketpp, and have followed the example here. My application will be running as a linux daemon which starts on boot, and therefore I won't be able to write logs to standard out. I would therefore like to add a customer logger using spdlog, and understand that it can be done based on what's on this page. Looks like I need to use the websocketpp::log::stub
interface to create my own customer logger. The issue is, the documentation on this is quite limited regarding logging, and I am not sure where to begin and how to incorporate it in the context of the telemetry server example linked above. I am not sure how to specify the logger when I define my server: typedef websocketpp::server server;
.
How do I go about extending the stub
class, and how do I initialize my server with this customer logger?
The only sample code I could find is in this thread here, but based on the linked comment this code is no longer relevant after V 0.3.x+
.
ANSWER
Answered 2020-Jun-24 at 22:36Building a custom logger has two steps. First, write a policy class with the appropriate interface then create a custom config that uses that policy.
To write the policy class websocketpp::log::stub
is a minimal implementation that doesn't actually do anything (it is primarily used for stubbing out logging in the unit tests) but it demonstrates and documents the interface that a logging class needs to implement. The logging class does not need to be a subclass of websocketpp::log::stub
. You can look at other examples in the websocketpp/logger/*
folder. The syslog logger in particular might be interesting as an example of a logging policy that outputs to something other than standard out.
To set up the custom config you will create a config class. It can be standalone or a subclass of one of the standard ones, like websocketpp::config::asio
, that just overrides a small number of things. Your config might only override the loggers, for example. Once created, you will pass your config class into the endpoint template parameter instead of websocketpp::config::asio
.
More details about what you can override at compile time via this config system can be found at https://docs.websocketpp.org/reference_8config.html. There is an example on this page that shows a custom config that replaces the default logger (among other changes).
QUESTION
I'm need help with websocketspp / websockets++ please (https://github.com/zaphoyd/websocketpp).
I'm open to other simpler libraries, also C, if that's an overall better option :)
My overall goal is to have a websockets webpage as a replacement for a telnet client for DikuMUD.
I've been using the "echo_server" example which is running fine.
I'm trying to save the connection handler "hdl" from one callback and then re-use it later to send another message back to the client. Looks to me like hdl is a class that will get created / destroyed on the stack with each function call to e.g. on_message.
I would like to store the hdl somehow, e.g. in a std::map so that I can look it up and use that looked up hdl to send another message later to the same client.
Here's the example. Sorry for the void , I'm used to C and lightweight C++ :)
...ANSWER
Answered 2020-Mar-15 at 10:00connection_hdl
is istelf a pointer, store connection_hdl
. It is a weak pointer.
Generally, suggest avoiding void*
with asio, and using reference-counted smart pointers. Even though you can control lifetime of object in a synchronous program, and call free
or delete
when needed, in asynchronous program the flow is varying, so the right place to free pointer could be different place each time.
asio may use boost::weak_ptr
or std::weak_ptr
. boost
one has operator <
, so can be directly used in a map. For std
, there's std::weak_ptr::owner_before
to be used for ordering, can be used via std::owner_less
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install websocketpp
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page