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

BUG: Lack of client address in case RPCReceiveError #1809

Closed
marcinh opened this issue Nov 24, 2022 · 1 comment
Closed

BUG: Lack of client address in case RPCReceiveError #1809

marcinh opened this issue Nov 24, 2022 · 1 comment

Comments

@marcinh
Copy link

marcinh commented Nov 24, 2022

What pyzmq version?

24.0.1

What libzmq version?

4.3.4

Python version (and how it was installed)

3.9.13

OS

Windows/CentOS

What happened?

When RPCReceiveError is raised there is no information about the address of client that sent malformed message:

class BaseSocket:
   ...
    def recv_from_client(self):
        try:
            data = self.socket.recv_multipart()
            addr = data[0].decode()
        except UnicodeDecodeError as e:
            raise RPCReceiveError("ZMQ interrupted or corrupted message") from e
        except zmqerr.ZMQError as e:
            raise RPCError("ZMQ network broken") from e
        try:
            msg = Message.unserialize(data[1])
        except (UnicodeDecodeError, msgerr.ExtraData) as e:
            raise RPCReceiveError("ZMQ interrupted or corrupted message") from e
        return addr, msg

when UnicodeDecodeError or msgerr.ExtraData is caught we have available addr (or whole data) variable and it could be pass as an RPCReceiveError attribute so that it can be properly handled on higher layers of the code (e.g. implement some kind of retry mechanism or discard if this message is from outside of host pool)

Code to reproduce bug

No response

Traceback, if applicable

No response

More info

This is especially used when server receives any message with different protocol (e.g. any HTTP get sent accidentally on socket port)

@marcinh
Copy link
Author

marcinh commented Dec 7, 2022

Opened by mistake

@marcinh marcinh closed this as completed Dec 7, 2022
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

1 participant