serverless / platform-sdk

Serverless Platform SDK
Apache License 2.0
17 stars 7 forks source link

Explore free ports on users machine #67

Open pmuens opened 5 years ago

pmuens commented 5 years ago

Some users are facing issues with the Port we use for signing into the Platform here.

It would be nice if we could use a mechanism which explores open ports on the users machine to figure out which port to use for our sign in logic. AFAIK @plfx talked about such an npm package the other day.

medikoo commented 5 years ago

I also recently was receiving a quite dirty error, only because java for some reason took over 8000 port:

$ sls login
Serverless Enterprise: Logging you in via your default browser...
events.js:180
      throw er; // Unhandled 'error' event
      ^

Error: listen EADDRINUSE: address already in use :::8000
    at Server.setupListenHandle [as _listen2] (net.js:1228:14)
    at listenInCluster (net.js:1276:12)
    at Server.listen (net.js:1364:7)
    at Function.listen (/usr/local/lib/node_modules/express/lib/application.js:618:24)
    at listen (/Users/medikoo/npm-packages/@serverless/platform-sdk/src/login/login.js:32:22)
    at tryCatch (/usr/local/lib/node_modules/regenerator-runtime/runtime.js:45:40)
    at Generator.invoke [as _invoke] (/usr/local/lib/node_modules/regenerator-runtime/runtime.js:271:22)
    at Generator.prototype.<computed> [as next] (/usr/local/lib/node_modules/regenerator-runtime/runtime.js:97:21)
    at step (/Users/medikoo/npm-packages/@serverless/platform-sdk/dist/login/login.js:47:191)
    at /Users/medikoo/npm-packages/@serverless/platform-sdk/dist/login/login.js:47:437
    at new Promise (<anonymous>)
    at /Users/medikoo/npm-packages/@serverless/platform-sdk/dist/login/login.js:47:99
    at login (/Users/medikoo/npm-packages/@serverless/platform-sdk/src/login/login.js:19:7)
    at _callee$ (/Users/medikoo/npm-packages/@serverless/enterprise-plugin/src/lib/login.js:8:11)
    at tryCatch (/usr/local/lib/node_modules/regenerator-runtime/runtime.js:45:40)
    at Generator.invoke [as _invoke] (/usr/local/lib/node_modules/regenerator-runtime/runtime.js:271:22)
    at Generator.prototype.<computed> [as next] (/usr/local/lib/node_modules/regenerator-runtime/runtime.js:97:21)
    at asyncGeneratorStep (/Users/medikoo/npm-packages/@serverless/enterprise-plugin/dist/lib/login.js:10:103)
    at _next (/Users/medikoo/npm-packages/@serverless/enterprise-plugin/dist/lib/login.js:12:194)
    at /Users/medikoo/npm-packages/@serverless/enterprise-plugin/dist/lib/login.js:12:364
    at new Promise (<anonymous>)
    at /Users/medikoo/npm-packages/@serverless/enterprise-plugin/dist/lib/login.js:12:97
    at _ref (/Users/medikoo/npm-packages/@serverless/enterprise-plugin/dist/lib/login.js:62:15)
    at _default (/Users/medikoo/npm-packages/@serverless/enterprise-plugin/dist/lib/login.js:15:15)
    at _callee$ (/Users/medikoo/npm-packages/@serverless/enterprise-plugin/src/lib/plugin.js:268:17)
    at tryCatch (/usr/local/lib/node_modules/regenerator-runtime/runtime.js:45:40)
    at Generator.invoke [as _invoke] (/usr/local/lib/node_modules/regenerator-runtime/runtime.js:271:22)
    at Generator.prototype.<computed> [as next] (/usr/local/lib/node_modules/regenerator-runtime/runtime.js:97:21)
    at asyncGeneratorStep (/Users/medikoo/npm-packages/@serverless/enterprise-plugin/dist/lib/plugin.js:48:103)
    at _next (/Users/medikoo/npm-packages/@serverless/enterprise-plugin/dist/lib/plugin.js:50:194)
    at /Users/medikoo/npm-packages/@serverless/enterprise-plugin/dist/lib/plugin.js:50:364
    at new Promise (<anonymous>)
    at ServerlessEnterprisePlugin.<anonymous> (/Users/medikoo/npm-packages/@serverless/enterprise-plugin/dist/lib/plugin.js:50:97)
    at /Users/medikoo/npm-packages/serverless/lib/classes/PluginManager.js:464:55
    at tryCatcher (/usr/local/lib/node_modules/bluebird/js/release/util.js:16:23)
    at Object.gotValue (/usr/local/lib/node_modules/bluebird/js/release/reduce.js:157:18)
    at Object.gotAccum (/usr/local/lib/node_modules/bluebird/js/release/reduce.js:144:25)
    at Object.tryCatcher (/usr/local/lib/node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (/usr/local/lib/node_modules/bluebird/js/release/promise.js:517:31)
    at Promise._settlePromise (/usr/local/lib/node_modules/bluebird/js/release/promise.js:574:18)
    at Promise._settlePromiseCtx (/usr/local/lib/node_modules/bluebird/js/release/promise.js:611:10)
    at _drainQueueStep (/usr/local/lib/node_modules/bluebird/js/release/async.js:142:12)
    at _drainQueue (/usr/local/lib/node_modules/bluebird/js/release/async.js:131:9)
    at Async._drainQueues (/usr/local/lib/node_modules/bluebird/js/release/async.js:147:5)
    at Immediate.Async.drainQueues (/usr/local/lib/node_modules/bluebird/js/release/async.js:17:14)
    at processImmediate (internal/timers.js:439:21)
    at process.topLevelDomainCallback (domain.js:126:23)
Emitted 'error' event at:
    at emitErrorNT (net.js:1255:8)
    at processTicksAndRejections (internal/process/task_queues.js:77:11) {
  code: 'EADDRINUSE',
  errno: 'EADDRINUSE',
  syscall: 'listen',
  address: '::',
  port: 8000
}

It took me a while to figure out

garethmcc commented 5 years ago

It seems, from people who have spoken to me, that DynamoDB local often is set to port 8000 as well. So there is a real need for it.

MacRonin commented 5 years ago

Hmm, the DynamoDB-local might explain my error. I had recently started exploring the Serverless framework and had a basic learning environment setup (used dynamoDB) before upgrading to 1.48 and trying the enterprise dashboard. the code had worked before my update On OSX used Homebrew)

after the update I get the port 8000 in use error when trying to login

$ sls login Serverless: DOTENV: Loading environment variables from .env: Serverless: - SLS_DEBUG Serverless: Load command login Serverless: Load command logout Serverless: Load command generate-event Serverless: Load command test Serverless: Load command dashboard Serverless: Invoke login Serverless: Logging you in via your default browser... Error: listen EADDRINUSE: address already in use :::8000 at Server.setupListenHandle [as _listen2] (net.js:1228:14) at listenInCluster (net.js:1276:12) at Server.listen (net.js:1364:7) at Function.listen (/usr/local/Cellar/serverless/1.48.2/libexec/lib/node_modules/serverless/node_modules/express/lib/application.js:618:24) at listen

Your Environment Information --------------------------- Operating System: darwin Node Version: 12.6.0 Serverless Version: 1.48.2 Enterprise Plugin Version: 1.3.1 Platform SDK Version: 2.0.3

Update: Reading some other referenced threads. I wanted to mention one thing that seemed a bit out of place. The login request does reach my default browser (Safari) and end up on the Applications page