BRouter server response: connection denied

Issue #355 resolved
Jürgen Beck created an issue

OS: Ubuntu 16.04.4 LTS (64 bit) - Kernel: 4.13.0-45-generic

QMapShack built from following sources:
qmapshack-1.11.1.tar.gz, gdal-2.2.4.tar.gz, proj-5.0.1.tar.gz. routino-3.2.tgz. qt-opensource-linux-x64-5.5.1.run

Running QMapShack:
export QTDIR=~/QMapShack/src/Qt5.5.1/5.5/gcc_64;
export LD_LIBRARY_PATH=$QTDIR/lib:/usr/local/lib;
/usr/local/bin/qmapshack

Minor issue when creating first new track after program start using local BRouter 1.4.11 installation: Error message "Invalid server response: connection denied"

Few seconds later message disappears and from now server is routing as expected. Maybe an initial timing problem between QMapShack and BRouter application?

Comments (4)

  1. Norbert Truchsess

    that is caused by brouter taking longer to open the port after startup of the process than QMS issuing its first routing-request. Does not happen if you start BRouter manually before. I'll check whether I can implement waiting on the open port instead of waiting for startup of process to solve this issue.

  2. Jürgen Beck reporter

    To check if issue #355 got resolved I integrated committed method of determining BRouter local server's ready-for-connect state into QMS 1.11.1 release code. I encountered 3 different behaviours which make me believe that method is not yet reliable.

    1. Rarely - issue #355 still occurs and QMS application windows shows error message "Invalid server response: connection denied"
    2. Mostly - issue #355 does not occur
    3. Sometimes - issue #355 does not occur but terminal window shows warning message
    [warning] QAbstractSocket::waitForDisconnected() is not allowed in UnconnectedState
    

    Then I inserted following debug line of code after count loop ...

    printf("connected=%d counts=%d\n",connected?1:0,counts);fflush(stdout);
    

    ... and got following output:

    • Case 3 - connected=1 counts>0 - Connecting socket to BRouter process succeeded within 10 attempts, i.e 10*100 msec = 1 second
    • Case 2 - connected=0 counts=0 - Connecting did not succeed within 10 attempts or 1 sec. Nevertheless 1 second delay was enough for BRouter process to become ready for accepting connection when starting new track.
    • Case 1 - connected=0 counts=0 - Connecting did not succeed within 10 attempts or 1 sec. BRouter process was still not ready for accepting connection. Increasing attempt count to 50 i.e. 5 seconds did help.

    To avoiding warning message in case 3, following line of code should get changed:

    - socket.waitForDisconnected();
    + if (socket.state() != QAbstractSocket::UnconnectedState) socket.waitForDisconnected();
    
  3. Log in to comment