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

SocketIOUser not support send BINARY data #2457

Closed
2 tasks done
luis-allan opened this issue Nov 10, 2023 · 3 comments
Closed
2 tasks done

SocketIOUser not support send BINARY data #2457

luis-allan opened this issue Nov 10, 2023 · 3 comments

Comments

@luis-allan
Copy link

Prerequisites

Description

in this function, it prevent user to send data in OPCODE_BINARY, so I suggest to export websocket 'opcode' param to user as bellow。

    # def send(self, body, name=None, context={}, opcode=websocket.ABNF.OPCODE_TEXT)
    def send(self, body, name=None, context={}):
        if not name:
            if body == "2":
                name = "2 heartbeat"
            else:
                # hoping this is a subscribe type message, try to detect name
                m = re.search(r'(\d*)\["([a-z]*)"', body)
                assert m is not None
                code = m.group(1)
                action = m.group(2)
                url_part = re.search(r'"url": *"([^"]*)"', body)
                assert url_part is not None
                url = re.sub(r"/[0-9_]*/", "/:id/", url_part.group(1))
                name = f"{code} {action} url: {url}"

        self.environment.events.request.fire(
            request_type="WSS",
            name=name,
            response_time=None,
            response_length=len(body),
            exception=None,
            context={**self.context(), **context},
        )
        logging.debug(f"WSS: {body}")
        # self.ws.send(body, opcode)
        self.ws.send(body)
@cyberw
Copy link
Collaborator

cyberw commented Nov 10, 2023

👍 PR welcome! (technically this issue should be in locust-plugins but its ok :)

@luis-allan
Copy link
Author

👍 PR welcome! (technically this issue should be in locust-plugins but its ok :)

a PR is created in locust-plugins.pr-151

@cyberw
Copy link
Collaborator

cyberw commented Nov 22, 2023

Merged!

@cyberw cyberw closed this as completed Nov 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants