Skip to content
This repository has been archived by the owner on Jun 8, 2020. It is now read-only.

Added fragmented text message handling in WebSocketClientHandler #360

Merged
merged 6 commits into from
Aug 21, 2019

Conversation

Nephtys
Copy link
Contributor

@Nephtys Nephtys commented Jul 23, 2019

When the received message was fragmented, the first part was sent to the message handler and the rest of the message was ignored.
The first message has type TextWebSocketFrame and the following have type ContinuationWebSocketFrame. Each frame has a boolean finalFragment to indicate if the message was fully received.
See RFC 6455 section 5.4 and 5.2, and Netty WebSocket08FrameDecoder for more information.

Nephtys added 2 commits July 23, 2019 14:31
(if the websocket message was fragmented, only the first part was sent to the message handler and the rest of the message was ignored). See RFC 6455 section 5.4 and 5.2 for more information.
* develop: (35 commits)
  Bump netty-codec-http from 4.1.36.Final to 4.1.37.Final
  Bump log4j-slf4j-impl from 2.11.2 to 2.12.0
  Bump log4j-core from 2.11.2 to 2.12.0
  Bump netty-handler from 4.1.36.Final to 4.1.37.Final
  Bump netty-all from 4.1.36.Final to 4.1.37.Final
  Bump rxjava2-interop from 0.13.6 to 0.13.7
  Bump maven-javadoc-plugin from 3.1.0 to 3.1.1
  Bump mockito-core from 2.28.2 to 3.0.0
  Bump fluent-hc from 4.5.5 to 4.5.9
  Bump xchange.version from 4.3.19 to 4.3.20
  Revert previous changes
  Revert previous changes
  Add ws client handler
  Update lib to use root project
  update parent lib
  update parent lib
  version update
  update
  Update
  update
  ...
@Nephtys
Copy link
Contributor Author

Nephtys commented Jul 23, 2019

Issues mentioning intermittent failures or lost messages may be related

@badgerwithagun
Copy link
Collaborator

@Nephtys: The change looks sensible. Did you encounter this issue with a specific exchange, or is this just precautionary?

@Nephtys
Copy link
Contributor Author

Nephtys commented Aug 21, 2019

We encountered this issue with snapshot messages on the LGO exchange websocket, but it's not an exchange specific case, it's how the websocket protocol was designed and any exchange using message framing will encounter this issue.
The resulting errors can be silent because the message is received incomplete, so it can be ignored by the following handlers (in fact, in case of a JSON payload, the JSON will be incomplete, resulting in an exception in the JSON parser and the message never sent to the exchange specific handler (or null). That's why that could be the reason for some other open bugs like "message lost" problems in xchange-stream.
See RFC 6455 section 5.4 and 5.2, and Netty WebSocket08FrameDecoder for more information on how the websocket protocol is built.

@badgerwithagun
Copy link
Collaborator

All understood; I did read up on this part of the protocol before asking. I'm just wondering which issues this fix might close, since the original reporters might find it interesting. #284 perhaps. I found it odd that I've never seen it, but I agree; it's probably that it's manifesting in lots of different ways.

In any case, this looks sensible, as I said, so LGTM.

Copy link
Collaborator

@badgerwithagun badgerwithagun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirmed that this doesn't need to be a StringBuffer:

https://stackoverflow.com/questions/46508433/concurrency-in-netty

Approved

@badgerwithagun badgerwithagun merged commit 51a88cd into bitrich-info:develop Aug 21, 2019
@davidjirovec
Copy link
Contributor

Yes, it looks it could help. I am still running my custom xchange-stream bitfinex version with checksums. Still checksum error a few times a day. I'll try changes from this PR, after a few days I can say if it helped.

@badgerwithagun
Copy link
Collaborator

Thanks @Nephtys and @davidjirovec

@Nephtys
Copy link
Contributor Author

Nephtys commented Aug 21, 2019

Yes you're right @badgerwithagun, maybe #284 and maybe #183 and #137

Thank you for your review !

@Nephtys Nephtys deleted the fix/frame-fragments branch August 21, 2019 08:58
davidjirovec pushed a commit to davidjirovec/xchange-stream that referenced this pull request Aug 21, 2019
Added fragmented text message handling in WebSocketClientHandler
@davidjirovec
Copy link
Contributor

Testing, checksum errors still sometimes show up :-|

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants