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

Bind interface is chosen not properly #304

Closed
michael-l-a opened this issue Jun 18, 2018 · 4 comments
Closed

Bind interface is chosen not properly #304

michael-l-a opened this issue Jun 18, 2018 · 4 comments

Comments

@michael-l-a
Copy link

When process is starting is should bind to interface : port.
Port can be specified via environmental variable BOTPRESS_PORT.
But interface doesn't have BOTPRESS_HOST option to be set. Thus Botpress decides himself what interface to choose.
If you start Botpress on local machine it will bind to host 0.0.0.0 (all interfaces) but will print that it binded to localhost.
But when you start it remotely in Kubernetes it binds to interface of SVC but not 0.0.0.0 (not even own host).

So we have two problems here:

  • we can't specify interface via env variable
  • self behaviour is unpredictable

How it looks in the system.
This is IP of the host where Botpress is running. Thus I expect it to bind either to 0.0.0.0 or 127.0.0.1 or 10.42.110.150:

$ kubectl get pod -o wide
NAME                        READY     STATUS    RESTARTS   AGE       IP              NODE
botpress-6c9f9c59f5-f8sh4   1/1       Running   762        2d        10.42.110.150   node1

Here is service address which is load balancer in front of host of Botpress:

$ kubectl get svc -o wide
NAME         TYPE           CLUSTER-IP      EXTERNAL-IP       PORT(S)          AGE       SELECTOR
botpress     LoadBalancer   10.43.210.138   192.168.177.202   3000:30404/TCP   2d        component=botpress

But all of a sudden Botpress is trying to bind to foreign address 10.43.210.138 instead of own:

$ kubectl logs -f botpress-6c9f9c59f5-f8sh4

Globally installed Botpress version: 10.17.3


[botpress] 	 There are 6 modules installed:
[botpress] 	 >> @botpress/audience
[botpress] 	 >> @botpress/builtins
[botpress] 	 >> @botpress/nlu
[botpress] 	 >> @botpress/skill-choice
[botpress] 	 >> @botpress/hitl
[botpress] 	 >> @botpress/channel-web

yarn run v1.6.0
$ botpress start
17:31:20 - info: Creating data directory: /usr/share/botpress/.data
17:31:20 - info: Starting botpress version 10.17.3
17:31:27 - info: [Ghost Content Manager] (transparent) Initialized
17:31:27 - debug: [Ghost Content Manager] (transparent) Added root folder generated/media, doing nothing.
17:31:27 - debug: [Ghost Content Manager] (transparent) Added root folder generated/flows, doing nothing.
17:31:27 - info: [Skills] Initiated
17:31:27 - info: Loaded @botpress/audience, version 10.17.3
17:31:28 - debug: [Ghost Content Manager] (transparent) Added root folder generated/intents, doing nothing.
17:31:28 - debug: [Ghost Content Manager] (transparent) Added root folder generated/entities, doing nothing.
17:31:28 - info: Loaded @botpress/nlu, version 10.17.3
17:31:28 - info: Configuration for module "@botpress/skill-choice" has been created at /usr/share/botpress/config/skill-choice.json
17:31:28 - info: Loaded @botpress/skill-choice, version 10.17.3
17:31:28 - info: Loaded @botpress/hitl, version 10.17.3
17:31:28 - verbose: [Renderers] Enabled for webchat.
17:31:28 - info: Loaded @botpress/channel-web, version 10.17.3
17:31:28 - info: Loaded 5 modules
17:31:28 - info: [Skills] Loaded 1 skills
17:31:28 - debug: [Ghost Content Manager] (transparent) Added root folder generated/content, doing nothing.
17:31:28 - debug: Loading middleware: rendering.instrumentation
17:31:28 - debug: Loading middleware: hitl.captureInMessages
17:31:28 - debug: Loading middleware: nlu.incoming
17:31:28 - debug: Loading middleware: hear
17:31:28 - debug: Loading middleware: hitl.captureOutMessages
17:31:28 - debug: Loading middleware: webchat.sendMessages
17:31:28 - debug: Loading middleware: fallback
17:31:28 - debug: Loading data for builtin_text from builtin_text.json
17:31:28 - info: Read 7 item(s) from builtin_text.json
17:31:28 - error: [FATAL] An unhandled exception occurred in your bot 
{ message: 'bind EACCES tcp://10.43.210.138:3000',
  stack: 'Error: bind EACCES tcp://10.43.210.138:3000\n    at Object._errnoException (util.js:1024:11)\n    at _exceptionWithHostPort (util.js:1046:20)\n    at listenOnMasterHandle (net.js:1411:16)\n    at rr (internal/cluster/child.js:111:12)\n    at Worker.send (internal/cluster/child.js:78:7)\n    at process.onInternalMessage (internal/cluster/utils.js:42:8)\n    at emitTwo (events.js:131:20)\n    at process.emit (events.js:214:7)\n    at process.emit (/usr/share/botpress/node_modules/source-map-support/source-map-support.js:439:21)\n    at emit (internal/child_process.js:772:12)\n    at _combinedTickCallback (internal/process/next_tick.js:141:11)\n    at process._tickDomainCallback (internal/process/next_tick.js:218:9)',
  code: 'EACCES',
  errno: 'EACCES',
  syscall: 'bind',
  address: 'tcp://10.43.210.138:3000',
  port: -1 }
