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

Randomly corrupt payload #59

Closed
byrnedo opened this issue Jun 15, 2016 · 9 comments
Closed

Randomly corrupt payload #59

byrnedo opened this issue Jun 15, 2016 · 9 comments
Assignees

Comments

@byrnedo
Copy link
Contributor

byrnedo commented Jun 15, 2016

I'm seeing that quite a high number of messages coming back from the same request are truncated somehow on the client side.

This happens randomly with the exact same message when sent repeatedly. Some work, some don't.

I debugged a little in the Connection::receive() function:

private function receive($len = null)
    {

        if ($len) {
            error_log("packet len [$len]");
            $line = fread($this->streamSocket, $len);
            error_log('line len [' . strlen($line) .']');
        } else {
            $line = fgets($this->streamSocket);
        }
        return $line;
    }

The output I get is:

PHP message: packet len [16236]
PHP message: line len [16236]
PHP message: packet len [16299]
PHP message: line len [16299]
PHP message: packet len [16258]
PHP message: line len [8658]

PHP message: line len [8658]

Is this something to do with the stream timeout?
I guess there are the following scenarios:

  1. Nats is reporting the wrong message length (packet len in the above)
  2. Fread is failing for some reason (time or otherwise)
@repejota repejota self-assigned this Jun 15, 2016
@repejota
Copy link
Owner

Hi @byrnedo is this something urgent for you?
I'm working on adding docker support on our tests and deprecate our NATS server mockup on the tests as you can see at #60, that would help a lot on testing as we will use a real and latest NATS server.

Once i finish i will take a look on this ASAP.

Cheers!

@byrnedo
Copy link
Contributor Author

byrnedo commented Jun 15, 2016

Hi @repejota,

Actually, I think I have a fix :) It should be chunk reading the message when doing fread, I am testing the fix now so will be able to make a merge request shortly.

@repejota
Copy link
Owner

Nice! Thanks mate! 😄

@byrnedo
Copy link
Contributor Author

byrnedo commented Jun 15, 2016

See pull request #61

@repejota
Copy link
Owner

repejota commented Jun 15, 2016

Closing after merging #61
Thanks @byrnedo !! 💪

@byrnedo
Copy link
Contributor Author

byrnedo commented Jun 16, 2016

No problem :)

@repejota
Copy link
Owner

But it is fixed right? If not I can reopen it an do some R&D 😉

@byrnedo
Copy link
Contributor Author

byrnedo commented Jun 16, 2016

It seems to work for me :) I was sending large-ish messages and it showed up. Small messages were fine, but all looks good now!

@byrnedo
Copy link
Contributor Author

byrnedo commented Jun 16, 2016

Shit, there was a bug, @repejota :( Check #64.

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