Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move to msgpack 2 #95

Open
supermihi opened this issue Feb 17, 2016 · 19 comments
Open

Move to msgpack 2 #95

supermihi opened this issue Feb 17, 2016 · 19 comments

Comments

@supermihi
Copy link

I am trying to use the autobahn-cpp library in a Visual Studio 2015 project. After including both msgpack-c and autobahn-cpp, I get the following compiler error. I have already enabled the preprocessor flags MSGPACK_DISABLE_LEGACY_NIL and MSGPACK_DISABLE_LEGACY_CONVERT, as suggested in the msgpack-c readme for header-only mode. I'd appreciate any hints!

1>------ Build started: Project: X, Configuration: Debug x64 ------
1>  X.cpp
1>d:\autobahn-cpp\autobahn\wamp_call_options.ipp(66): error C2593: 'operator >>' is ambiguous
1>  d:\msgpack-c\include\msgpack\v2\adaptor\adaptor_base.hpp(48): note: could be 'const msgpack::v1::object &msgpack::v2::operator >><std::unordered_map<std::string,msgpack::v1::object,std::hash<_Kty>,std::equal_to<_Kty>,std::allocator<std::pair<const _Kty,_Ty>>>>(const msgpack::v1::object &,T &)'
1>          with
1>          [
1>              _Kty=std::string,
1>              _Ty=msgpack::v1::object,
1>              T=std::unordered_map<std::string,msgpack::v1::object,std::hash<std::string>,std::equal_to<std::string>,std::allocator<std::pair<const std::string,msgpack::v1::object>>>
1>          ]
1>  d:\msgpack-c\include\msgpack\v1\adaptor\adaptor_base.hpp(53): note: or       'const msgpack::v1::object &msgpack::v1::operator >><std::unordered_map<std::string,msgpack::v1::object,std::hash<_Kty>,std::equal_to<_Kty>,std::allocator<std::pair<const _Kty,_Ty>>>>(const msgpack::v1::object &,T &)'
1>          with
1>          [
1>              _Kty=std::string,
1>              _Ty=msgpack::v1::object,
1>              T=std::unordered_map<std::string,msgpack::v1::object,std::hash<std::string>,std::equal_to<std::string>,std::allocator<std::pair<const std::string,msgpack::v1::object>>>
1>          ]
1>  d:\autobahn-cpp\autobahn\wamp_call_options.ipp(66): note: while trying to match the argument list '(const msgpack::v1::object, std::unordered_map<std::string,msgpack::v1::object,std::hash<_Kty>,std::equal_to<_Kty>,std::allocator<std::pair<const _Kty,_Ty>>>)'
1>          with
1>          [
1>              _Kty=std::string,
1>              _Ty=msgpack::v1::object
1>          ]
1>d:\autobahn-cpp\autobahn\wamp_call_options.ipp(111): error C2593: 'operator <<' is ambiguous
1>  d:\msgpack-c\include\msgpack\v1\object.hpp(611): note: could be 'void msgpack::v1::operator <<(msgpack::v1::object &,const msgpack_object &)' [found using argument-dependent lookup]
1>  d:\msgpack-c\include\msgpack\v1\object.hpp(721): note: or       'std::ostream &msgpack::v1::operator <<(std::ostream &,const msgpack::v1::object &)' [found using argument-dependent lookup]
1>  d:\msgpack-c\include\msgpack\v2\adaptor\adaptor_base.hpp(66): note: or       'void msgpack::v2::operator <<<std::unordered_map<std::string,msgpack::v1::object,std::hash<_Kty>,std::equal_to<_Kty>,std::allocator<std::pair<const _Kty,_Ty>>>>(msgpack::v1::object::with_zone &,const T &)'
1>          with
1>          [
1>              _Kty=std::string,
1>              _Ty=msgpack::v1::object,
1>              T=std::unordered_map<std::string,msgpack::v1::object,std::hash<std::string>,std::equal_to<std::string>,std::allocator<std::pair<const std::string,msgpack::v1::object>>>
1>          ]
1>  d:\msgpack-c\include\msgpack\v2\adaptor\adaptor_base.hpp(60): note: or       'void msgpack::v2::operator <<<std::unordered_map<std::string,msgpack::v1::object,std::hash<_Kty>,std::equal_to<_Kty>,std::allocator<std::pair<const _Kty,_Ty>>>>(msgpack::v1::object &,const T &)'
1>          with
1>          [
1>              _Kty=std::string,
1>              _Ty=msgpack::v1::object,
1>              T=std::unordered_map<std::string,msgpack::v1::object,std::hash<std::string>,std::equal_to<std::string>,std::allocator<std::pair<const std::string,msgpack::v1::object>>>
1>          ]
1>  d:\msgpack-c\include\msgpack\v1\adaptor\adaptor_base.hpp(65): note: or       'void msgpack::v1::operator <<<std::unordered_map<std::string,msgpack::v1::object,std::hash<_Kty>,std::equal_to<_Kty>,std::allocator<std::pair<const _Kty,_Ty>>>>(msgpack::v1::object &,const T &)'
1>          with
1>          [
1>              _Kty=std::string,
1>              _Ty=msgpack::v1::object,
1>              T=std::unordered_map<std::string,msgpack::v1::object,std::hash<std::string>,std::equal_to<std::string>,std::allocator<std::pair<const std::string,msgpack::v1::object>>>
1>          ]
1>  d:\msgpack-c\include\msgpack\v1\adaptor\adaptor_base.hpp(71): note: or       'void msgpack::v1::operator <<<std::unordered_map<std::string,msgpack::v1::object,std::hash<_Kty>,std::equal_to<_Kty>,std::allocator<std::pair<const _Kty,_Ty>>>>(msgpack::v1::object::with_zone &,const T &)'
1>          with
1>          [
1>              _Kty=std::string,
1>              _Ty=msgpack::v1::object,
1>              T=std::unordered_map<std::string,msgpack::v1::object,std::hash<std::string>,std::equal_to<std::string>,std::allocator<std::pair<const std::string,msgpack::v1::object>>>
1>          ]
1>  d:\autobahn-cpp\autobahn\wamp_call_options.ipp(111): note: while trying to match the argument list '(msgpack::v1::object::with_zone, std::unordered_map<std::string,msgpack::v1::object,std::hash<_Kty>,std::equal_to<_Kty>,std::allocator<std::pair<const _Kty,_Ty>>>)'
1>          with
1>          [
1>              _Kty=std::string,
1>              _Ty=msgpack::v1::object
1>          ]
1>d:\autobahn-cpp\autobahn\wamp_subscribe_options.ipp(126): error C2593: 'operator <<' is ambiguous
1>  d:\msgpack-c\include\msgpack\v1\object.hpp(611): note: could be 'void msgpack::v1::operator <<(msgpack::v1::object &,const msgpack_object &)' [found using argument-dependent lookup]
1>  d:\msgpack-c\include\msgpack\v1\object.hpp(721): note: or       'std::ostream &msgpack::v1::operator <<(std::ostream &,const msgpack::v1::object &)' [found using argument-dependent lookup]
1>  d:\msgpack-c\include\msgpack\v2\adaptor\adaptor_base.hpp(66): note: or       'void msgpack::v2::operator <<<std::map<std::string,std::string,std::less<_Kty>,std::allocator<std::pair<const _Kty,_Ty>>>>(msgpack::v1::object::with_zone &,const T &)'
1>          with
1>          [
1>              _Kty=std::string,
1>              _Ty=std::string,
1>              T=std::map<std::string,std::string,std::less<std::string>,std::allocator<std::pair<const std::string,std::string>>>
1>          ]
1>  d:\msgpack-c\include\msgpack\v2\adaptor\adaptor_base.hpp(60): note: or       'void msgpack::v2::operator <<<std::map<std::string,std::string,std::less<_Kty>,std::allocator<std::pair<const _Kty,_Ty>>>>(msgpack::v1::object &,const T &)'
1>          with
1>          [
1>              _Kty=std::string,
1>              _Ty=std::string,
1>              T=std::map<std::string,std::string,std::less<std::string>,std::allocator<std::pair<const std::string,std::string>>>
1>          ]
1>  d:\msgpack-c\include\msgpack\v1\adaptor\adaptor_base.hpp(65): note: or       'void msgpack::v1::operator <<<std::map<std::string,std::string,std::less<_Kty>,std::allocator<std::pair<const _Kty,_Ty>>>>(msgpack::v1::object &,const T &)'
1>          with
1>          [
1>              _Kty=std::string,
1>              _Ty=std::string,
1>              T=std::map<std::string,std::string,std::less<std::string>,std::allocator<std::pair<const std::string,std::string>>>
1>          ]
1>  d:\msgpack-c\include\msgpack\v1\adaptor\adaptor_base.hpp(71): note: or       'void msgpack::v1::operator <<<std::map<std::string,std::string,std::less<_Kty>,std::allocator<std::pair<const _Kty,_Ty>>>>(msgpack::v1::object::with_zone &,const T &)'
1>          with
1>          [
1>              _Kty=std::string,
1>              _Ty=std::string,
1>              T=std::map<std::string,std::string,std::less<std::string>,std::allocator<std::pair<const std::string,std::string>>>
1>          ]
1>  d:\autobahn-cpp\autobahn\wamp_subscribe_options.ipp(126): note: while trying to match the argument list '(msgpack::v1::object::with_zone, std::map<std::string,std::string,std::less<_Kty>,std::allocator<std::pair<const _Kty,_Ty>>>)'
1>          with
1>          [
1>              _Kty=std::string,
1>              _Ty=std::string
1>          ]
1>d:\autobahn-cpp\autobahn\wamp_auth_utils.hpp(84): warning C4267: 'argument': conversion from 'size_t' to 'int', possible loss of data
1>d:\autobahn-cpp\autobahn\wamp_auth_utils.hpp(116): warning C4267: 'initializing': conversion from 'size_t' to 'int', possible loss of data
1>d:\autobahn-cpp\autobahn\wamp_auth_utils.hpp(119): warning C4267: 'initializing': conversion from 'size_t' to 'int', possible loss of data
1>d:\autobahn-cpp\autobahn\wamp_auth_utils.hpp(164): warning C4267: 'argument': conversion from 'size_t' to 'int', possible loss of data
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
@DZabavchik
Copy link

