Skip to content
This repository was archived by the owner on Dec 7, 2019. It is now read-only.
This repository was archived by the owner on Dec 7, 2019. It is now read-only.

Slightly incorrect end of frame handeling #18

Description

@xepa

Currently frames are read until the END_OF_FRAME marker defined as \x00\n. This is not entirely correct while reading. This end of frame is allowed for sending frames but not for reading. The correct end of frame marker is defined as \x00\n*, ie the NULL character optionally followed by any amount of newlines.

The current way of reading is not really suited as we read per new line. Thus we could timeout waiting on a NULL that is never followed by a newline. Or we could read the current frame NULL terminated and the COMMAND of the next frame that may directly follow it.

This can be prevented with ActiveMQ instructing the server to sent only one frame and then wait for an acknowledgement, but not all servers may support this. On top of that it may hurt performance.

I am not quite sure how this should be fixed. I was thinking about a refactor using an internal buffer to store data not yet processed while reading all data available. Would this be an acceptable approach ? If permitted if would be nice to incorporate (refactored a bit of course) the following classes
https://github.com/BraveSirRobin/amqphp/blob/master/src/amqphp/Socket.php
https://github.com/BraveSirRobin/amqphp/blob/master/src/amqphp/StreamSocket.php
Not sure if this is allowed licence wise what would you all think about this approach.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions