diff --git a/ndb/src/mgmapi/ndb_logevent.cpp b/ndb/src/mgmapi/ndb_logevent.cpp
index 2817abcfdbbaf33b1c8a09b41e907a90c51d8342..4188929c952324448deae1cc0b8d2139fdae49f4 100644
--- a/ndb/src/mgmapi/ndb_logevent.cpp
+++ b/ndb/src/mgmapi/ndb_logevent.cpp
@@ -369,6 +369,9 @@ int ndb_logevent_get_next(const NdbLogEventHandle h,
   Properties p;
   char buf[256];
 
+  struct timeval start_time;
+  gettimeofday(&start_time, 0);
+
   /* header */
   while (1) {
     if (in.gets(buf,sizeof(buf)) == 0)
@@ -383,7 +386,23 @@ int ndb_logevent_get_next(const NdbLogEventHandle h,
     }
     if ( strcmp("log event reply\n", buf) == 0 )
       break;
-    ndbout_c("skipped: %s", buf);
+
+    if ( strcmp("<PING>\n", buf) )
+      ndbout_c("skipped: %s", buf);
+
+    struct timeval now;
+    gettimeofday(&now, 0);
+    unsigned elapsed_ms=
+      (now.tv_sec-start_time.tv_sec)*1000 +
+      (now.tv_usec-start_time.tv_usec)/1000;
+
+    if (elapsed_ms >= timeout_in_milliseconds)
+    {
+      // timed out
+      return 0;
+    }
+
+    new (&in) SocketInputStream(h->socket, timeout_in_milliseconds-elapsed_ms);
   }
 
   /* read name-value pairs into properties object */