A dirty solution is to define MSGPACK_DEFAULT_API_VERSION=1 in project settings. That will effectively disable v2 namespace. It will compile and run fine.

@supermihi
Copy link
Author

Thanks, that fixes compilation. However, I'm not able to set up a connection to a crossbar.io server (see also #2). Question: Has anyone ever managed to use Autobahn|Cpp with VS 2015?

@DZabavchik
Copy link

It compiles with VS2015, runs, connects and authenticates with crossbar.io 0.12.1. After fixing auth flow, I have not tried anything beyond authenticating and receiving a WELCOME. If you are running crossbar.io on windows, disable unix socket listener from crossbar config. I'll commit .sln and .vcxproj along with #46

@oberstet
Copy link
Contributor

Ah, nice! That's good news. If it can authenticate (eg https://github.com/crossbario/autobahn-cpp/blob/master/examples/wampcra.cpp), chances are high "it just works" (RPC and PubSub).

We should probably have a variant of above example that combines that with actually doing something. On the other hand: it's trivial to copy-paste code from the other examples.

@DZabavchik
Copy link

Just noticed, part of my fix for wampcra got overwritten by most recent merge. break missing for CHALLENGE again.

           case message_type::CHALLENGE:
               process_challenge(std::move(message));
 +             break;
           case message_type::AUTHENTICATE:

@supermihi
Copy link
Author

Thanks for your answers. I'm glad to hear that VS2015 appears to be supported now; however, I'm not able to get it running. I've done the following:

  1. Create crossbar.io's hello example app and add an additional rawsocket transport on Port 8000: { "type": "rawsocket", "endpoint": { "type": "tcp", "port": 8000 } }
  2. Use this example from Autobahn|cpp:
̀int main(int argc, char** argv)
{

    try {
        const tcp::endpoint endpoint = tcp::endpoint(address::from_string("127.0.0.1"), 8000);

        boost::asio::io_service io;
        auto transport = make_shared<autobahn::wamp_tcp_transport>(io, endpoint);
        auto session = make_shared<autobahn::wamp_session>(io, true);
        transport->attach(static_pointer_cast<autobahn::wamp_transport_handler>(session));

        boost::future<void> connect_future;
        boost::future<void> start_future;
        boost::future<void> join_future;
        boost::future<void> call_future;
        boost::future<void> leave_future;
        boost::future<void> stop_future;

        connect_future = transport->connect().then([&](boost::future<void> connected) {
            try {
                connected.get();
            }
            catch (const exception& e) {
                cerr << e.what() << endl;
                io.stop();
                return;
            }
            cout << "transport connected" << endl;

            start_future = session->start().then([&](boost::future<void> started) {
                try {
                    started.get();
                }
                catch (const exception& e) {
                    cerr << e.what() << endl;
                    io.stop();
                    return;
                }

                cerr << "session started" << endl;

                join_future = session->join("realm1").then([&](boost::future<uint64_t> joined) {
                    try {
                        cerr << "joined realm: " << joined.get() << endl;
                    }
                    catch (const exception& e) {
                        cerr << e.what() << endl;
                        io.stop();
                        return;
                    }
[...]

However, when I try to run this program, it says

starting io service
stopped io service
async_read: The system cannot find the file specified.

When debugging with VS2015, a lot of exceptions of type boost::exception_detail::clone_impl<std::system_error> are thrown. In addition, the crossbar logs an autobahn.wamp.exception.TransportLost.

@supermihi
Copy link
Author

Just an addition: With autobahn-python, I can connect to the router (using websocket, not rawsocket which doesn't appear to be supported by the python package) and call the example "add2" method without problems.

@supermihi
Copy link
Author

Sorry for the spam, I figured out that the problem was msgpack-python not being installed on the crossbar side, while autobahn|cpp doesn't support json (does it?). After installing msgpack-python, everything works. To recap the steps necessary for others trying to get this running:

  1. Make sure to install msgpack-python on the crossbar server, and add a rawsocket transport in .crossbar\config.json on a different port than the websocket transport, as described above.
  2. Add the MSGPACK_DEFAULT_API_VERSION=1 preprocessor define to workaround the issue above (I still think this should be considered a bug, and using API version 2 is probably preferable?)
  3. Be sure to connect to the correct port of the rawsocket transport.

@oberstet
Copy link
Contributor

I still think this should be considered a bug, and using API version 2 is probably preferable?

It works on gcc and clang, so if so, I'd consider it a VS bug. Ask MS to fix their compilers.

@oberstet
Copy link
Contributor

@supermihi

  • rgd (1): missing msgpack-python: I have expanded the examples README https://github.com/crossbario/autobahn-cpp/tree/master/examples#run - installing via pip install crossbar[all] will automatically install msgpack support as well. I also added links to other router implementations.
  • rgd (3): missing rawsocket TCP transport in the Crossbar.io examples config (to make it work on Windows): I have expanded the config so that it starts rawsocket transports both on UDS and TCP. @DZabavchik is working on a PR to fix the Windows issues, and that also includes a Crossbar.io config without UDS (which doesn't work on Windows).

@DZabavchik
Copy link

Sorry l, forgot to mention msg pack on server side. I stepped on that rake also.

MSGPACK_DEFAULT_API_VERSION=1 is now defined in the headers for _WIN32

Regards,

Denis

On Feb 19, 2016, at 05:20, Michael Helmling notifications@github.com wrote:

Sorry for the spam, I figured out that the problem was msgpack-python not being installed on the crossbar side, while autobahn|cpp doesn't support json (does it?). After installing msgpack-python, everything works. To recap the steps necessary for others trying to get this running:

  1. Make sure to install msgpack-python on the crossbar server, and add a rawsocket transport in .crossbar\config.json on a different port than the websocket transport, as described above.
  2. Add the MSGPACK_DEFAULT_API_VERSION=1 preprocessor define to workaround the issue above (I still think this should be considered a bug, and using API version 2 is probably preferable?)
  3. Be sure to connect to the correct port of the rawsocket transport.


Reply to this email directly or view it on GitHub.

@oberstet
Copy link
Contributor

I think this should be addressed by @DZabavchik recent contributions now. Closing (though I didn't test it .. lack of Windows).

@supermihi
Copy link
Author

Thanks a lot! I'll test on monday if it works out-of-the-box with VS2015 now but from what you mention I'm pretty sure it should.

@DZabavchik
Copy link

There is a pre-build step that will complain about setting missing boost, msgpack and OpenSSL directories or updating project settings, it is pretty much self explanatory.

Regards,

Denis

On Feb 20, 2016, at 06:11, Michael Helmling notifications@github.com wrote:

Thanks a lot! I'll test on monday if it works out-of-the-box with VS2015 now but from what you mention I'm pretty sure it should.


Reply to this email directly or view it on GitHub.

@davidchappelle
Copy link
Contributor

Since we probably don't want to be stuck on v1, I have submitted a defect to msgpack-c for this issue. I was able to provide a simple program demonstrating the issue and isolate it to a specific commit:

msgpack/msgpack-c#442

I think that we should re-open this issue for the time being and revert hardcoding to v1 once msgpack is patched.

@oberstet oberstet changed the title Visual Studio 2015 Compiler Error: "Operator >> is ambiguous" VSS is stuck on MsgPack v1 (upstream issue) Mar 16, 2016
@oberstet oberstet reopened this Mar 16, 2016
@oberstet
Copy link
Contributor

@davidchappelle agreed. reopened and changed title

@oberstet oberstet changed the title VSS is stuck on MsgPack v1 (upstream issue) Move to msgpack 2 May 2, 2017
@CanNuhlar
Copy link

CanNuhlar commented Oct 17, 2022

Can we at least add add_compile_definitions(MSGPACK_DEFAULT_API_VERSION=1) to current CMakeLists.txt? It's impossible to use autobahn-cpp-dev with debian 10 & 11 without fetching msgpack from Debian 9. Which is bad.

I think it'd be best to increase compatibility until msgpack v2 support is there. What do you think? @oberstet

If this sounds okay to you I'll create a PR.

@oberstet
Copy link
Contributor

oberstet commented Oct 17, 2022

@CanNuhlar yes indeed, sounds good!

this is better than current state, but we still should/want to move to msgpack 2 I guess, so pls leave comments, and keep this issue open or a new one ...

@CanNuhlar
Copy link

#236

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants