Beast: How to connect to URI with parameters?

Created on 7 Aug 2018  ·  4Comments  ·  Source: boostorg/beast

[Environment]
Windows 10 64bit
Visual C++ 2017
Boost C++ Library 1.67

[Problem]
I'm trying to connect to WebSocket server that has a URL like below.

ws://a.live2.nicovideo.jp:2805/unama/wsapi/v1/watch/17394521080445?audience_token=17394521080445_84484127_1533712910_4e130746d630b25abfd4441c0e3f58e04a40bd5a

How can I connect to this url? Must I set header parameters manually?

All 4 comments

First, perform a DNS lookup on "a.live2.nicovideo.jp". Then, connect to port 2805 on the IP address returned by the DNS lookup. Once you have a connection, you can handshake using

ws.handshake(hostname, "/unama/wsapi/v1/watch/17394521080445?audience_token=17394521080445_84484127_1533712910_4e130746d630b25abfd4441c0e3f58e04a40bd5a");

Where ws is your connected websocket::stream object.

Thanks, vinniefalco. I'll try it.

Handshake seems succeeded.
I'll try to check further behaviors.

I succeeded to communicate with server by modifying the request header for websocket protocol.
The issue below was very useful to understand.
https://github.com/boostorg/beast/issues/991

Was this page helpful?
0 / 5 - 0 ratings