Would I have been better off with the service plan?

We just had to have one of the sump pumps in our basement replaced.  This is probably just bad luck, but you could make a good argument that I brought this on myself.  When Hurricane Irene passed through New England, I jinxed myself by offering on Facebook that if anyone needed to borrow our 16 gallon wet-vac, they were welcome to it.  The wet-vac had been sitting idle in our basement for over 5 years.  We bought it when we had some serious water leak issues, but in 2006, we brought in Boston Basement Technologies to put in water barriers and a second sump pump, and it had been dry ever since.

Naturally, about 15 minutes after posting the offer of the wet-vac, an alarm started going off in the basement.  It turned out that sump pump was not working, and the water level in the hole where the pump sits had risen high enough to trigger an alarm.  I brought the wet-vac out of retirement to pump out the hole and then worked with my father to see if we could fix it (my parents somehow seem to conveniently time their visits with major weather events like monster snow storms or hurricanes).  While we managed to clean out some sediment and try snaking the the discharge pipe, we couldn’t get it working.  The motor would hum, but no water would move.  Fortunately, Irene never hit Cambridge, MA directly, so we never had any rise to the point of leaking into the basement itself.  We pumped the water out of the hole with the wet-vac a couple of times, but I don’t think it was necessary.

A few weeks after the storm, I made an appointment for Boston Basement Technologies to come out and try to fix it.  While they do excellent work (that water barrier has been great), their service scheduling is pretty poor.  Back in 2006, they cancelled my installation appointments twice.  This time, sure enough, they called 1.5 hours into my two hour service window to say the tech had a personal issue and they needed to cancel.  They finally made it out this past Friday morning.  The tech checked the pipe, then determined that the sump pump had failed and would have to be replaced.  He had a new one in the truck.

How much for the sump pump?  $850.  For a sump pump?!  But the fact of the matter is that I needed the sump pump fixed and really did not have the time to start comparison shopping with other services.  So I agreed.

Then I asked about the warranty.  They told me the warranty was one year from the manufacturer, but as long as I had Boston Basement Technologies come out for an annual service visit, they would extend that warranty indefinitely. How much was the annual service visit, I asked?  $165.  I had no recollection of them telling me back in 2006 that an annual service appointment would extend the warranty indefinitely, but I’m sure they did.  As a general policy, I never purchase warranties or service contracts.  

My experience with most technology is that it either fails within the first few months or it lasts for years, probably beyond its usefulness.  Since warranties often run around 15-20% of the cost of the original item, self-insuring seems a much better deal to me.  I look at it this way: if a warranty costs 20% of the cost, and I buy warranties on five different products I buy, I effectively bought a 6th product up front.  If one of those five fail within the warranty period, I would get a replacement, but I effectively paid for it up front when you factor in all the warranties.  Or, I could wait until one of them actually fails and pay for a replacement myself then, costing me the same money in the end.  I would need for more than one out of every five products fail within that extended warranty period for it to become cost effective.  This hasn’t been my experience with most products, so I’d rather save my money.

The failed sump pump made me revisit my bias against warranty and service contracts in my head.  Let’s see: I bought the original sump pump in 2006, and this is five years later.  That would mean five service appointment visits (5 x $165) for a total of $825.  Since the new sump pump cost me $850, that was right about break even.  Had the sump pump failed last year, the service plan would have made more sense.  Had it failed next year, it would have undoubtably been better to skip it.  Even beyond the dollars, getting these annual service plans is a major hassle.  I have to arrange to be home from work on the day of the service appointment, and Boston Basement Technology’s track record for showing up at their service appointments has been less than stellar in my experience.  Once I factor in the time I have to spend dealing with them, it clearly is not worth it.

So I think I made the right decision.  I don’t think i will be getting annual service plans on this new sump pump either.  I’d rather keep the cash in my pocket as long as possible and avoid the scheduling headaches.  More importantly, I watched everything the tech did when he replaced the sump pump.  It doesn’t look that complicated, now that I see how the pipes fit together.  If it fails again, I think I might take a stab installing a much cheaper one from Home Depot myself now that I know what to do.
Posted in Uncategorized | Tagged , , | Leave a comment

Determine a linux server’s public ip address from the command line

We were recently setting up a linux server to integrate with a partner of ours, and we found that it was unable to connect to the remote server.  Our first suspicion was that our partner was blocking any ip addresses that were not in a white list, and a couple of quick emails confirmed this to be the case.  We just needed to tell them the public ip address of our computer and they would add it to the white list.

Since our firewalls and routers translate internal private ip addresses to a different set of public external ip addresses, knowing the machine’s internal ip address isn’t much help.  Requests to outside machines will see requests from our machine as a different, external ip address.  We needed to know what those external machines would see.

Our hosting engineer was able to look up what the machine’s external ip address would be mapped to, but since we were having the ip address registered in a partner’s system, I wanted to make 100% sure it was correct.  I wanted an answer from the horse’s mouth.  It’s not that I didn’t trust the engineer; I just wanted to see it for myself…. Well, okay, I admit it.  I can be a bit of a control freak at times.

On a Windows machine, checking a computer’s ip address is pretty straightforward.  Open a web browser, point it at www.whatismyipaddress.com, and look at what ip address it shows you.

On a linux machine, it’s not so simple.  There are none of these fancy icons or windows.  It’s just an SSH session in a terminal window.  Opening a web browser is not an option.  So how to check using nothing but the command line?

My friends at Akamai have set up a site that is useful for this situation called whatismyip.akamai.com.  It’s similar to public services such as www.whatismyipaddress.com, but it is completely stripped down.  All it does is send back your ip address.  No ads, no explanatory messages, no headers, just the ip address.

You can then combine this with wget in quiet mode to fetch the public ip address and display it on the command line as follows:


$ wget -q -O - http://whatismyip.akamai.com
74.125.93.104

There isn’t even a line break in the output file, so you can see how it would be easy to incorporate this into shell scripts and other utilities.  I would guess that this is why Akamai set up the site in the first place.  Very kind of them to allow the rest of us to use it.

Posted in Uncategorized | Tagged , , | 1 Comment

The Two Pocket Problem: How My iPhone Survived a Year Riding in a Pocket With My Keys

Put this in the category of “first world problems”.

Back in the days before cell phones, men generally had two things on them at all times: a wallet and a set of keys. Since most men don’t consider it socially acceptable to carry a purse, this mean carrying the wallet and keys in your pocket.  Most pairs of pants had two front pockets, so this worked out pretty well.

Once cell phones became popular, a problem arose. You now had to carry three items (wallet, keys and cellphone), but you still only had two pockets. Wallets tend to be fairly bulky and take up most of the space in a pocket, so if you put your keys in their with them, it gets very hard to fish out your keys without doing a little dance squeeze your hand in past your wallet. If you put your cell phone in with your wallet, they take up so much space that you look like you are carrying a softball around in your pants. The remaining choice is to put your cellphone in the same pocket as your keys. Back when I had an old clamshell style phone, I did this for a few years. It worked well enough, but the keys were constantly scraping against the phone. After about six months, the phone looked like it had been chewed by a dog. While not great for the aesthetics of the phone, it didn’t matter much since the clamshell style protected the vital areas of the screen and keys.

Now some people will point out that their are more than two pockets on pants – namely, the back pockets. Personally, I’ve never understood the idea of storing any of these items in your back pockets. Sitting on your phone doesn’t seem like a great way to keep it operating, and sitting on your keys is painful. I know that many people sit on their wallets, but this still doesn’t strike me as comfortable, and it seems like an open invitation for pickpockets.

When I upgraded to a smartphone (a Treo 650), I didn’t want to take the risk. If the screen got scratched, my several hundred dollar phone would be pretty much shot. I decided that since being a software engineer already put me firmly in the dork category, it wouldn’t be too bad to to start wearing my phone on my belt. I wan’t happy about it as a fashion decision, but I tried to compensate for it by finding nice, designer belt cases that would at least try to dress it up a little bit. For my Treo, I was quite happy with a french designed case from Covertec.

When I finally upgraded to an iPhone, I was never able to find a belt case as nice or as functional. The iPhone belt cases tended to be of much shoddier construction, and I found myself constantly wearing them out after a few months and searching for a new one. Their latches were not well designed, leading to unfortunate scratches when my phone slipped out while running across a street. And they were just ugly – it seemed like all of the smart designers were making slider or bumper cases.

