# Swipl mqi\_start sometimes not starting correctly

**URL:** <https://swi-prolog.discourse.group/t/swipl-mqi-start-sometimes-not-starting-correctly/6641>\
**Category:** Help!\
**Created:** [June 15, 2023, 4:55pm UTC](https://swi-prolog.discourse.group/t/swipl-mqi-start-sometimes-not-starting-correctly/6641 "2023-06-15T16:55:33Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![gilbert](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/gilbert/32/911_2.png) [@gilbert](https://swi-prolog.discourse.group/u/gilbert)\
**Post date:** [June 15, 2023, 4:55pm UTC](https://swi-prolog.discourse.group/t/swipl-mqi-start-sometimes-not-starting-correctly/6641/1 "2023-06-15T16:55:33Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![brebs](https://avatars.discourse-cdn.com/v4/letter/b/e9c0ed/32.png) [@brebs](https://swi-prolog.discourse.group/u/brebs)\
**Post date:** [June 15, 2023, 5:45pm UTC](https://swi-prolog.discourse.group/t/swipl-mqi-start-sometimes-not-starting-correctly/6641/2 "2023-06-15T17:45:34Z")

</div>

> [@gilbert](#):
>
> only outputs a single number

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

---

<div class="post-metadata">

**Author:** ![gilbert](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/gilbert/32/911_2.png) [@gilbert](https://swi-prolog.discourse.group/u/gilbert)\
**Post date:** [June 15, 2023, 8:14pm UTC](https://swi-prolog.discourse.group/t/swipl-mqi-start-sometimes-not-starting-correctly/6641/3 "2023-06-15T20:14:50Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![brebs](https://avatars.discourse-cdn.com/v4/letter/b/e9c0ed/32.png) [@brebs](https://swi-prolog.discourse.group/u/brebs)\
**Post date:** [June 16, 2023, 6:48am UTC](https://swi-prolog.discourse.group/t/swipl-mqi-start-sometimes-not-starting-correctly/6641/4 "2023-06-16T06:48:07Z")

</div>

> [@gilbert](#):
>
> My program reads these values

Care to show your code for reading these 2 values?

---

<div class="post-metadata">

**Author:** ![gilbert](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/gilbert/32/911_2.png) [@gilbert](https://swi-prolog.discourse.group/u/gilbert)\
**Post date:** [July 4, 2023, 3:54pm UTC](https://swi-prolog.discourse.group/t/swipl-mqi-start-sometimes-not-starting-correctly/6641/5 "2023-07-04T15:54:18Z")

</div>

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

Gratefully the problem was on my end 🙌 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!
