title: Has anybody got "java.net.SocketException: Connection reset" when using Java-Prolog Connector
body: <p>I wonder if anyone has used Java-Prolog Connector (<a href="https://sewiki.iai.uni-bonn.de/research/pdt/connector/start" rel="nofollow noreferrer">https://sewiki.iai.uni-bonn.de/research/pdt/connector/start</a>) and met &quot;java.net.SocketException: Connection reset&quot; before.</p>
  <p>My code is like</p>
  <pre><code>PrologProcess process = Connector.newPrologProcess();
  while(condition) {
      process.restart();
      PrologSession session = process.getSession();
      session.queryOnce(assertz(...));
      String query = ...;
      Map&lt;String, Object&gt; query_result = session.queryOnce(query);
      session.dispose();
  }
  </code></pre>
  <p>So what I'm basically trying to do is to iteratively build sessions and get query results while condition holds. However, it does not always work, and it seems that if there are too many iterations I may get &quot;java.net.SocketException: Connection reset&quot; and fail to obtain sessions. Has anybody used the same tool and met the same issue? Thanks!</p>
  <p>Below is the detailed exception message:</p>
  <pre><code>org.cs3.prolog.connector.process.PrologProcessException: Failed to obtain session
      at org.cs3.prolog.connector.internal.process.AbstractPrologProcess.getSession(AbstractPrologProcess.java:371)
      at org.cs3.prolog.connector.internal.process.AbstractPrologProcess.getSession(AbstractPrologProcess.java:346)
      at com.example.demo.Search.is_done(Search.java:5363)
      at com.example.demo.Search.main(Search.java:1156)
  Caused by: org.cs3.prolog.connector.process.PrologProcessException: java.io.IOException: EndOfStream read while waiting for OK
      at org.cs3.prolog.connector.internal.lifecycle.AbstractState.error(AbstractState.java:117)
      at org.cs3.prolog.connector.internal.lifecycle.LifeCycle$3.run(LifeCycle.java:226)
      at org.cs3.prolog.connector.internal.lifecycle.LifeCycle$DispatcherThread.run(LifeCycle.java:59)
  Caused by: java.io.IOException: EndOfStream read while waiting for OK
      at org.cs3.prolog.connector.internal.process.socket.SocketClient.readUntil(SocketClient.java:185)
      at org.cs3.prolog.connector.internal.process.socket.SocketClient.readUntil(SocketClient.java:142)
      at org.cs3.prolog.connector.internal.process.socket.SocketClient.reset(SocketClient.java:105)
      at org.cs3.prolog.connector.internal.process.socket.SocketClient.&lt;init&gt;(SocketClient.java:60)
      at org.cs3.prolog.connector.internal.process.socket.SocketPrologProcess.getSession_impl(SocketPrologProcess.java:163)
      at org.cs3.prolog.connector.internal.process.AbstractPrologProcess.getSession_internal(AbstractPrologProcess.java:379)
      at org.cs3.prolog.connector.internal.process.AbstractPrologProcess.getSession(AbstractPrologProcess.java:369)
      at org.cs3.prolog.connector.internal.process.AbstractPrologProcess.getSession(AbstractPrologProcess.java:346)
      at com.example.demo.Search.is_done(Search.java:5363)
      at com.example.demo.Search.main(Search.java:1156)
  
  java.net.SocketException: Connection reset
      at java.net.SocketInputStream.read(SocketInputStream.java:209)
      at java.net.SocketInputStream.read(SocketInputStream.java:141)
      at org.cs3.prolog.connector.internal.process.socket.InputStreamProxy.read(InputStreamProxy.java:79)
      at sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:284)
      at sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:326)
      at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:178)
      at java.io.InputStreamReader.read(InputStreamReader.java:184)
      at java.io.BufferedReader.fill(BufferedReader.java:161)
      at java.io.BufferedReader.readLine(BufferedReader.java:324)
      at java.io.BufferedReader.readLine(BufferedReader.java:389)
      at org.cs3.prolog.connector.internal.process.socket.SocketClient.readUntil(SocketClient.java:174)
      at org.cs3.prolog.connector.internal.process.socket.SocketClient.readUntil(SocketClient.java:142)
      at org.cs3.prolog.connector.internal.process.socket.SocketClient.reset(SocketClient.java:105)
      at org.cs3.prolog.connector.internal.process.socket.SocketClient.&lt;init&gt;(SocketClient.java:60)
      at org.cs3.prolog.connector.internal.process.socket.SocketClient.&lt;init&gt;(SocketClient.java:53)
      at org.cs3.prolog.connector.internal.process.socket.SocketServerStartAndStopStrategy.getSocketClient(SocketServerStartAndStopStrategy.java:355)
      at org.cs3.prolog.connector.internal.process.socket.SocketServerStartAndStopStrategy.stopSocketServer(SocketServerStartAndStopStrategy.java:335)
      at org.cs3.prolog.connector.internal.process.socket.SocketServerStartAndStopStrategy.stopServer(SocketServerStartAndStopStrategy.java:326)
      at org.cs3.prolog.connector.internal.process.AbstractPrologProcess$MyLifeCycle.stopServer(AbstractPrologProcess.java:234)
      at org.cs3.prolog.connector.internal.lifecycle.ErrorState$1.run(ErrorState.java:48)
      at org.cs3.prolog.connector.internal.lifecycle.LifeCycle$DispatcherThread.run(LifeCycle.java:59)
  </code></pre>