Friday, July 24, 2015

RserveLink Eval Failed Even When Successful

I have been playing with RserveLink and Rserve recently and found that it worked very well, except in one case (which is not really a fringe case) where it reliably returns an "Eval Failed" exception when the command actually succeeded. I was able to run the command in RStudio (Awesome R IDE) and RGUI successfully.

I am not going to include the R statement that generated the issue because it is large, but suffice it to say that it reliably works with much larger statements.

The response we get for the 4th index is 0 and the library jumps over the if statement. However, dragging the debug arrow onto the DataLength line and run the code, it continues without error.
if (response[4] != 0)
{
    Int32 DataLength = BitConverter.ToInt32(response, 4);
I changed the section of code converting the code to the following. Essentially, just getting the response data length and assume that a data length greater than 0 is successful.
Int32 DataLength = BitConverter.ToInt32(response, 4);
if (DataLength != 0)
{
The original code was posted in a zip file on SourceForge and posted back in 2007. I have emailed the author (awaiting reply) and posted my change on my RserveLink GitHub repository. The binary library targeting 4.0 Client and 4.5.1 can be found in the releases section.

I have also published an RserveLink Nuget package for ease of adding to .Net projects.

No comments: