Я работаю над проектом IoT. Я собираюсь использовать Mqtt для связи между устройствами, я начал запускать простой пример, используя NodeJs и mosca, и он работает на моей локальной машине Linux.Mqtt Node Js, развертывающий на авариях герою
Когда я начал развертывание через Heroku, я столкнулся с проблемой крушения.
вот мой код:
var mosca = require('mosca')
var http = require('http');
var url = require('url');
var sys = require('sys');
var settings = {
port: 1883 || Number(process.env.PORT)
};
//here we start mosca
var server = new mosca.Server(settings);
server.on('ready', setup);
// fired when the mqtt server is ready
function setup() {
console.log('Mosca server is up and running')
}
// fired whena client is connected
server.on('clientConnected', function(client) {
console.log('client connected', client.id);
});
// fired when a message is received
server.on('published', function(packet, client) {
console.log('Published : ', packet.payload);
});
// fired when a client subscribes to a topic
server.on('subscribed', function(topic, client) {
console.log('subscribed : ', topic);
});
// fired when a client subscribes to a topic
server.on('unsubscribed', function(topic, client) {
console.log('unsubscribed : ', topic);
});
// fired when a client is disconnecting
server.on('clientDisconnecting', function(client) {
console.log('clientDisconnecting : ', client.id);
});
// fired when a client is disconnected
server.on('clientDisconnected', function(client) {
console.log('clientDisconnected : ', client.id);
});
и это крах сообщенных бревен Heroku:
State changed from crashed to starting
2015-09-28T12:49:43.209288+00:00 heroku[web.1]: Starting process with command `node index.js`
2015-09-28T12:49:48.669918+00:00 app[web.1]: (node) sys is deprecated. Use util instead.
2015-09-28T12:49:48.718428+00:00 app[web.1]: Mosca server is up and running
2015-09-28T12:50:43.468112+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2015-09-28T12:50:43.468112+00:00 heroku[web.1]: Stopping process with SIGKILL
2015-09-28T12:50:44.373307+00:00 heroku[web.1]: State changed from starting to crashed
2015-09-28T12:50:44.352908+00:00 heroku[web.1]: Process exited with status 137
2015-09-28T12:53:30.899810+00:00 heroku[slug-compiler]: Slug compilation started
2015-09-28T12:53:30.899837+00:00 heroku[slug-compiler]: Slug compilation finished
2015-09-28T12:53:30.830161+00:00 heroku[api]: Deploy c237cb9 by [email protected]
2015-09-28T12:53:30.830200+00:00 heroku[api]: Release v20 created by [email protected]
2015-09-28T12:53:30.926174+00:00 heroku[web.1]: State changed from crashed to starting
2015-09-28T12:53:33.726073+00:00 heroku[web.1]: Starting process with command `node index.js`
2015-09-28T12:53:36.600467+00:00 app[web.1]: (node) sys is deprecated. Use util instead.
2015-09-28T12:53:36.643097+00:00 app[web.1]: Mosca server is up and running
2015-09-28T12:54:33.858449+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2015-09-28T12:54:33.858449+00:00 heroku[web.1]: Stopping process with SIGKILL
2015-09-28T12:54:34.801910+00:00 heroku[web.1]: State changed from starting to crashed
2015-09-28T12:54:34.781887+00:00 heroku[web.1]: Process exited with status 137
2015-09-28T12:54:36.720413+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=iot-mqtt-glinty-tutorial.herokuapp.com request_id=b74f96e4-0a38-405d-a3c6-38fd41c601b0 fwd="196.221.206.12" dyno= connect= service= status=503 bytes=
2015-09-28T12:54:37.904668+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=iot-mqtt-glinty-tutorial.herokuapp.com request_id=19d27d3a-a478-47a0-8e3f-532d741d15ac fwd="196.221.206.12" dyno= connect= service= status=503 bytes=
Любое решение, что пожалуйста ???
кажется, что PROCFILE играет большую роль в Heroku, но проблема в том, что Heroku всегда поиск по умолчанию http/webservice в индексном файле –
Heroku не считает «индекс» особенным. Единственное особенное - это предположение о «веб-сервисе» в отсутствие Procfile. Не указывая Heroku, как начать процесс, который вы хотите начать, что еще может сделать Heroku для запуска вашего приложения? т.е. если вы не сообщите Heroku, как запустить приложение, что вы ожидаете от системы запуска приложений? – hunterloftis