After much unhappiness, one year ago I decided to take the plunge and put my iPhone back in my pocket with my keys. I figured that I would be replacing it in a year anyways when the new models came out (this was back when we expected another summer release for the iPhone 5), and if worst came to worst and I seriously damaged it, I would use it as an excuse for an early upgrade to an iPhone 4. I bought a slider case for the phone to protect the plastic parts, held my breath, and slipped the phone into my pocket with my keys.

Now, one year later, the iPhone itself is in pristine condition. There isn’t a single scratch on the glass:

Img_7850

The case itself looks like it has been chewed by a dog, but it just slides off and can be replaced for $20. The iPhone underneath is just fine.

Img_7855

While I have been careful to keep the glass of the phone front facing the pocket fabric, away from they keys, I cannot imagine that it has not periodically gone in backwards or been jumbled around when running after my kids. I can only conclude that the glass of the iPhone is indeed made of very strong stuff.

Based on this success, when the iPhone 5 comes out in a few months, I am definitely going to keep it in my pocket, with my keys. The phone survives just fine

And apologies to those of you who wear your phones on your belts and may find this post insulting :-).

Posted in Uncategorized | Tagged , | 1 Comment

HTML Shortcut: Dynamically populate a select list drop down when it is first clicked

e were recently making some modifications to a configuration options page.  The page was set up a type of table, where each record had its own row, and each column represented a different type of data that could be edited.  Some of the editable columns were dropdown lists which could have hundreds of different options to choose from.  If you had a large number of records, a massive chunk of the HTML content being shipped from the server was made up of the hundreds of identical options for each of these dropdowns. 

The saddest part is that we knew that most users would probably come in, adjust one or two settings, and leave all the rest of the drop downs untouched.  Without having to redesign the page, we wanted to find a way not have to ship so much needless data down to the client.

The solution seemed straightforward at first.  It was easy to write some javascript that would populate the dropdowns on the fly, so all we needed was to populate each dropdown with a single list item (the one the user should see selected).  When they would first click on it, the rest of the list would populate magically, and the user would never know the difference.  Onfocus, which fires when the user clicks or uses the keyboard to select the list seemed like the right event to use.


function InitList(selectList)
{
  // if the list is already populated, nothing left to do
  if (selectList.optons.length > 1) {
    return;
  }

  selectList.optons.length = 0;
  var currentSelection = selectList.value;

  // sample code for population a list of 10 elements
  for (var i = 0; i < 10; i++) {
      selectList.options[i] = new Option(i, i, false, i == currentSelection);
  }
}

<select onfocus="InitList(this);">
   <option value="5" selected>5</option>
</select>

Unfortunately we ran into a gotcha with IE, naturally.  We implemented the solution with an onfocus handler in the select list, which worked fine in Chrome and Firefox.  However, for IE, the dropdown wouldn’t open when you first clicked it.  You would have to click the dropdown a second time for it to start working.

The source of the problem turned out to be that when you change a select list in IE, it would automatically cancel the event that would trigger it to open.  What was happening was that the first click would populate the list but prevent the dropdown from appearing.  On the second click, the list was already populated and the javascript wouldn’t alter the elements, so the dropdown was able to proceed with its opening.

The solution for IE was to just use an onmousedown handler.  It fired before the actual opening of the dropdown was initiated, so IE didn’t feel the need to cancel the opening afterwards.

But, you still need the onfocus handler as well.  People using the keyboard to navigate the UI or a screen reader will never trigger an onmousedown event, so the javascript won’t fire.  A keyboard navigator would use the tab key to put the focus on the dropdown and then hit the spacebar to open it, and all they would see is the one item the list was originally populated with.

Fortunately, you can just use both.  The onmousedown will fire before the onfocus handler does, which will avoid problems with IE canceling the opening of the dropdown.  And the keyboard navigators will not have the problem of the dropdown opening getting canceled, since their focusing of the element was a separate action from opening it.


<select onfocus="InitList(this);" onmousedown="InitList(this);">
   <option value="5" selected>5</option>
</select>

 

Posted in Uncategorized | Tagged , , , | 2 Comments

Movie of Rafael’s First Year

Just as we did for Ayelet when she turned one, we have created a short (approximately 20 minute) movie with photos and videos that trace Rafael’s first year, starting from just before he was born until his first birthday.  Along the way, it covers many important milestones, including his birth, his brit milah, his first food, and his first steps.

To view the video full screen, click in the bottom right of the video on the button with the four arrows.

We wanted to focus the video specifically on Rafael, since Ayelet has a first year video that focuses just on her.  However, it has been an important year for the rest of the family too, so we have a second video that traces the year for the whole family.  There is a small amount of overlap with Rafael’s video, but by and large it contains different material.  It is also around 20 minutes.

If you’d like to see the video of Ayelet’s first year or the family video from last year, you can view them here.

Posted in Uncategorized | Leave a comment

If I had to do it all over again, which baby gear would I absolutely buy again?

Now that my younger child has turned one, we are find ourselves leaving the baby stage behind.  As all parents know, babies require an extraordinary amount of gear – clothing, strollers, sippy cups, bath toys, and thousands of other items that retailers are trying to convince people that they need.  Some of these items have been invaluable, while others didn’t quite live up to the promise of the manufacturers.

Having been through the baby stage twice now, I’ve found a handful of items that I found truly invaluable.  These are items that either so perfectly fit a need that I can’t imagine not having them or items that vastly exceeded their competitors.  I thought it would be worth taking a minute to highlight the best of the best.

Baby Gate
Once the babies become mobile, parents are faced with the need to keep them off the stairs or out of certain rooms.  There are a variety of baby gates on the market, but they generally fall into two major categories – fixed gates and roll-up gates.  A fixed gate is like a door that opens and closes, while a roll-up gate is kind of like a window shade that stretches across the the path.

I really find fixed gates a pain.  They tend to have complicated mechanisms that are difficult to negotiate one handed, and anyone with a kid knows that there is rarely more than one hand free (often you are holding the kid in the other hand).  The real problem with them is that they default to closed, and they are always getting in the way.  Even if the kid is asleep or out of the house, you find yourself constantly having to stop and open the gate every time you want to get by.

Roll-up gates take the reverse approach.  When you don’t need them closed, they are tucked up against the wall and practically invisible.  When you want them, they completely bar the path, and their flexible structure makes them easier to install than a fixed gate.  However, I have seen some pretty flimsy models out there that are prone to breaking or are difficult to open and close.

The gate that I love is the Retract-a-gate.  It’s not sold in stores, but I took a risk when I ordered it online and found it was perfect.  We have one at the top of the stairs which is opened and closed multiple times a day, and another at the bottom which is only closed when needed.

Retractable child safety gate from Retractagate.

First of all, it is very easy to use with just one hand.  It can also take a tremendous pounding; many people use is for dogs since it can withstand a blow of 200 pounds.  It’s one of the few gates that is rated for use at the top of the stairs, and it is has been incredibly durable. I can’t imagine going through childhood without it.

Temporal Thermometer
Taking a kid’s temperature is not a simple task.  Getting them to sit still to hold the thermometer in their mouth or under their arm long enough to get an accurate read is a challenge, and it’s impossible for a baby.  For the wee ones, you have to use a rectal thermometer.  I have never met a parent who views taking a baby’s thermometer rectally as “no big deal.”

The problem with a baby is that all they can do is cry, and you are often left trying to guess what is wrong.  There is a long list of possibilities (dirty diaper, teething, bumped head…), but many times you will find yourself wondering, “could she be sick?  Maybe she has a fever.”  The problem is that you have to take the baby’s temperature to answer this question.  This is such an ordeal that you are probably only willing to do this when you are at your wit’s end.  

Exergen Temporal Artery Thermometer with Silver Ion Antimicrobial Head

You slide it across your child’s forehead and down their temple, and it instantly gives you a temperature reading in a few seconds.  You need to briefly trick the child into holding still for a moment, and then you are done.  It transforms checking a temperature from an ordeal into an easy answer.

Some people have raised concerns about the accuracy of a temporal thermometer, but our pediatrician assured us that they work well, and they use them themselves in the office themselves.  And if you are still concerned, you can use it in two steps – take a temporal reading first, and if it comes out high, go for the rectal thermometer to double check.  I’ve never had to bother, personally.

Best of all, everyone in the family can use it, and we will have it for years.  I can’t say the same for the rectal thermometer.

Baby Seat
Parents with babies have to buy these special bath tubs to wash the kids in, and for the first few months, you can’t avoid it.  However, they are a real pain.  The baby kind of flops around in them and cries a lot, and you are constantly having to try to maneuver them around to get under them.  I find it takes two adults working together to use them.

