Skip to content
This repository has been archived by the owner on Sep 20, 2024. It is now read-only.

Timeout when deploying on Bluemix #340

Closed
mttrs opened this issue Jul 25, 2016 · 12 comments
Closed

Timeout when deploying on Bluemix #340

mttrs opened this issue Jul 25, 2016 · 12 comments

Comments

@mttrs
Copy link

mttrs commented Jul 25, 2016

I'm getting an error regarding timeout. The log says a correct listening port should be set. Should I set up a web server instead of just using controller.spawn() and startRTM() function?

Error restarting application: Start app timeout
TIP: Application must be listening on the right port. Instead of hard coding the port, use the $PORT environment variable.

Code: same as Basic Usage code

var Botkit = require('botkit');

var controller = Botkit.slackbot({});

// connect the bot to a stream of messages
controller.spawn({
  token: <my_slack_bot_token>,
}).startRTM()

// give the bot something to listen for.
controller.hears('hello',['direct_message','direct_mention','mention'],function(bot,message) {
  bot.reply(message,'Hello yourself.');
});
% cat Procfile
web: node app.js

% cat manifest.yml
applications:
- path: .
  memory: 128M
  instances: 1
  domain: mybluemix.net
  name: xxx-bot
  host: xxx-bot
  disk_quota: 1024M
  buildpack: https://github.com/cloudfoundry/nodejs-buildpack.git
@mttrs
Copy link
Author

mttrs commented Jul 25, 2016

Even I change the Procfile to run as worker, it sitll causes the error.

% cat Procfile
worker: node app.js

A log says... It looks down after 1 min. Probably setting timeout as 1 min.

0 of 1 instances running, 1 starting
0 of 1 instances running, 1 down
0 of 1 instances running, 1 down
0 of 1 instances running, 1 down

@SheaBelsky
Copy link

I'm also developing a bot with Bluemix, you need to have a server running (Express, or make one with Botkit) and set it up with the process.env.VCAP_APP_PORT port.

@mttrs
Copy link
Author

mttrs commented Jul 26, 2016

Hi @SHBelsky ,

Thanks for the info. It runs with Blumix after adding the code below which sets express web server. It's a bit bothersome to need a extra job, since other public cloud like heroku and azure web app don't need it. It might be a cloud foundry policy, though...

const port = process.env.VCAP_APP_PORT || 3000;

controller.setupWebserver(port, function(err,webserver) {
  controller.createWebhookEndpoints(controller.webserver);
});

@mttrs mttrs closed this as completed Jul 26, 2016
@aeweidne
Copy link

@mttrs is it required to set up this webserver even when just communicating with RTM via websockets? running into something similar using a container service with docker

@SheaBelsky
Copy link

SheaBelsky commented Aug 18, 2016

@aeweidne you don't need to create a webserver if you're using Slack. Just doing slackbot.startRTM(); should be sufficient.

edited this because I confused this GitHub topic with a different one :p

@mttrs
Copy link
Author

mttrs commented Aug 19, 2016

@aeweidne ,
You need to do it only when the app runs on any cloud foundry base PaaSs such as Bluemix. I'm not sure a container version works well, though.

@aeweidne
Copy link

@mttrs Is there a specific port that I need to expose on my container in order to take advantage of websockets? It's working fine locally and on a virtual machine but inside my container it is hanging without connecting.

@mttrs
Copy link
Author

mttrs commented Aug 19, 2016

@aeweidne ,
You mean that your container app runs on the bluemix? I've not tried the container app on bluemix, so I have no idea about it. But what if setting a web server with your app? The port should be VCAP_APP_PORT as above my comment.

@aeweidne
Copy link

aeweidne commented Aug 22, 2016

@mttrs I am using a regular Docker container now, after moving on from Bluemix, and the websocket connection appears to close randomly after responding in chat. The node process on the container is still running, so it's not crashing. Going to try to use debug mode to get to the bottom of it. Thanks for the help

after turning on debug mode: this is the error I'm getting intermittently:

Mdebug: Got response { [Error: getaddrinfo ENOTFOUND slack.com slack.com:443]
  code: 'ENOTFOUND',
  errno: 'ENOTFOUND',
  syscall: 'getaddrinfo',
  hostname: 'slack.com',
  host: 'slack.com',
  port: 443 } undefined

@anonrig
Copy link
Contributor

anonrig commented Aug 23, 2016

@aeweidne did you open the port 443 for SSL connection to slack.com?

@mttrs mttrs reopened this Aug 24, 2016
@upkarlidder
Copy link

I tried the same and seems like cloudfoundry/bluemix tries to ping the app after deploying and doesn't start the app if it is unable to find a port to connect with. @mttrs solution worked.

OUT Starting app instance (index 0) with guid xxxxxxxxxx
OUT 
OUT > slack-sample-bot-app@3.2.0 start /home/vcap/app
OUT > node server/index.js
OUT info: ** No persistent storage method specified! Data may be lost when process shuts down.
OUT info: ** Setting up custom handlers for processing Slack messages
OUT info: ** API CALL: https://slack.com/api/rtm.start
OUT notice: ** BOT ID: yogibot_1 ...attempting to connect to RTM!
OUT notice: RTM websocket opened
ERR Instance (index 0) failed to start accepting connections

@mttrs
Copy link
Author

mttrs commented Sep 16, 2016

@aeweidne ,
My problem is solved and to separate from the other issue like docker, I'd like to close the issue. Please issue a new ticket if you wanna discuss the docker with bluemix.

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

No branches or pull requests

6 participants