Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QWebSocket server stalls after 2k connections
Forum Updated to NodeBB v4.3 + New Features

QWebSocket server stalls after 2k connections

Scheduled Pinned Locked Moved Unsolved General and Desktop
7 Posts 2 Posters 838 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    Delavega77
    wrote on last edited by aha_1980
    #1

    Hi all,

    i just configured the websocket server from the example qt5.12 on linux machine ubuntu 18.04. I builded the echosslclient example as well and i tried to perform a loop to make 10k thousands connections. But after about 2k connections the cpu goes at 100% and no more connections is allowed. Moreover if i disconnect the clients already connected i see the event in the server and clients are disconnected, but if i try to connect again no event is triggered.
    So i want figure out if it is some missing machine configuration (max tcp connection, ipconfig...) or it is something related to the qwebsocket server object.
    Any suggestion/comment is appreciated.
    Thank you Diego

    raven-worxR 1 Reply Last reply
    0
    • D Delavega77

      Hi all,

      i just configured the websocket server from the example qt5.12 on linux machine ubuntu 18.04. I builded the echosslclient example as well and i tried to perform a loop to make 10k thousands connections. But after about 2k connections the cpu goes at 100% and no more connections is allowed. Moreover if i disconnect the clients already connected i see the event in the server and clients are disconnected, but if i try to connect again no event is triggered.
      So i want figure out if it is some missing machine configuration (max tcp connection, ipconfig...) or it is something related to the qwebsocket server object.
      Any suggestion/comment is appreciated.
      Thank you Diego

      raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by
      #2

      @Delavega77
      how do you test your connections exactly?
      Did you try to attach a debugger at the state where no more connections are possible?

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      D 1 Reply Last reply
      0
      • raven-worxR raven-worx

        @Delavega77
        how do you test your connections exactly?
        Did you try to attach a debugger at the state where no more connections are possible?

        D Offline
        D Offline
        Delavega77
        wrote on last edited by
        #3

        @raven-worx
        Hi ,
        i just logged the number of connection established on the server side and on client side i get the message when it is connected.
        I also tried from qt ide in debug mode but when no more connections are possible nothing happens.
        Please let me know if i can test more.
        Thank you.

        raven-worxR 1 Reply Last reply
        0
        • D Delavega77

          @raven-worx
          Hi ,
          i just logged the number of connection established on the server side and on client side i get the message when it is connected.
          I also tried from qt ide in debug mode but when no more connections are possible nothing happens.
          Please let me know if i can test more.
          Thank you.

          raven-worxR Offline
          raven-worxR Offline
          raven-worx
          Moderators
          wrote on last edited by raven-worx
          #4

          @Delavega77
          what is the memory consumption at this time of your server application?

          You wrote:

          But after about 2k connections the cpu goes at 100% and no more connections is allowed.

          At this time you can in the debugger press the PAUSE button and check the position the runtime currently is in. Maybe this gives a clue whats going on.
          You might need to repeat this a few times until you get a state which helps giving some information.

          --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
          If you have a question please use the forum so others can benefit from the solution in the future

          D 1 Reply Last reply
          2
          • raven-worxR raven-worx

            @Delavega77
            what is the memory consumption at this time of your server application?

            You wrote:

            But after about 2k connections the cpu goes at 100% and no more connections is allowed.

            At this time you can in the debugger press the PAUSE button and check the position the runtime currently is in. Maybe this gives a clue whats going on.
            You might need to repeat this a few times until you get a state which helps giving some information.

            D Offline
            D Offline
            Delavega77
            wrote on last edited by
            #5

            @raven-worx

            Hi,
            I tried your suggestion and i found that is stalled qeventdispatcher_glib.cpp

            Details:

            bool QEventDispatcherGlib::processEvents(QEventLoop::ProcessEventsFlags flags)
            {
                Q_D(QEventDispatcherGlib);
            
                const bool canWait = (flags & QEventLoop::WaitForMoreEvents);
                if (canWait)
                    emit aboutToBlock();
                else
                    emit awake();
            
                // tell postEventSourcePrepare() and timerSource about any new flags
                QEventLoop::ProcessEventsFlags savedFlags = d->timerSource->processEventsFlags;
                d->timerSource->processEventsFlags = flags;
            
                if (!(flags & QEventLoop::EventLoopExec)) {
                    // force timers to be sent at normal priority
                    d->timerSource->runWithIdlePriority = false;
                }
            
                bool result = g_main_context_iteration(d->mainContext, canWait);
                while (!result && canWait)
                    result = g_main_context_iteration(d->mainContext, canWait);
            
                d->timerSource->processEventsFlags = savedFlags;
            
                if (canWait)
                    emit awake();
            
                return result;
            }
            

            and here:

            bool QEventDispatcherGlib::processEvents(QEventLoop::ProcessEventsFlags flags)
            {
                Q_D(QEventDispatcherGlib);
            
                const bool canWait = (flags & QEventLoop::WaitForMoreEvents);
                if (canWait)
                    emit aboutToBlock();
                else
                    emit awake();
            
                // tell postEventSourcePrepare() and timerSource about any new flags
                QEventLoop::ProcessEventsFlags savedFlags = d->timerSource->processEventsFlags;
                d->timerSource->processEventsFlags = flags;
            
                if (!(flags & QEventLoop::EventLoopExec)) {
                    // force timers to be sent at normal priority
                    d->timerSource->runWithIdlePriority = false;
                }
            
                bool result = g_main_context_iteration(d->mainContext, canWait);
                while (!result && canWait)
                    result = g_main_context_iteration(d->mainContext, canWait);
            
                d->timerSource->processEventsFlags = savedFlags;
            
                if (canWait)
                    emit awake();
            
                return result;
            }
            

            Thank you

            D 1 Reply Last reply
            0
            • D Delavega77

              @raven-worx

              Hi,
              I tried your suggestion and i found that is stalled qeventdispatcher_glib.cpp

              Details:

              bool QEventDispatcherGlib::processEvents(QEventLoop::ProcessEventsFlags flags)
              {
                  Q_D(QEventDispatcherGlib);
              
                  const bool canWait = (flags & QEventLoop::WaitForMoreEvents);
                  if (canWait)
                      emit aboutToBlock();
                  else
                      emit awake();
              
                  // tell postEventSourcePrepare() and timerSource about any new flags
                  QEventLoop::ProcessEventsFlags savedFlags = d->timerSource->processEventsFlags;
                  d->timerSource->processEventsFlags = flags;
              
                  if (!(flags & QEventLoop::EventLoopExec)) {
                      // force timers to be sent at normal priority
                      d->timerSource->runWithIdlePriority = false;
                  }
              
                  bool result = g_main_context_iteration(d->mainContext, canWait);
                  while (!result && canWait)
                      result = g_main_context_iteration(d->mainContext, canWait);
              
                  d->timerSource->processEventsFlags = savedFlags;
              
                  if (canWait)
                      emit awake();
              
                  return result;
              }
              

              and here:

              bool QEventDispatcherGlib::processEvents(QEventLoop::ProcessEventsFlags flags)
              {
                  Q_D(QEventDispatcherGlib);
              
                  const bool canWait = (flags & QEventLoop::WaitForMoreEvents);
                  if (canWait)
                      emit aboutToBlock();
                  else
                      emit awake();
              
                  // tell postEventSourcePrepare() and timerSource about any new flags
                  QEventLoop::ProcessEventsFlags savedFlags = d->timerSource->processEventsFlags;
                  d->timerSource->processEventsFlags = flags;
              
                  if (!(flags & QEventLoop::EventLoopExec)) {
                      // force timers to be sent at normal priority
                      d->timerSource->runWithIdlePriority = false;
                  }
              
                  bool result = g_main_context_iteration(d->mainContext, canWait);
                  while (!result && canWait)
                      result = g_main_context_iteration(d->mainContext, canWait);
              
                  d->timerSource->processEventsFlags = savedFlags;
              
                  if (canWait)
                      emit awake();
              
                  return result;
              }
              

              Thank you

              D Offline
              D Offline
              Delavega77
              wrote on last edited by
              #6

              @raven-worx
              Any idea?
              Thank you

              raven-worxR 1 Reply Last reply
              0
              • D Delavega77

                @raven-worx
                Any idea?
                Thank you

                raven-worxR Offline
                raven-worxR Offline
                raven-worx
                Moderators
                wrote on last edited by
                #7

                @Delavega77
                hard to say.
                The complete callstack would be more interesting. But even then the bug might be outside (anywhere before).

                --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
                If you have a question please use the forum so others can benefit from the solution in the future

                1 Reply Last reply
                0

                • Login

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved