Number of selected items does not match actual selected items

6 posts, 0 answers
  1. Graeme
    Graeme avatar
    31 posts
    Member since:
    Aug 2014

    Posted 30 Sep 2014 Link to this post

    I'm logging A HUGE amount of sessions as part of some troubleshooting and fiddler is becoming very slow to respond (in some cases unusable) as a result. My thinking of working around this was to get Fiddler to save the sessions to a file every x sessions then clear the list.

    My FiddlerScript looks like this (this should save every 100 sessions to a file, though when it works I will increase this number):

    //---------------------BEGIN FIDDLERSCRIPT EXCERPT---------------------
    var numberOfLoggedSessions: int = 0;
    var savedArchivesCount: int = 0;

    class Handlers
    {
    ...
        static function OnDone(oSession: Session) {
            if (numberOfLoggedSessions > 98) {
                FiddlerApplication.UI.actSelectAll();
                numberOfLoggedSessions = 0;
                var sessionsToSave: Session[] = FiddlerApplication.UI.GetSelectedSessions();
                savedArchivesCount ++;
                FiddlerApplication.UI.actSaveSessionsToZip("C:\\Users\\storage\\Desktop\\" + savedArchivesCount + ".saz");
                FiddlerApplication.UI.actRemoveSelectedSessions();
            } else {
                numberOfLoggedSessions ++;
            }
        }
    ...
    }
    //---------------------END FIDDLERSCRIPT EXCERPT---------------------

    When I test it, it seems to work, so I leave it for a bit and eventually come back and see an error message that I don't understand:

    There was a problem with your FiddlerScript.

    Number of selected items does not match actual selected items.
      at
    System.Windows.Forms.ListView.SelectedListViewItemCollection.get_SelectedItemArray()
      at
    System.Windows.Forms.ListView.SelectedListViewItemCollection.CopyTo(Array dest, Int32 index)
      at Fiddler.frmViewer.WeakStoreWebSessionsBeforeDelete(Object oLVIC)
      at Fiddler.frmViewer.actRemoveSelectedSessions()
      at Fiddler.ScriptNamespace.Handlers.OnDone(Session oSession)
      at Fiddler.FiddlerScript.DoSessionCompleted(Session oSession)

    Do you have any ideas what's going wrong?
  2. Eric Lawrence
    Admin
    Eric Lawrence avatar
    833 posts

    Posted 30 Sep 2014 Link to this post

    Hi, Graeme--

    Curious: What's your definition of "A HUGE amount"?

    The fundamental problem you're having is that you're trying to interact with Fiddler's UI from a background (session processing) thread. In Windows, access to UI must occur on the UI thread only, or you risk running into corruption because the other threads will have an inconsistent view of the UI state.

    Extract your code into a method, e.g. 

    public static function doDump(): void
    {
     
      FiddlerApplication.UI.actSelectAll();
       savedArchivesCount ++;
       FiddlerApplication.UI.actSaveSessionsToZip("C:\\Users\\storage\\Desktop\\" + savedArchivesCount + ".saz");
       FiddlerApplication.UI.actRemoveSelectedSessions();
    }

    And then call it like so:

    static function OnDone(oSession: Session) {
      ++numberOfLoggedSessions;
      if (numberOfLoggedSessions > 99) 
      {
        numberOfLoggedSessions = 0;
        var miUI: MethodInvoker = doDump;
        FiddlerApplication.UI.Invoke(miUI);
      }        
    }


    Regards,
    Eric Lawrence
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

  3. Graeme
    Graeme avatar
    31 posts
    Member since:
    Aug 2014

    Posted 01 Oct 2014 in reply to Eric Lawrence Link to this post

    Yep, that works better.

    Thanks!
  4. Graeme
    Graeme avatar
    31 posts
    Member since:
    Aug 2014

    Posted 01 Oct 2014 in reply to Graeme Link to this post

    ...oh and a huge amount is somewhere in the region of 3,000,000 requests!
  5. Eric Lawrence
    Admin
    Eric Lawrence avatar
    833 posts

    Posted 01 Oct 2014 Link to this post

    Whoa, you win. That is huge. :-)

    thanks, Eric Lawrence
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  6. Graeme
    Graeme avatar
    31 posts
    Member since:
    Aug 2014

    Posted 09 Oct 2014 in reply to Eric Lawrence Link to this post

    lol,

    Just to let you know; I've got Fiddler streaming requests and responses, only logging the headers and saving every 10,000 sessions to an archive before removing them from the UI. It's done approximately 1,800,000 sessions captures so far (having proxied about 8TB of bodies) and is behaving much better now than it did when it was holding all of them in memory.

    Thanks for your help in getting Fiddler churn through and log this amount of traffic :-)
Back to Top