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

Does the send callback indicate an error condition? #56

Closed
ajoseps opened this issue Aug 10, 2019 · 3 comments
Closed

Does the send callback indicate an error condition? #56

ajoseps opened this issue Aug 10, 2019 · 3 comments

Comments

@ajoseps
Copy link

ajoseps commented Aug 10, 2019

It seems that the callback for the FIX send and sendRaw functions only trigger HandleOKCallback and not the HandleErrorCallback. The reason why I suspect this is because I tried the following scenario.

1. Logon to FIX Session
2. Sleep before sending FIX message
3. Disconnect/Disable Internet
4. Sleep ends. Continue execution to send message
5. Callback gets triggered but the passed in value to the callback function is null

I also tried the success case and confirmed the passed in value of the callback is still null.

The default version of HandleErrorCallback which is not overriden by FixSessionAsyncWorker passes back an error value. The overriden HandleOKCallback always passes back a null value. In nan's WorkComplete function, it conditions which callback to call based on errmsg_. I suspect node-quickfix does not set errmsg_ when a failure occurs.

Code Snippets I used inside my initiator:

console.log('sleeping for 5 seconds');
sleep(5000)
console.log('done sleeping');
this.send(req, (err) => {
    console.log(`ERROR: ${err}`);
});

Definition of sleep:

function sleep(miliseconds) {
   var currentTime = new Date().getTime();
   while (currentTime + miliseconds >= new Date().getTime()) {
   }
}
@askmike
Copy link

askmike commented Aug 19, 2019

Not familiar with this lib, but your sleep function is blocking the event loop. Meaning no callbacks can fire until it (and everything in sync after it) completes. I'd look into setTimeout if I were you.

@ajoseps
Copy link
Author

ajoseps commented Aug 19, 2019

That was the point of the sleep function... to halt execution until the network connection was disabled, and to fire the callbacks afterwards so that they fail to send.

Regardless, the reason why there is no error propagation is because the underlying quickfix library does not propagate send errors. I believe it stores all failed messages into a queue/buffer and just retries them indefinitely. The send function in quickfix always returns true, so the nodejs wrapper would never know if it ever failed. I was able to trigger the HandleErrorCallback by placing SetErrorMessage() into the happy path, but since there is no way to determine if a send actually failed without modifying quickfix itself, we can't really do much on the node layer. Relevant SO

@ajoseps ajoseps closed this as completed Aug 19, 2019
@askmike
Copy link

askmike commented Aug 20, 2019 via email

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