fix broken connection handling - #107
Merged
jmglsn merged 4 commits intoMar 19, 2018
Merged
Conversation
Changed to non-blocking operations, replaced stream_get_line with fread.
staabm
reviewed
Feb 27, 2018
staabm
left a comment
Member
There was a problem hiding this comment.
Need a more in deep review tomorrow
| } | ||
| $data = $stompFrame->__toString(); | ||
| if (!@fwrite($this->connection, $data, strlen($data))) { | ||
| if (@fwrite($this->connection, $data, strlen($data)) !== strlen($data)) { |
Member
There was a problem hiding this comment.
IIRC this is not a good idea on non-blocking streams.
We either need to buffer/remember what was not yet written, or do a retry in case we have no buffer
Member
Author
|
This also adds a write timeout to the Connection.
staabm
reviewed
Mar 14, 2018
| if (@fwrite($this->connection, $data, strlen($data)) !== strlen($data)) { | ||
| throw new ConnectionException('Was not possible to write frame!', $this->activeHost); | ||
| } | ||
| $this->writeData($stompFrame->__toString(), $this->writeTimeout); |
Member
There was a problem hiding this comment.
I would pass the Frame into writeData and to the toString() stuff inside the method
staabm
reviewed
Mar 14, 2018
| { | ||
| $offset = 0; | ||
| $size = strlen($data); | ||
| $lastByteTime = microtime(true); |
Member
There was a problem hiding this comment.
shouldn't this be inside the loop?
Member
Author
There was a problem hiding this comment.
I would like to avoid that it's not timing out in case we don't have a successful write at all. So I set the initial value as first timeout challenge.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This enables non-blocking stream operations and replaces
stream_get_linewithfread. As the the previous code failed to recognize that the broker connection was dropped.This solves #104.