As soon as they are able to hold their head up, I highly recommend a baby bath seat.

Screen_shot_2011-07-26_at_8

It keeps them from falling over into the water, but they are now upright.  This makes the bath much more fun for them, since they can start to interact with toys and other objects, and it is much easier to poke around and get them clean.  I was a little skeptical at first, but my mom got us one, and I was immediately converted.  Ours is from Juvenile Solutions, but there are others on the market that I am sure are perfectly fine.

High Chair
There are some very fancy, expensive high chairs out on the market.  I enjoy beautifully designed products, and I found myself attracted to the Svan chair, since it would go well with our decor and not scream “baby”.  We bought one for a few hundred dollars and used it with our first child, but with our second child it has been sitting in our basement.  It worked okay, sort of, but it was a pain to clean, and the tray never managed to stay level.

What do we use instead?  A $25 booster seat from Fisher Price, strapped to a sturdy folding chair.

Fisher-Price Healthy Care Booster Seat
No, it’s not pretty, but it is extremely practical.  First of all, it is super easy to clean.  Second, we can take it anywhere we go.  When we don’t need it, we just stick it in the closet.  My advice is save the hundreds of dollars and just use this instead.

If anyone would like our old svan highchair, you can have it.  Just come pick it up.

Stroller
I’d be remiss if I didn’t give a shout-out to our Phil and Ted’s stroller.  There are many fancy models out on the market, but I find the Phil and Ted’s inline style so incredibly useful that I can’t imagine going to any other.

The beauty of this stroller is that it holds two kids, but has the foot print of a single stroller.  We always knew we were going to have two kids, but it still made a great stroller when we had just one.  It was rugged and able to navigate our tough New England winters and uneven Cambridge sidewalks.

Now that we have two kids, it is truly wonderful.  You often have to negotiate tight spaces if you try to go into a store or weave through a busy sidewalk, and even with two kids, it has a very small footprint.  You can go anywhere.  Also, we don’t always know whether our older kid will want to walk or ride.  Since the stroller is still very compact, we don’t feel like dopes lugging around a double stroller when one kid isn’t riding in it.

Some people have concerns that the kid in the back gets a raw deal, since they can’t see ahead, but we really haven’t found it to be the case.  Our older daughter will sometimes insist on riding in the back, and they have a great view out the sides.  We’ve also found that while you lose some storage when both kids are in it, it’s very easy to hang a diaper bag and a booster seat off the sides.

I do have my quibbles with the Phil and Ted sport buggy, though.  The brake is difficult to engage, and there isn’t really a good cup holder for it.  However, the advantages of the double inline stroller have more than made up for these, and it seems that they have improved on the brake design in the newer models.
Posted in Uncategorized | Tagged , | Leave a comment

Choosing to post family movies online with Vimeo instead of YouTube

My son just turned one a few weeks ago, and we are finishing up work on a movie assembled from photos and video taken during his first year.  We put together a similar one for my daughter after her first year, and we liked having it so much that we make one of these video scrapbooks each year.  It’s a way of taking the hundreds of photos and videos of little moments that we capture over the course of the year and distilling them down to some of the most cherished moments that we’ll want to look back on in future years.

The past versions of these movies were burned on DVDs and sent out to a handful of family members, but as technology has evolved, I have found the physical disks to be cumbersome.  Periodically my daughter asks to see them, and I have to rumage through the cases of DVDs to find the one I want.  There are also more far flung family members who may have a passing interest in seeing the video, but the hastle of burning and mailing the DVD means that they will never see it.

We now live in world of online video, so posting these movies is the natural way to share with a broader audience and more easily access them in the future.  We usually use Google’s Picasa web for sharing photos and short video clips, but it doesn’t make good long term storage for these movies.  Picasa limits the amount of storage available, and they do not let you embed individual movie clips into other websites or let the person on the other end download them if they so choose.

Most people turn to YouTube for this kind of video sharing.  There is no fee for storage, sharing the videos is easy, and you can embed them in other websites.  However, you can’t upload a video longer than 15 minutes.  This is an improvement from their previous limit of 10 minutes, but it still falls short of the length of videos I am trying to upload, which run around 20 minutes or so.  Sure, you could break them up, but this makes for a lousy viewing experience.  Users are also constantly baraged with links to other videos.

