Changeset 10960 in ntrip for trunk/BNC/src/bncnetqueryv2.cpp


Ignore:
Timestamp:
Jul 27, 2026, 1:43:45 PM (4 days ago)
Author:
stuerze
Message:

A timeout is added to allow a reonnect after an outage of Ntrip Version 2/2s streams

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/BNC/src/bncnetqueryv2.cpp

    r10802 r10960  
    1616
    1717#include <iostream>
     18
     19#include <QTimer>
    1820
    1921#include "bncnetqueryv2.h"
     
    3436  _firstData = true;
    3537  _status    = init;
     38  _timeOut   = 20000;
    3639
    3740  bncSettings settings;
     
    215218  // Wait Loop
    216219  // ---------
     220  bool timedOut = false;
    217221  if (!_reply->bytesAvailable()) {
     222    QTimer timer;
     223    timer.setSingleShot(true);
     224    connect(&timer, SIGNAL(timeout()), _eventLoop, SLOT(quit()));
     225    timer.start(_timeOut);
    218226    _eventLoop->exec();
     227    timedOut = !timer.isActive();
    219228  }
    220229  if (!_reply) {
     230    return;
     231  }
     232
     233  // Timeout: neither new data arrived nor did the request finish
     234  // (e.g. connection silently dropped by a NAT/firewall)
     235  // --------------------------------------------------------------
     236  if (timedOut) {
     237    _status = error;
     238    emit newMessage(_url.path().toLatin1().replace(0,1,"")
     239                    + ": Read timeout", true);
     240    disconnect(_reply, SIGNAL(finished()), this, SLOT(slotFinished()));
     241    _reply->abort();
    221242    return;
    222243  }
Note: See TracChangeset for help on using the changeset viewer.