Skip to content
This repository has been archived by the owner on Dec 29, 2022. It is now read-only.

fix coalescing tcp packets #22

Merged
merged 1 commit into from
Dec 11, 2016
Merged

fix coalescing tcp packets #22

merged 1 commit into from
Dec 11, 2016

Conversation

albertosantini
Copy link
Contributor

When the pressure on the socket is high, there is not any guarantee
for one data event per packet. Indeed multiple json messages are
coalesced in one tcp packet.

We need to add a delimeter (an arbitrary '\0', compatible with C
strings, just in case) to separate the packets in valid json messages.

So we add the delimeter when the json message is stringified and we
parse the packet to split it finally in multiple json messages.

Fixes #20

When the pressure on the socket is high, there is not any guarantee
for one data event per packet. Indeed multiple json messages are
coalesced in one tcp packet.

We need to add a delimeter (an arbitrary '\0', compatible with C
strings, just in case) to separate the packets in valid json messages.

So we add the delimeter when the json message is stringified and we
parse the packet to split it finally in multiple json messages.

Fixes #20
@nkcmr
Copy link
Owner

nkcmr commented Dec 11, 2016

@albertosantini LGTM. Thanks for the PR.

@nkcmr nkcmr merged commit 3c03e5c into nkcmr:master Dec 11, 2016
@albertosantini
Copy link
Contributor Author

Thanks a lot for the quick merge and for publishing a new release.

In another PR I will try to add a test.
Then I would like to refactor the code to encapsulate the delimeter.
Stay tuned. :)

@albertosantini albertosantini deleted the fix-issue20 branch December 11, 2016 21:34
@albertosantini
Copy link
Contributor Author

Just a feedback. :)

As you know I have been using flic in Argo, an open source trading platform.

Just tested 1.3.6 with very high tick frequency mixed with order transactions: it works very well.

Now the order and the trade transactions are correctly caught: before fixing issue 20, one transaction message was lost in the space. The provider updated the streaming API and the transaction events were fired very quickly: suddenly I got that issue (and it was a show stopper).

As a nice side effect, also the quote ticks are caught correctly: before fixing issue 20, I saw a few invalid data messages, but I didn't care because tick frequency is very high and if a few tickets are lost, in my use case, is not a serious problem.

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.

2 participants