I found another website that better meets my needs: Vimeo.  I’ve come across Vimeo clips on several other sites on the web, and after a little investigation I saw that it was a good fit.  There is no limit to the length of the movie you can upload, and there is no limit on the storage.  What they do limit is the amount you can upload for free on a weekly basis (500 MB).  My 20 minute videos clock in at a little under 300 MB, so this is adequate for what I want to do, and a $10 a month ($60 a year) ups the weekly limit to 5 GB and allows for uploading HD.

Vimeo targets more towards a professional crowd than the YouTube, which seems more focused on getting a viral hit.  It gives much more control about how you distribute the content, and it doesn’t automatically push more videos at the user.

Creating an account took just a few minutes, and I was immediately able to upload the video of my daughter’s first year.  WIthin a half hour after that, it wa processed by Vimeo’s servers and ready for viewing and embedding:

Ayelet’s First Year from Jeremy Rothman-Shore on Vimeo.

That original video was done on a PC using a product from Wondershare called DVD Slideshow Builder.  It was my first attempt to build a video like this, and the tool was a little crude.  It was missing many key features like audio ducking (dropping the background music level so you could hear voices in a video clip) and had limited photo options.

When we upgraded to a Mac, I was ushred into the world of iMovie and its far more sophisticated editing studio, configuration options, and Ken Burns effects (the gradual pan/zoom effect on photos, which gives the stills some movement).  Our follow up video which covers the period from after my daughter’s first birthday up to the birth of my son was much more polished.  I promptly shelled out the $10 for a month of Vimeo Plus so that I didn’t have to wait until next week to upload it:

The Rothman-Shores, 2009-2010 from Jeremy Rothman-Shore on Vimeo.

My son’s first year video is almost done, and we are also going to create a second video this year that chronicles the adventures of the rest of the Rothman-Shores.  Both my wife and I are younger children, and we didn’t want our son to get short changed by not having his own video.  In future years we will go back to one video per year, at least until our kids no longer have the patience to let us photograph them anymore.

I don’t expect them to be of much interest to anyone outside of family, and I will still burn DVDs for the closest family members who don’t watch much web video.  But I like the fact that I can now access the movies from any computer anywhere, without the clutter and 15 minute chunking of YouTube.

Posted in Uncategorized | Tagged , , | Leave a comment

Map of the world’s submarine data cables highlight challenges of routing internet traffic

I came across a very interesting site today – www.cablemap.info.  It’s an overlay of the world’s submarine data transmission cables on top of google maps, allowing you to see how the world interconnects.  It appears to be the work of one person, Greg Mahlknecht (@thewomble_za) of South Africa.

Looking at the map highlights a number of interesting issues.  Take Australia, for example:

Image001

Someone had told me years ago that the Western and Eastern halves of Australia don’t actually connect, and you can see it is true from this map.  The undersea cables that connect to Western Australia run out through Indonesia to Singapore, and from there you would have to go through the Philippines or Hong Kong to get to Guam before you could find a connection back to Sydney and Eastern Australia.  It is possible that there are overland cables connecting the continent, which don’t seem to generally be shown on the maps, but from what I know of Australia’s terrain, I wouldn’t be surprised if there weren’t any.

Another interesting issue is I see an explanation for some of the routing quirks I have seen when troubleshooting Akamai routing.  I often have to deal with clients who have DNS misconfigurations that cause problems for Akamai acceleration, and in one case I had a client who was accessing the Internet in Sydney, Australia, but resolving DNS in Singapore.  What really surprised me at the time was that the route between the client and the edge server in Singapore went through Los Angeles!

As I look at the map now, I can see why this might occur:

Image002

While there are routes that take a user through Guam and/or Hawaii, most of the cables in the Pacific link directly between West Coast of the United States and the Japan region.  While shorter paths may exist, the actual path is dependent on peering relationships between different providers.  There are many more paths that would potentially run across the full length of the pacific, and we know that BGP does not look at performance as its main metric for routing decisions.

There is a lot of interesting detail looking at other parts of the world.  If you want to get to Asia, you basically have to either route through India or Africa.  And the Middle East seems to depend mostly on connections that run from France.

Definitely worth checking out the site!

Posted in Uncategorized | Tagged , , , , | Leave a comment

Debugging: Use Fiddler and WebProxy to debug HttpWebRequest / HttpWebResponse issues in ASP.NET

