jovotech / jovo-cli

đŸ›  Command Line Interface for the Jovo Framework: Makes voice experience deployment a breeze, including features like local development and staging.
https://www.jovo.tech/marketplace/jovo-cli
Apache License 2.0
57 stars 31 forks source link

"jovo run" should throw an error if selected default port is already being used #91

Open stuart-clark-45 opened 5 years ago

stuart-clark-45 commented 5 years ago

I'm submitting a...

Expected Behavior

jovo run should throw an error if selected default port is already being used

Current Behavior

everything appears to start up fine, so kinda looks like jovo just isn't working to the new user such as myself

Your Environment

Jovo CLI Version: 2.2.7

Jovo packages of current project: jovo-cms-i18next: 2.2.10 jovo-core: 2.2.9 jovo-db-filedb: 2.2.9 jovo-framework: 2.2.12 jovo-platform-alexa: 2.2.14 jovo-platform-dialogflow: 2.2.10 jovo-platform-googleassistant: 2.2.12 jovo-plugin-debugger: 2.2.10

ProductName: Mac OS X ProductVersion: 10.13.4 BuildVersion: 17E202

jankoenig commented 5 years ago

Hi @stuart-clark-45, thank you.

I typically get an error like this when I try to run the server when the port is already used in a different tab:

Error -----------------------------------------------------------------

  Code:
  EADDRINUSE

  Message:
  listen EADDRINUSE :::3000

  Stack:
  Error: listen EADDRINUSE :::3000
      at Object._errnoException (util.js:1022:11)
      at _exceptionWithHostPort (util.js:1044:20)
      at Server.setupListenHandle [as _listen2] (net.js:1367:14)
      at listenInCluster (net.js:1408:12)
      at Server.listen (net.js:1492:7)
      at Function.server.listen (/Users/jankoenig/Jovo/BundleTest/node_modules/jovo-framework/src/server.ts:17:21)
      at Object.<anonymous> (/Users/jankoenig/Jovo/BundleTest/src/index.js:15:13)
      at Module._compile (module.js:652:30)
      at Object.Module._extensions..js (module.js:663:10)
      at Module.load (module.js:565:32)

   ----------------------------------------------------------------------

I agree that it could have a more descriptive error message.

Are you seeing this error?

stuart-clark-45 commented 5 years ago

Hi @jankoenig

Thanks for the speedy response promising to see that this repo is so active

A useful bit of info i probably missed out is that the port clash was caused by a create-react-app running using yarn start

Once I run jovo run I get this:

This is your webhook url: https://webhook.jovo.cloud/7c1c1143-6295-48a2-a51b-b5a8e3d94520
Local server listening on port 3000!

To open Jovo Debugger in your browser, enter .

Then when I try to launch the app through alexa testing console I get the following output

Local server did not return a valid JSON response:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Error</title>
</head>
<body>
<pre>Cannot POST /webhook</pre>
</body>
</html>

Local server did not return a valid JSON response:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Error</title>
</head>
<body>
<pre>Cannot POST /webhook</pre>
</body>
</html>
aswetlow commented 5 years ago

Hey @stuart-clark-45

Based on your feedback, we've made some improvements. Please update your Jovo CLI and let me know what you think.

stuart-clark-45 commented 5 years ago

Hi @aswetlow,

I have updated my jovo-cli and just gave this a test afraid I see no change

rubenaeg commented 4 years ago

Closing this for now due to inactivity. If the issue still persists, feel free to reopen.

mig82 commented 3 years ago

I'm facing a similar issue. When the JOVO_PORT environment variable is set to anything other than 3000, then the requests coming from Alexa and Google Actions through the Jovo Webhook fail to find the server. And then I get this very cryptic message from Node:

Local server did not return a valid JSON response:
undefined

Notice that if I use --port to change the port —rather than relying on the JOVO_PORT environment variable— then the requests from the Jovo webhook do find my local server.

rubenaeg commented 3 years ago

Seems like this is a bug we didn't catch earlier. Setting JOVO_PORT directly does change the port for the Jovo instance, but not for the connected socket for the webhook. Will fix this with the new release for v3.