This is a migrated thread and some comments may be shown as answers.

Number of selected items does not match actual selected items

5 Answers 154 Views
Fiddler Classic
This is a migrated thread and some comments may be shown as answers.
Graeme
Top achievements
Rank 1
Graeme asked on 30 Sep 2014, 02:20 PM
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?

5 Answers, 1 is accepted

Sort by
0
Eric Lawrence
Telerik team
answered on 30 Sep 2014, 04:24 PM
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.

0
Graeme
Top achievements
Rank 1
answered on 01 Oct 2014, 01:45 PM
Yep, that works better.

Thanks!
0
Graeme
Top achievements
Rank 1
answered on 01 Oct 2014, 01:46 PM
...oh and a huge amount is somewhere in the region of 3,000,000 requests!
0
Eric Lawrence
Telerik team
answered on 01 Oct 2014, 10:06 PM
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.

 
0
Graeme
Top achievements
Rank 1
answered on 09 Oct 2014, 02:34 PM
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 :-)
Tags
Fiddler Classic
Asked by
Graeme
Top achievements
Rank 1
Answers by
Eric Lawrence
Telerik team
Graeme
Top achievements
Rank 1
Share this question
or