darrenjs / wampcc

WAMP C++ library
MIT License
73 stars 22 forks source link

rawsocket connection issue with crossbar.io router #18

Closed sashakh closed 6 years ago

sashakh commented 6 years ago

Hi, I'm running wampcc against crossbar.io router using raw socket protocol and it fails in such way:

$ ./admin --proto raw 127.0.0.1 8000 -R realm1 -p com.example.oncounter --arglist '["hi"]' -d -d
fd: 10, tcp_tx: len 4, hex 7ff30000
fd: 10, tcp_rx: len 4, hex 7ff30000
session #1 handhake error: failed to negotiate rawsocket message serialiser
session #1 timeout waiting for peer
session #1 closing
error, wamp session could not be established

crossbar.io log says:

2017-12-13T20:13:31+0200 [Router      20896 crossbar.router.protocol.WampRawSocketServerProtocol] WampRawSocketProtocol: connection made
2017-12-13T20:13:31+0200 [Router      20896 crossbar.router.protocol.WampRawSocketServerProtocol] WampRawSocketProtocol: opening handshake received - 7ff30000
2017-12-13T20:13:31+0200 [Router      20896 crossbar.router.protocol.WampRawSocketServerProtocol] WampRawSocketProtocol: client requests us to send out most 16777216 bytes per message
2017-12-13T20:13:31+0200 [Router      20896 crossbar.router.protocol.WampRawSocketServerProtocol] WampRawSocketProtocol: client wants to use serializer '3'
2017-12-13T20:13:31+0200 [Router      20896 crossbar.router.session.RouterSession] Client session connected - transport: {u'peer': u'tcp4:127.0.0.1:35038', u'protocol': u'wamp.2.cbor', u'type': 'rawsocket'}
2017-12-13T20:13:31+0200 [Router      20896 crossbar.router.protocol.WampRawSocketServerProtocol] ApplicationSession started.
2017-12-13T20:13:31+0200 [Router      20896 crossbar.router.protocol.WampRawSocketServerProtocol] WampRawSocketProtocol: opening handshake completed: <autobahn.wamp.serializer.CBORSerializer object at 0x7f3cc1a69690>
2017-12-13T20:13:31+0200 [Router      20896 crossbar.router.protocol.WampRawSocketServerProtocol] WampRawSocketProtocol: connection lost: reason = '[Failure instance: Traceback (failure with no frames): <class 'twisted.internet.error.ConnectionLost'>: Connection to the other side was lost in a non-clean fashion.

Tracking down onto the code I see that failure happens on wampcc side: https://github.com/darrenjs/wampcc/blob/master/libs/wampcc/rawsocket_protocol.cc#L167-L170 , where serializer = 3 (as requested by wampcc and echoed by crossbar.io), but only known values for wampcc are 1 and 2 (json and msgpack), so it fails. Then I've requested serializer explicitly:

./admin --proto raw --proto msgpack 127.0.0.1 8000 -R realm1 -p com.example.oncounter --arglist '["hi"]' -d -d

and it worked fine.

My question is how things should be negotiated between wampcc and crossbar.io and where the fix is needed? Thanks!

darrenjs commented 6 years ago

Hi,

Thanks for the detailed bug info, and I have managed to re-produce it.

I think the bug is that wampcc should not send the value '3' to the server, in the first instance. Re-reading the specs, that is not a supported value. So a fix would be in rawsocket_protocol::initiate(t_initiate_cb cb), to check that the user has selected a specific serialiser; if they haven't, an exception should be thrown.

However, I think the WAMP specification is a little inconsistent here. If using a websocket, the client can say, during login, that it support both Json & MessagePack serialisations, and the server gets to choose. But this feature is apparently not supported for RawSocket (according to docs).

So, short term fix, is to reject the request in the above function. But possibly I will check with the WAMP protocol maintainers to confirm my understanding.

sashakh commented 6 years ago

Thanks, Darren, Looks like a good plan. Sasha

On Dec 14, 2017 00:05, "Darren Smith" notifications@github.com wrote:

Hi,

Thanks for the detailed bug info, and I have managed to re-produce it.

I think the bug is that wampcc should not send the value '3' to the server, in the first instance. Re-reading the specs, that is not a supported value. So a fix would be in rawsocket_protocol::initiate(t_initiate_cb cb), to check that the user has selected a specific serialiser; if they haven't, an exception should be thrown.

However, I think the WAMP specification is a little inconsistent here. If using a websocket, the client can say, during login, that it support both Json & MessagePack serialisations, and the server gets to choose. But this feature is apparently not supported for RawSocket (according to docs).

So, short term fix, is to reject the request in the above function. But possibly I will check with the WAMP protocol maintainers to confirm my understanding.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/darrenjs/wampcc/issues/18#issuecomment-351540150, or mute the thread https://github.com/notifications/unsubscribe-auth/ABCIjMgxfjjb0NAkrEfrakyC9yIexs8wks5tAEoSgaJpZM4RBAqc .

darrenjs commented 6 years ago

Fixed on c09a2b4ff0fe025853fba44d6b29dc44ffdaf059