Use contexts in fortune bundle clients.

Fixes veyron/release-issues/issues/1509

Change-Id: I8a6d295cd8d4fdf3212d3e5ab8578db359b66d3c
diff --git a/client/bundles/fortune/src/client/client.go b/client/bundles/fortune/src/client/client.go
index 7ccb322..d621bd1 100644
--- a/client/bundles/fortune/src/client/client.go
+++ b/client/bundles/fortune/src/client/client.go
@@ -12,6 +12,7 @@
 	"time"
 
 	"v.io/v23"
+	"v.io/v23/context"
 	_ "v.io/x/ref/profiles"
 
 	"fortune"
@@ -31,8 +32,11 @@
 	fmt.Printf("Issuing request\n")
 	var fortune string
 	for {
+		// Create a context that will timeout in 1 second.
+		timeoutCtx, _ := context.WithTimeout(ctx, 1*time.Second)
+
 		var err error
-		if fortune, err = stub.GetRandomFortune(ctx); err == nil {
+		if fortune, err = stub.GetRandomFortune(timeoutCtx); err == nil {
 			break
 		}
 		fmt.Printf("%v\nRetrying in 100ms...\n", err)
diff --git a/client/bundles/fortune/src/client/client.js b/client/bundles/fortune/src/client/client.js
index 075e650..edb1d78 100644
--- a/client/bundles/fortune/src/client/client.js
+++ b/client/bundles/fortune/src/client/client.js
@@ -31,11 +31,12 @@
 });
 
 function retryBindTo(ctx, client, cb) {
-  client.bindTo(ctx, 'bakery/cookie/fortune', function(err, fortuneService) {
+  var timeoutCtx = ctx.withTimeout(1000);
+  client.bindTo(timeoutCtx, 'bakery/cookie/fortune', function(err, fortuneService) {
     if (err) {
       console.error(err + '\nRetrying in 100ms...');
       return setTimeout(function() {
-        retryBindTo(ctx, client, cb);
+        retryBindTo(timeoutCtx, client, cb);
       }, 100);
     }