Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error - False port in use #1

Closed
a4sh3u opened this issue Nov 19, 2018 · 9 comments
Closed

Error - False port in use #1

a4sh3u opened this issue Nov 19, 2018 · 9 comments
Assignees

Comments

@a4sh3u
Copy link

a4sh3u commented Nov 19, 2018

Hi,
I'm trying to run this app in docker and get the port in use error with any port I use. Please help
Here is my Dockerfile:

FROM node:latest

ENV DEBIAN_FRONTEND noninteractive
ENV HUBOT_NAME myhubot
ENV HUBOT_OWNER none
ENV HUBOT_DESCRIPTION Hubot
ENV EXTERNAL_SCRIPTS "hubot-help,hubot-pugme"

RUN useradd hubot -m

RUN npm install -g hubot coffeescript yo generator-hubot && \
    npm install --save hubot-google-hangouts-chat

USER hubot

WORKDIR /home/hubot

RUN yo hubot --owner="${HUBOT_OWNER}" --name="${HUBOT_NAME}" --description="${HUBOT_DESCRIPTION}" --defaults && sed -i /heroku/d ./external-scripts.json && sed -i /redis-brain/d ./external-scripts.json && npm install hubot-scripts --save

EXPOSE 8080

VOLUME ["/home/hubot/scripts"]

CMD node -e "console.log(JSON.stringify('$EXTERNAL_SCRIPTS'.split(',')))" > external-scripts.json && \
    npm install $(node -e "console.log('$EXTERNAL_SCRIPTS'.split(',').join(' '))") && \
    bin/hubot -n $HUBOT_NAME --adapter google-hangouts-chat

And here is the error I get while trying to the run the image created from above:

  • hubot-pugme@0.1.1
  • hubot-help@1.0.1
    updated 2 packages and audited 178 packages in 1.283s
    found 0 vulnerabilities

audited 178 packages in 1.277s
found 0 vulnerabilities

body-parser deprecated undefined extended: provide extended option node_modules/hubot/src/robot.js:445:21
[Mon Nov 19 2018 16:26:45 GMT+0000 (Coordinated Universal Time)] INFO Hangouts Chat adapter initialized successfully
[Mon Nov 19 2018 16:26:45 GMT+0000 (Coordinated Universal Time)] WARNING Loading scripts from hubot-scripts.json is deprecated and will be removed in 3.0 (github/hubot-scripts#1113) in favor of packages for each script.

Your hubot-scripts.json is empty, so you just need to remove it.
[Mon Nov 19 2018 16:26:45 GMT+0000 (Coordinated Universal Time)] INFO Server is running in port - 8080
[Mon Nov 19 2018 16:26:45 GMT+0000 (Coordinated Universal Time)] ERROR Error: listen EADDRINUSE: address already in use 0.0.0.0:8080
at Server.setupListenHandle [as _listen2] (net.js:1290:14)
at listenInCluster (net.js:1338:12)
at doListen (net.js:1469:7)
at process.internalTickCallback (internal/process/next_tick.js:72:19)

@julbrs
Copy link

julbrs commented Nov 29, 2018

I have quite the same issue... Following the instructions here, running bin/hubot -a google-hangouts-chat in my project I can then see in the logs:

[Thu Nov 29 2018 15:16:26 GMT-0500 (EST)] INFO Server is running in port - 8080
[Thu Nov 29 2018 15:16:26 GMT-0500 (EST)] ERROR Error: listen EADDRINUSE 0.0.0.0:8080
  at Server.setupListenHandle [as _listen2] (net.js:1360:14)
  at listenInCluster (net.js:1401:12)
  at doListen (net.js:1510:7)
  at _combinedTickCallback (internal/process/next_tick.js:142:11)
  at process._tickCallback (internal/process/next_tick.js:181:9)

The only thing changed is the remove of the engines section in package.json because it was refering to something like node 0.10.

Seems that 2 processes are trying to start. Digging.

@grant
Copy link

grant commented Nov 29, 2018

@jichu4n FYI

@julbrs
Copy link

julbrs commented Nov 29, 2018

OK just to confirm following that:

mkdir myhubot
cd myhubot
yo hubot
# answer google-hangouts-chat for bot adapter
bin/hubot -a google-hangouts-chat

and my output:

[Thu Nov 29 2018 16:18:16 GMT-0500 (EST)] ERROR Error: listen EADDRINUSE 0.0.0.0:8080
  at Server.setupListenHandle [as _listen2] (net.js:1360:14)
  at listenInCluster (net.js:1401:12)
  at doListen (net.js:1510:7)
  at _combinedTickCallback (internal/process/next_tick.js:142:11)
  at process._tickCallback (internal/process/next_tick.js:181:9)

My config

npm 6.4.1
node 8.12.0

the package.json:

{
  "name": "myhubot",
  "version": "0.0.0",
  "private": true,
  "author": "xxxxxxxxxxxxxxxxxxxxxxxx",
  "description": "A simple helpful robot for your Company",
  "dependencies": {
    "hubot": "^3.1.1",
    "hubot-diagnostics": "^1.0.0",
    "hubot-google-hangouts-chat": "^1.0.3",
    "hubot-google-images": "^0.2.7",
    "hubot-google-translate": "^0.2.1",
    "hubot-help": "^1.0.1",
    "hubot-heroku-keepalive": "^1.0.3",
    "hubot-maps": "0.0.3",
    "hubot-pugme": "^0.1.1",
    "hubot-redis-brain": "^1.0.0",
    "hubot-rules": "^1.0.0",
    "hubot-scripts": "^2.17.2",
    "hubot-shipit": "^0.2.1"
  },
  "engines": {
    "node": "0.10.x"
  }
}

@julbrs
Copy link

julbrs commented Nov 30, 2018

Testing with the HTTP server start commented...

julbrs@39cfb79

Why the adapater is starting a second HTTP server ?

@julbrs
Copy link

julbrs commented Nov 30, 2018

OK disabling the existing HTTP server is not a good idea. But here is a commit to re-use the existing HTTP server built-in and just listen a particular url via robot.router.listen:

julbrs@d75850c

Can I push the 2 commits as a PR ?

If you want to test my fork this just edit your package.json file and replace existing hubot-google-hangouts-chat row by:

"hubot-google-hangouts-chat": "bobman38/hubot-google-hangouts-chat",

Then run npm install

@kumarse
Copy link

kumarse commented Dec 5, 2018

@a4sh3u Can you try setting EXPRESS_PORT and PORT environment variables explicitly as shown in https://developers.google.com/hangouts/chat/how-tos/integrate-hubot#deploy_in_appengine

As @bobman38 mentioned, there are two express servers being initialized today - an express server that comes built-in with Hubot and one that is spinned up by this adapter. If the EXPRESS_PORT and PORT environment variables are not explicitly set, both try to listen to the same port 8080 and hence clash.

This is not ideal. We will look into fixing this.

@kumarse
Copy link

kumarse commented Dec 5, 2018

@bobman38 Let me make sure using the hubot built-in express server is OK and get back to you on the PR.

@a4sh3u
Copy link
Author

a4sh3u commented Dec 7, 2018

@kumarse thanks. that works

@dgliu-f82
Copy link
Contributor

To disable the default HTTP daemon, just pass -d to bin/hubot e.g.
bin/hubot -d -a google-hangouts-chat

The developer doc has been updated:
https://developers.google.com/hangouts/chat/how-tos/integrate-hubot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants