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

Publishing events seem not to create PUBLISHED message. #1940

Closed
aarlt opened this issue Feb 4, 2022 · 2 comments
Closed

Publishing events seem not to create PUBLISHED message. #1940

aarlt opened this issue Feb 4, 2022 · 2 comments

Comments

@aarlt
Copy link

aarlt commented Feb 4, 2022

Hello! I recently discovered WAMP & crossbar. I'm really impressed by this project and the protocol. It seem to be a perfect match for a project that I have in mind since many months. So I started to do some very basic things to get a better understanding how all this could be used.

For simple first tests I created a dynamic authenticator that enable the usage of cryptosign. I basically just used https://github.com/crossbario/crossbar-examples/blob/master/authentication/cryptosign/dynamic/authenticator.py and at least from the authentication point of view everything seem to work as expected.

As a WAMP client I decided to use connectanum-dart. I wrote a very basic program

import 'dart:async';
import 'dart:io';

import 'package:connectanum/authentication.dart';
import 'package:connectanum/connectanum.dart';
import 'package:connectanum/json.dart';

void main() async {
  final client1 = Client(
    realm: 'test',
    transport: WebSocketTransport(
      'ws://127.0.0.1:8080',
      Serializer(),
      WebSocketSerialization.SERIALIZATION_JSON,
    ),
    authenticationMethods: [CryptosignAuthentication.fromHex('00' * 32)],
  );
  final session1 = await client1.connect().first;
  final subscription = await session1.subscribe(
      '3b6a27bcceb6a42d62a3a8d02a6f0d73653215771de243a63ac048a18b59da29.push');
  subscription.eventStream!.listen(
      (event) => print('received from <id>.push: \'${event.arguments![0]}\''));

  final client2 = Client(
    realm: 'test',
    transport: WebSocketTransport(
      'ws://127.0.0.1:8080',
      Serializer(),
      WebSocketSerialization.SERIALIZATION_JSON,
    ),
    authenticationMethods: [CryptosignAuthentication.fromHex('00' * 32)],
  );
  final session2 = await client2.connect().first;

  await session2.publish(
      '3b6a27bcceb6a42d62a3a8d02a6f0d73653215771de243a63ac048a18b59da29.push',
      arguments: ['Hello']);

  await session2.publish(
      '3b6a27bcceb6a42d62a3a8d02a6f0d73653215771de243a63ac048a18b59da29.push',
      arguments: ['World']);

  unawaited(session1.close());
  unawaited(session2.close());
}

For my surprise the program got stuck inside the first await session.publish. Initially I thought that I did something wrong, because I don't have that much experience with dart yet. I also thought that I used the client library in a wrong way, so a created an issue konsultaner/connectanum-dart#39.

In this issue @konsultaner was asking me, whether the router is firing the needed PUBLISHED message. So I checked the corresponding logs.

2022-02-03T14:39:51-0500 [Router      10810 crossbar.router.protocol.WampWebSocketServerProtocol] WAMP RECV: message=Publish(request=1, topic=3b6a27bcceb6a42d62a3a8d02a6f0d73653215771de243a63ac048a18b59da29.push, args=['WHello'], kwargs=None, acknowledge=None, exclude_me=None, exclude=None, exclude_authid=None, exclude_authrole=None, eligible=None, eligible_authid=None, eligible_authrole=None, retain=None, enc_algo=None, enc_key=None, enc_serializer=None, payload=-, forward_for=None), session=7557342860847853, authid=3b6a27bcceb6a42d62a3a8d02a6f0d73653215771de243a63ac048a18b59da29

2022-02-03T14:39:51-0500 [Router      10810 crossbar.router.router.Router] Validate 'event' for '3b6a27bcceb6a42d62a3a8d02a6f0d73653215771de243a63ac048a18b59da29.push'

2022-02-03T14:39:51-0500 [Router      10810 crossbar.router.role.RouterRole] CrossbarRouterRoleStaticAuth.authorize identity 3b6a27bcceb6a42d62a3a8d02a6f0d73653215771de243a63ac048a18b59da29.push publish

2022-02-03T14:39:51-0500 [Router      10810 crossbar.router.router.Router] Authorized action 'publish' for URI '3b6a27bcceb6a42d62a3a8d02a6f0d73653215771de243a63ac048a18b59da29.push' by session 7557342860847853 with authid '3b6a27bcceb6a42d62a3a8d02a6f0d73653215771de243a63ac048a18b59da29' and authrole 'identity' -> authorization: {'allow': True, 'disclose': False, 'cache': True}

2022-02-03T14:39:51-0500 [Router      10810 crossbar.router.broker.Broker] <crossbar.router.broker.Broker.processPublish>::on_authorize_success() - permission GRANTED for PUBLISH to topic "3b6a27bcceb6a42d62a3a8d02a6f0d73653215771de243a63ac048a18b59da29.push" [realm="test", session_id=7557342860847853, authid="3b6a27bcceb6a42d62a3a8d02a6f0d73653215771de243a63ac048a18b59da29", authrole="identity"]

2022-02-03T14:39:51-0500 [Router      10810 crossbar.router.broker.Broker] dispatching for subscription=ExactUriObservation(id=2741518893347922, uri=3b6a27bcceb6a42d62a3a8d02a6f0d73653215771de243a63ac048a18b59da29.push, match=exact, ordered=False, extra=<crossbar.router.broker.SubscriptionExtra object at 0x1187afbb0>, created=2022-02-03T19:39:51.302Z, observers={<crossbar.router.session.RouterSession object at 0x1187238e0>}), storing_event=False

2022-02-03T14:39:51-0500 [Router      10810 crossbar.router.broker.Broker] unchunked dispatching to 1 receivers

2022-02-03T14:39:51-0500 [Router      10810 crossbar.router.protocol.WampWebSocketServerProtocol] WAMP SEND: message=Event(subscription=2741518893347922, publication=8264063572469899, args=['Hello'], kwargs=None, publisher=None, publisher_authid=None, publisher_authrole=None, topic=None, retained=None, enc_algo=None, enc_key=None, enc_serializer=None, payload=-, forward_for=None), session=3677469751106487, authid=3b6a27bcceb6a42d62a3a8d02a6f0d73653215771de243a63ac048a18b59da29

The strange thing is that the PUBLISHED message seem not to get generated during publish. I only see an EVENT message that seem to be used to inform the subscribers, but the needed PUBLISHED message is missing.

Because the current state of my router only consists of a dynamic authenticator, I'm not sure what I could have done wrong here. But maybe I missed something here.

For my tests I used crossbar.io v21.3.1.

Any ideas?

@oberstet
Copy link
Contributor

oberstet commented Feb 4, 2022

I'm really impressed by this project and the protocol. It seem to be a perfect match for a project that I have in mind since many months.

hi there and welcome! thanks for the nice words, good to hear=)

I'm not sure what I could have done wrong here. But maybe I missed something here.

yeah, there are 2 ways of publishing: unacknowledged (means, nothing returned from router) or acknowledge (success return with publication ID and such is returned)

pls have a look here https://autobahn.readthedocs.io/en/latest/wamp/programming.html?highlight=acknowledge#publishing-events

if you need example code, here:

find ~/scm/crossbario/autobahn-python/examples/ -name "*.py" -exec grep -Hi "acknowledge" {} \;
find ~/scm/crossbario/crossbar-examples/ -name "*.py" -exec grep -Hi "acknowledge" {} \;

@aarlt
Copy link
Author

aarlt commented Feb 4, 2022

Thanks a lot! Everything works now as expected!

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

No branches or pull requests

2 participants