17:31:28 - error: Error: bind EACCES tcp://10.43.210.138:3000
    at Object._errnoException (util.js:1024:11)
    at _exceptionWithHostPort (util.js:1046:20)
    at listenOnMasterHandle (net.js:1411:16)
    at rr (internal/cluster/child.js:111:12)
    at Worker.send (internal/cluster/child.js:78:7)
    at process.onInternalMessage (internal/cluster/utils.js:42:8)
    at emitTwo (events.js:131:20)
    at process.emit (events.js:214:7)
    at process.emit (/usr/share/botpress/node_modules/source-map-support/source-map-support.js:439:21)
    at emit (internal/child_process.js:772:12)
    at _combinedTickCallback (internal/process/next_tick.js:141:11)
    at process._tickDomainCallback (internal/process/next_tick.js:218:9)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
@epaminond
Copy link

epaminond commented Jun 18, 2018

@m-abramovich , I've prepared a PR botpress/botpress#645 adding ability to specify hostname.

As for unpredictable self-behavior, it may come from node's http package. We are using regular server.listen function that binds server to some default interface if hostname isn't provided.

@michael-l-a
Copy link
Author

michael-l-a commented Jun 18, 2018

@epaminond, Understood, thank you.

slvnperron referenced this issue in botpress/botpress Jun 19, 2018
feat(core): hostname bot listens to can be customized (resolve #644)
@michael-l-a
Copy link
Author

Still it appears (not 100% of time)

# kubectl describe deploy botpress | grep -B 8 BOTPRESS_HOSTNAME

Pod Template:
  Labels:  component=botpress
  Containers:
   botpress:
    Image:      botpress/server:latest
    Port:       3000/TCP
    Host Port:  0/TCP
    Environment:
      BOTPRESS_HOSTNAME:  0.0.0.0
# kubectl logs -f botpress-6fcb4c57bd-znwnh 

Globally installed Botpress version: 10.20.1

[botpress] 	 There are 6 modules installed:
[botpress] 	 >> @botpress/audience
[botpress] 	 >> @botpress/builtins
[botpress] 	 >> @botpress/nlu
[botpress] 	 >> @botpress/skill-choice
[botpress] 	 >> @botpress/hitl
[botpress] 	 >> @botpress/channel-web

yarn run v1.6.0
$ botpress start
21:46:36 - info: Creating data directory: /usr/share/botpress/.data
21:46:36 - info: Starting botpress version 10.20.1
21:46:37 - info: [Ghost Content Manager] (transparent) Initialized
21:46:37 - debug: [Ghost Content Manager] (transparent) Added root folder generated/media, doing nothing.
21:46:37 - info: [Skills] Initiated
21:46:37 - debug: [Ghost Content Manager] (transparent) Added root folder generated/flows, doing nothing.
21:46:37 - info: Loaded @botpress/audience, version 10.20.1
21:46:37 - debug: [Ghost Content Manager] (transparent) Added root folder generated/intents, doing nothing.
21:46:37 - debug: [Ghost Content Manager] (transparent) Added root folder generated/entities, doing nothing.
21:46:37 - info: Loaded @botpress/nlu, version 10.20.1
21:46:37 - info: Configuration for module "@botpress/skill-choice" has been created at /usr/share/botpress/config/skill-choice.json
21:46:37 - info: Loaded @botpress/skill-choice, version 10.20.1
21:46:37 - info: Loaded @botpress/hitl, version 10.20.1
21:46:38 - verbose: [Renderers] Enabled for webchat.
21:46:38 - info: Loaded @botpress/channel-web, version 10.20.1
21:46:38 - info: Loaded 5 modules
21:46:38 - info: [Skills] Loaded 1 skills
21:46:38 - debug: [Ghost Content Manager] (transparent) Added root folder generated/content, doing nothing.
21:46:38 - debug: Loading middleware: rendering.instrumentation
21:46:38 - debug: Loading middleware: hitl.captureInMessages
21:46:38 - debug: Loading middleware: nlu.incoming
21:46:38 - debug: Loading middleware: hear
21:46:38 - debug: Loading middleware: hitl.captureOutMessages
21:46:38 - debug: Loading middleware: webchat.sendMessages
21:46:38 - debug: Loading middleware: fallback
21:46:38 - debug: Loading data for builtin_text from builtin_text.json
21:46:38 - info: Read 7 item(s) from builtin_text.json
21:46:38 - error: [FATAL] An unhandled exception occurred in your bot 
{ message: 'bind EACCES tcp://10.43.63.0:3000',
  stack: 'Error: bind EACCES tcp://10.43.63.0:3000\n    at Object._errnoException (util.js:1024:11)\n    at _exceptionWithHostPort (util.js:1046:20)\n    at listenOnMasterHandle (net.js:1411:16)\n    at rr (internal/cluster/child.js:111:12)\n    at Worker.send (internal/cluster/child.js:78:7)\n    at process.onInternalMessage (internal/cluster/utils.js:42:8)\n    at emitTwo (events.js:131:20)\n    at process.emit (events.js:214:7)\n    at process.emit (/usr/share/botpress/node_modules/source-map-support/source-map-support.js:439:21)\n    at emit (internal/child_process.js:772:12)\n    at _combinedTickCallback (internal/process/next_tick.js:141:11)\n    at process._tickDomainCallback (internal/process/next_tick.js:218:9)',
  code: 'EACCES',
  errno: 'EACCES',
  syscall: 'bind',
  address: 'tcp://10.43.63.0:3000',
  port: -1 }
21:46:38 - error: Error: bind EACCES tcp://10.43.63.0:3000
    at Object._errnoException (util.js:1024:11)
    at _exceptionWithHostPort (util.js:1046:20)
    at listenOnMasterHandle (net.js:1411:16)
    at rr (internal/cluster/child.js:111:12)
    at Worker.send (internal/cluster/child.js:78:7)
    at process.onInternalMessage (internal/cluster/utils.js:42:8)
    at emitTwo (events.js:131:20)
    at process.emit (events.js:214:7)
    at process.emit (/usr/share/botpress/node_modules/source-map-support/source-map-support.js:439:21)
    at emit (internal/child_process.js:772:12)
    at _combinedTickCallback (internal/process/next_tick.js:141:11)
    at process._tickDomainCallback (internal/process/next_tick.js:218:9)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

@mitchhh22
Copy link

running to into the same issue trying to run on kubernetes.... anyone have a fix?

also latest tag on dockerhub is gone

@michaelmass michaelmass transferred this issue from botpress/botpress Jun 22, 2023
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

3 participants