{"action":"created","issue":{"url":"https://api.github.com/repos/appium/appium/issues/5059","labels_url":"https://api.github.com/repos/appium/appium/issues/5059/labels{/name}","comments_url":"https://api.github.com/repos/appium/appium/issues/5059/comments","events_url":"https://api.github.com/repos/appium/appium/issues/5059/events","html_url":"https://github.com/appium/appium/issues/5059","id":73422125,"number":5059,"title":"When Appium Android Node runs more than 50 tests , tests are skipped","user":{"login":"ArchanaChalapalle","id":8217142,"avatar_url":"https://avatars.githubusercontent.com/u/8217142?v=3","gravatar_id":"","url":"https://api.github.com/users/ArchanaChalapalle","html_url":"https://github.com/ArchanaChalapalle","followers_url":"https://api.github.com/users/ArchanaChalapalle/followers","following_url":"https://api.github.com/users/ArchanaChalapalle/following{/other_user}","gists_url":"https://api.github.com/users/ArchanaChalapalle/gists{/gist_id}","starred_url":"https://api.github.com/users/ArchanaChalapalle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ArchanaChalapalle/subscriptions","organizations_url":"https://api.github.com/users/ArchanaChalapalle/orgs","repos_url":"https://api.github.com/users/ArchanaChalapalle/repos","events_url":"https://api.github.com/users/ArchanaChalapalle/events{/privacy}","received_events_url":"https://api.github.com/users/ArchanaChalapalle/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/appium/appium/labels/NeedsTriage","name":"NeedsTriage","color":"ededed"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":9,"created_at":"2015-05-05T20:26:52Z","updated_at":"2015-05-08T20:01:57Z","closed_at":null,"body":"When more than 50 tests are run continuously in a test suite , some tests are skipped. \r\nAll of a sudden , this error appears in betweeen the runs\r\norg.openqa.selenium.SessionNotCreatedException:\r\n A new session could not be created. (Original error: Did not get session redirect from Chromedriver) (WARNING: The server did not provide any stacktrace information)\r\n"},"comment":{"url":"https://api.github.com/repos/appium/appium/issues/comments/100342397","html_url":"https://github.com/appium/appium/issues/5059#issuecomment-100342397","issue_url":"https://api.github.com/repos/appium/appium/issues/5059","id":100342397,"user":{"login":"yaphatak","id":12143988,"avatar_url":"https://avatars.githubusercontent.com/u/12143988?v=3","gravatar_id":"","url":"https://api.github.com/users/yaphatak","html_url":"https://github.com/yaphatak","followers_url":"https://api.github.com/users/yaphatak/followers","following_url":"https://api.github.com/users/yaphatak/following{/other_user}","gists_url":"https://api.github.com/users/yaphatak/gists{/gist_id}","starred_url":"https://api.github.com/users/yaphatak/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yaphatak/subscriptions","organizations_url":"https://api.github.com/users/yaphatak/orgs","repos_url":"https://api.github.com/users/yaphatak/repos","events_url":"https://api.github.com/users/yaphatak/events{/privacy}","received_events_url":"https://api.github.com/users/yaphatak/received_events","type":"User","site_admin":false},"created_at":"2015-05-08T20:01:57Z","updated_at":"2015-05-08T20:01:57Z","body":"@jlipps : Its chromedriver issue. We run more than 3000  tests everyday and but we dont see failures anymore. Only code change that I did, i dont kill chromedriver per test session, we restart it only if we see failure during new session creation. Again I will try to send pull request soon but i have implementation with earlier chromdriver code (where you didnt seprate chromriver package in separate module)\r\nNote:internalChromeDriver.js is kinda of static \r\n\r\nChromedriver.prototype.proxyNewSession = function (data, cb) {\r\n  var maxRetries = 3;\r\n  var curRetry = 0;\r\n  var retryInt = 500;\r\n  var doProxy = function (alreadyRestarted) {\r\n    this.proxyTo('/wd/hub/session', 'POST', data, function (err, res, body) {\r\n      if (err) {\r\n\t  logger.info(\"Error after posting to chromedriver\" + err);\r\n        if (/ECONNREFUSED/.test(err.message) && curRetry < maxRetries) {\r\n          logger.info(\"Could not connect yet; retrying in ECONNREFUSED\");\r\n          internalChromeDriver.start(this.chromedriver, this.proxyPort, function(){\t\r\n                curRetry++;\r\n                setTimeout(doProxy, retryInt);\r\n            }.bind(this));\r\n            return;\r\n        } else if (/ECONNRESET/.test(err.message) && curRetry < maxRetries) {\r\n            logger.info(\"Could not connect yet; retrying ECONNRESET\");\r\n\t\t\tinternalChromeDriver.start(this.chromedriver, this.proxyPort, function(){\t\r\n                curRetry++;\r\n                setTimeout(doProxy, retryInt);\r\n            }.bind(this));\r\n            return;\r\n        }\r\n        return cb(err);\r\n      }\r\n\r\n      // first checking if we get a well formed success response\r\n      this.chromeSessionId = null;\r\n      try {\r\n        if (body.status === 0 && body.sessionId) {\r\n          logger.info(\"Successfully started chrome session\");\r\n          this.chromeSessionId = body.sessionId;\r\n        }\r\n      } catch (ignore) {}\r\n      if (this.chromeSessionId) return cb(null, this.chromeSessionId);\r\n\r\n      // then check redirect success case\r\n      try {\r\n        if (res.statusCode === 303 && res.headers.location) {\r\n          logger.info(\"Successfully started chrome session\");\r\n          var loc = res.headers.location;\r\n          this.chromeSessionId = /\\/([^\\/]+)$/.exec(loc)[1];\r\n        }\r\n      } catch (ignore) {}\r\n      if (this.chromeSessionId) return cb(null, this.chromeSessionId);\r\n\r\n      // those are error cases\r\n\t  if (typeof body !== \"undefined\" &&\r\n                 typeof body.value !== \"undefined\" &&\r\n                 typeof body.value.message !== \"undefined\" &&\r\n\t\t\t\t body.value.message.indexOf(\"Adb command timed out\") !== -1){\r\n\t\t logger.info(\"Rebooting Device\");\t\r\n\t\t this.adb.exec(\"reboot\", function (err, stdout) {\r\n\t\t\tif (err) \r\n\t\t\tlogger.error(\"Device rebooting failed.\"); \r\n\t\t });\t\t\t \r\n         cb(new Error(body.value.message));\t \r\n\t  }\r\n      else if (typeof body !== \"undefined\" &&\r\n                 typeof body.value !== \"undefined\" &&\r\n\t\t\t\t\ttypeof body.value.message !== \"undefined\") {\r\n          logger.error(\"Chromedriver had trouble \" + body.value.message);\r\n          logger.error(\"Restarting chromedriver\");\r\n          internalChromeDriver.start(this.Chromedriver, this.proxyPort, function () {\r\n              curRetry++;\r\n              setTimeout(doProxy, retryInt);                \r\n          }.bind(this));\r\n      }\r\n\t  else {\r\n        logger.error(\"Chromedriver create session did not work. Status was \" +\r\n                     res.statusCode + \" and body was \" +\r\n                     JSON.stringify(body));\r\n           this.killOldChromedrivers(function () {\r\n               cb(new Error(\"Did not get session redirect from Chromedriver\"));\r\n          }.bind(this));\r\n      }\r\n    }.bind(this));\r\n  }.bind(this);\r\n\r\n  doProxy();\r\n};\r\n\r\nChromedriver.prototype.deleteSession = function (cb) {\r\n  logger.debug(\"Deleting Chrome session\");\r\n  var url = '/wd/hub/session/' + this.chromeSessionId;\r\n  this.proxyTo(url, 'DELETE', null, function (err, res) {\r\n    if (err) return cb(err);\r\n    if (res.statusCode !== 200) return cb(new Error(\"Status was not 200\"));\r\n    cb();\r\n  }.bind(this));\r\n};\r\n\r\nChromedriver.prototype.stop = function (cb) {\r\n  logger.debug('Killing chromedriver');\r\n  this.exitCb = cb;\r\n // this.proc.kill();\r\n\t// if (this.exitCb !== null) {\r\n      // return this.exitCb();\r\n    // }\r\n\tthis.deleteSession(function(){\r\n\t\tthis.onDie();\r\n\t\tif (this.exitCb !== null) {\r\n\t\t\treturn this.exitCb();\r\n\t\t}\r\n\t}.bind(this));\r\n   // this.onDie();\r\n};\r\n"}}