We recently found ourselves debugging code that was making web requests to another server.  If we hit the server manually in a web browser, it worked fine, but when we ran it through the code simulating the request using HttpWebRequest, we weren’t getting the responses we expected.

When you are working with a browser, you can just use a tool like HttpWatch or Fiddler to snoop on the requests the browser is making and what the server sends back.  However, when you are trying to debug code, there is no magic button to press to snoop on the requests and responses being generated.

Fortunately, it turns out to have HttpWebRequest use Fiddler as a proxy.  When set up properly, all of your outgoing requests from the server code will route through Fiddler (which can even be running on a separate box somewhere) before being sent up to the server.  This allows you to inspect the requests and response and debug much more quickly.

The first step is to download and install Fiddler.  Once you have it running, Then, go to Tools -> Fiddler Options, and choose the Connections tab.  Check what is set for the “Fiddler listens on port” and change it if necessary.

Image001

If you are debugging an HttpWebRequest made on your local machine, you are all set from the Fiddler side.  However, if you are running Fiddler on one machine and the code on another, you’ll need to make sure that whatever port Fiddler is set to use is open on your machine’s firewall.

The next step is to modify your code to use Fiddler as a proxy.  HttpWebRequest supports an object called a web proxy.  All you need to do is instantiate one that points to your Fiddler instance and attach it to the web request:


HttpWebRequest myRequest = new (HttpWebRequest) WebRequest.Create("http://someserver/somepage");
myRequest.Method = "POST";

WebProxy myProxy = new WebProxy("http://mymachinename:8888");
myRequest.Proxy = myProxy;

HttpWebResponse myResponse = (HttpWebResponse) myRequest.GetResponse();

Now, when you execute the the code above, instead of sending requests directly to the intended host (“someserver” in the example above), it will send them to the Fiddler proxy running elsewhere (on “mymachinename” in the example above).  It will proxy them on to the intended host, but you can now inspect the requests and responses directly without having to step through a debugger or log data.

UPDATED:

As @duncansmart pointed out in the comments, that can be accomplished without a code change at all.  Just modify the web.config to specify a proxy, and it will start working immediately.  Very useful if you need to debug in another environment where you cannot push code modifications easily.


<system.net>
    <defaultProxy>
      <proxy
        usesystemdefault="true"
        proxyaddress="http://mymachinename:8888"
      />
    </defaultProxy>
</system.net>
 

Posted in Uncategorized | Tagged , , , | 3 Comments

Kids love super giant bubbles on a hot summer day

Everyone with kids knows the children are fascianted with bubbles.  You dip the wand into a bottle, and then with just a gentle blow from your lips, a colorful, shiny orb appears.  It gently floats in the air, until an exuberant toddler jumps up and gleefully pops it.  Fun, cheap, and easy entertainment.

So, what’s better than bubbles?  Super, giant, enormous bubbles, of course.

Image002

These giant bubbles are made with a special wand called the Bubble Thing.  It’s essentially just a plastic tube with a circular cloth strap.  You dip it in bubble solution, pull it gently through the air to make a giant bubble, and then slowly tighten the cloth strap so that the circle closes, releasing the bubble.

Image006

The wand isn’t enough, however.  If you tried to make a bubble that big with just plain old soap and water, it would collapse under its own weight in most conditions.  You have to add a small quantity of glycerin (a sugar substitute), which allows the bubbles to survive at much larger sizes.  The official instructions call for 16 cups of water, 1 cup of soap, and 2 tablespoons of glycerin, although I have found that a half batch or even a quarter batch will make plenty of solution.

When I was a kid, our local art museum featured them at their yearly art fair.  I hadn’t seen one since then, but it occurred to me that they might still make them.  A quick google search, and I found that they were indeed still being sold, and quite cheaply – just $10.  A couple of days later, it arrived in the mail, along with a package of glycerin.  I just needed to provide dishsoap and water.

We had a hot sunny 4th of July here in the Boston area this year, so I decided it was a good time to bring it out and take it for a spin.

Image011

Image012

Believe it or not, these bubbles are actually small.  If you have the right weather conditions (humidity helps), low wind, and a lot of practice, you can make truly enormous rings and tubes a dozen feet long.

Posted in Uncategorized | Tagged , | 1 Comment