Swipl mqi_start sometimes not starting correctly

I’m using: SWI-Prolog version 9.1.10 for aarch64-linux

I’m running the following command to spawn an instance of SWI Prolog that I can query from a separate process:

swipl --quiet -g mqi_start -t halt -- --write_connection_values=true

This outputs a string in the format of two numbers separated by a space: a port number and a password. My program reads these values and connects to the SWI process. This works and my program can use the connection to consult Prolog code and query it.

However, in rare cases in the same environment that usually works, the swipl command only outputs a single number instead (which breaks my program). In addition, when this happens once, it starts happening more consistently thereafter.

Any ideas why might this be the case? Is there some sort of error handling I can add that I’m missing?

Which single number - the port or the password? Can tell by the length.

2 Likes

It’s 5 digits long, so must be the port.

Care to show your code for reading these 2 values?

Sorry for the late response, it took a while before the problem appeared again.

Gratefully the problem was on my end :raised_hands: My program was not accumulating network data chunks, and assuming the first chunk was always the full message. Thus it broke in the case that the port/password was sent in more than one chunk.

Thank you for the help!