crossbario / autobahn-python

WebSocket and WAMP in Python for Twisted and asyncio
https://crossbar.io/autobahn
MIT License
2.47k stars 768 forks source link

Support custom WAMP message attibutes #1214

Open samangh opened 5 years ago

samangh commented 5 years ago

When using the autobahn, how does one set a custom Option when registering an RPC end point?

The RegisterOptions object throws an exception when using an options that is not specified:

https://github.com/crossbario/autobahn-python/blob/fe70ceebe04849470b0c81b26ff6e65e709b0d33/autobahn/wamp/types.py#L930-L935

Section 6.1 of the WAMP specification specifies that if an option is not understood by an implementation then it must be ignored. My understanding is that this means that that the client should transmit the option to the router but not otherwise act on it.

6.1 Extensibility

Some WAMP messages contain Options|dict or Details|dict elements. This allows for future extensibility and implementations that only provide subsets of functionality by ignoring unimplemented attributes. Keys in Options and Details MUST be of type string and MUST match the regular expression [a-z][a-z0-9_]{2,} for WAMP predefined keys. Implementations MAY use implementation-specific keys that MUST match the regular expression [a-z0-9]{3,}. Attributes unknown to an implementation MUST be ignored.

samangh commented 5 years ago

Any thoughts on this?

oberstet commented 5 years ago

When using the autobahn, how does one set a custom Option when registering an RPC end point?

This is not exposed in Autobahn currently.

What router are you using?

samangh commented 5 years ago

I'm using a fork of https://github.com/darrenjs/wampcc. I'm implementing some additional functionality by using the Options element, as specified in the WAMP implementation.

oberstet commented 5 years ago

The extensibility section in the paragraph https://wamp-proto.org/_static/gen/wamp_latest_ietf.html#rfc.section.6.1 relates to the WAMP community extending the protocol itself - it is not about user extensibility.

User extensibility - aka "custom attributes" or "implementation specific attributes" - is not in the spec, but discussed here: https://github.com/wamp-proto/wamp-proto/issues/345

Thus, the first thing is to nail consensus on above issue on the WAMP spec adding x_ based custom attributes as an advanced feature to the WAMP spec.

When that is done, we need implementation .. and your PR #1216 is essentially what needs to be done here (it must then be reworked to use x_ attributes - not a custom dict).

oberstet commented 5 years ago

An important note is https://github.com/wamp-proto/wamp-proto/issues/345#issuecomment-454850745 : I fully agree with @meejah : it would be good to have use cases (the "why?" from a user perspective) described. This ensures that we actually cover the goals when defining the feature in the spec ..