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

registering a context twice results in keyerror #60

Closed
tacaswell opened this issue Apr 28, 2017 · 6 comments
Closed

registering a context twice results in keyerror #60

tacaswell opened this issue Apr 28, 2017 · 6 comments

Comments

@tacaswell
Copy link
Collaborator

See this with threading client, but looks like it's root is in _hub and _commands

In [7]: ct = Context()

In [8]: ct.register()
DEBUG:caproto.Broadcaster:Serializing 1 commands into one datagram
DEBUG:caproto.Broadcaster:1 of 1 RepeaterRegisterRequest(client_address='127.0.0.1')
sending to ('172.17.255.255', 5065) b'\x00\x18\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x7f\x00\x00\x01'
DEBUG:caproto.Broadcaster:Parsed 1 commands from first datagram in queue.
DEBUG:caproto.Broadcaster:0 of 1: RepeaterConfirmResponse(repeater_address='172.17.0.1')
DEBUG:caproto.Broadcaster:Processing 1/1 commands left in datagram. 0 more datagrams are cached.
Registered with repeater

In [11]: ct.register()
DEBUG:caproto.Broadcaster:Serializing 1 commands into one datagram
DEBUG:caproto.Broadcaster:1 of 1 RepeaterRegisterRequest(client_address='127.0.0.1')
sending to ('172.17.255.255', 5065) b'\x00\x18\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x7f\x00\x00\x01'
Registered with repeater

In [12]: Exception in thread Thread-3:
Traceback (most recent call last):
  File "/home/tcaswell/.virtualenvs/dd36/lib/python3.6/threading.py", line 916, in _bootstrap_inner
    self.run()
  File "/home/tcaswell/.virtualenvs/dd36/lib/python3.6/threading.py", line 864, in run
    self._target(*self._args, **self._kwargs)
  File "/home/tcaswell/source/bnl_source/caproto/caproto/threading/client.py", line 41, in __call__
    self.target_obj.next_command(bytes_recv, address)
  File "/home/tcaswell/source/bnl_source/caproto/caproto/threading/client.py", line 158, in next_command
    command = self.broadcaster.next_command()
  File "/home/tcaswell/source/bnl_source/caproto/caproto/_hub.py", line 445, in next_command
    commands = read_datagram(byteslike, address, self.their_role)
  File "/home/tcaswell/source/bnl_source/caproto/caproto/_commands.py", line 262, in read_datagram
    _class = get_command_class(role, header)
  File "/home/tcaswell/source/bnl_source/caproto/caproto/_commands.py", line 248, in get_command_class
    _class = Commands[role][header.command]
KeyError: 24
@danielballan
Copy link
Collaborator

The RepeaterRegisterRequest is making its way back to the client itself, and the client doesn't know what to do with a RepeaterRegisterRequest (or a *Request in general). The correct behavior is to ignore. I'll fix this in read_datagram.

@tacaswell
Copy link
Collaborator Author

Interesting! Multicast / udp has some weird side effects.

Why do not we see this problem if you register two broadcasters with the same repeater?

@danielballan
Copy link
Collaborator

Maybe you do. Have we ever checked that case? Not as far as I'm aware. Unfortunately, tolerating this at the protocol level really dilutes the usefulness of the Broadcaster. Good thing that the interesting action happens over TCP.

@tacaswell
Copy link
Collaborator Author

I did check and it worked :-p

@tacaswell
Copy link
Collaborator Author

it may also be that our reapater is bouncing stuff it should not.

@danielballan
Copy link
Collaborator

We now understand that the repeater was occasionally receiving a registration request twice (because UDP) and "forwarding" the second request back to the requester. This was fixed by #69.

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