I want to develop a MEAN stack app on Heroku, however, it failed and throw me some errors and ask me to check the log. My application works fine on localhost, here is the app github link: https://github.com/zichenma/blackboard I have no idea what happen. Anyone can help me with this? Thank you so much in advanced!
2016-10-26T19:25:04.437140+00:00 app[web.1]: # Unstable releases are available for preview/testing only.
2016-10-26T19:25:04.437211+00:00 app[web.1]: #
2016-10-26T19:25:04.437255+00:00 app[web.1]: ##############################################################
2016-10-26T19:25:04.437283+00:00 app[web.1]:
2016-10-26T19:25:04.489004+00:00 app[web.1]: Wed, 26 Oct 2016 19:25:04 GMT express-session deprecated undefined resave option; provide resave option at server.js:33:9
2016-10-26T19:25:04.490059+00:00 app[web.1]: Wed, 26 Oct 2016 19:25:04 GMT express-session deprecated undefined saveUninitialized option; provide saveUninitialized option at server.js:33:9
2016-10-26T19:25:04.490153+00:00 app[web.1]: Warning: connect.session() MemoryStore is not
2016-10-26T19:25:04.490155+00:00 app[web.1]: designed for a production environment, as it will leak
2016-10-26T19:25:04.490156+00:00 app[web.1]: memory, and will not scale past a single process.
2016-10-26T19:25:04.588917+00:00 app[web.1]: { [MongoError: auth failed] name: 'MongoError', ok: 0, errmsg: 'auth failed', code: 18 }
2016-10-26T19:26:02.387104+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2016-10-26T19:26:02.387104+00:00 heroku[web.1]: Stopping process with SIGKILL
2016-10-26T19:26:02.512694+00:00 heroku[web.1]: Process exited with status 137
2016-10-26T19:26:02.584450+00:00 heroku[web.1]: State changed from starting to crashed
2016-10-26T19:26:02.585639+00:00 heroku[web.1]: State changed from crashed to starting
2016-10-26T19:26:04.361960+00:00 heroku[web.1]: Starting process with command `node server.js`
2016-10-26T19:26:07.234279+00:00 app[web.1]: { [Error: Cannot find module '../build/Release/bson'] code: 'MODULE_NOT_FOUND' }
2016-10-26T19:26:07.235703+00:00 app[web.1]: js-bson: Failed to load c++ bson extension, using pure JS version
2016-10-26T19:26:07.434343+00:00 app[web.1]:
2016-10-26T19:26:07.434389+00:00 app[web.1]: ##############################################################
2016-10-26T19:26:07.434444+00:00 app[web.1]: #
2016-10-26T19:26:07.434485+00:00 app[web.1]: # !!! MONGOOSE WARNING !!!
2016-10-26T19:26:07.434524+00:00 app[web.1]: #
2016-10-26T19:26:07.434564+00:00 app[web.1]: # This is an UNSTABLE release of Mongoose.
2016-10-26T19:26:07.434643+00:00 app[web.1]: # DO NOT run this in production.
2016-10-26T19:26:07.434602+00:00 app[web.1]: # Unstable releases are available for preview/testing only.
2016-10-26T19:26:07.434688+00:00 app[web.1]: #
2016-10-26T19:26:07.434729+00:00 app[web.1]: ##############################################################
2016-10-26T19:26:07.434769+00:00 app[web.1]:
2016-10-26T19:26:07.531910+00:00 app[web.1]: Wed, 26 Oct 2016 19:26:07 GMT express-session deprecated undefined resave option; provide resave option at server.js:33:9
2016-10-26T19:26:07.533899+00:00 app[web.1]: Wed, 26 Oct 2016 19:26:07 GMT express-session deprecated undefined saveUninitialized option; provide saveUninitialized option at server.js:33:9
2016-10-26T19:26:07.630763+00:00 app[web.1]: { [MongoError: auth failed] name: 'MongoError', ok: 0, errmsg: 'auth failed', code: 18 }
2016-10-26T19:26:07.538978+00:00 app[web.1]: Warning: connect.session() MemoryStore is not
2016-10-26T19:26:07.538983+00:00 app[web.1]: designed for a production environment, as it will leak
2016-10-26T19:26:07.538984+00:00 app[web.1]: memory, and will not scale past a single process.
2016-10-26T19:26:24.587674+00:00 heroku[router]: at=error code=H20 desc="App boot timeout" method=GET path="/" host=zichenblackboard.herokuapp.com request_id=a2d7df9b-7e2f-467d-8d56-0952a7445c19 fwd="129.10.9.121" dyno= connect= service= status=503 bytes=
2016-10-26T19:27:04.738904+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2016-10-26T19:27:04.739029+00:00 heroku[web.1]: Stopping process with SIGKILL
2016-10-26T19:27:04.940692+00:00 heroku[web.1]: Process exited with status 137
2016-10-26T19:27:04.973605+00:00 heroku[web.1]: State changed from starting to crashed
2016-10-26T19:27:06.449518+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=zichenblackboard.herokuapp.com request_id=9855f356-0e8c-4263-81fc-772b1072cc45 fwd="129.10.9.121" dyno= connect= service= status=503 bytes=
2016-10-26T19:27:06.620739+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=zichenblackboard.herokuapp.com request_id=cb5da5c7-15c1-4d81-9a7b-ab9aaf6c05d4 fwd="129.10.9.121" dyno= connect= service= status=503 bytes=
2016-10-26T19:27:07.049617+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=zichenblackboard.herokuapp.com request_id=f19e3ed2-a72c-48f3-a42b-734d86d7ce67 fwd="129.10.9.121" dyno= connect= service= status=503 bytes=
2016-10-26T19:27:24.589248+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=zichenblackboard.herokuapp.com request_id=af99564e-dce2-4676-9969-124862c9f36b fwd="129.10.9.121" dyno= connect= service= status=503 bytes=
2016-10-26T19:27:24.969275+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=zichenblackboard.herokuapp.com request_id=6a853ff5-831d-4069-8f60-a1570f15795b fwd="129.10.9.121" dyno= connect= service= status=503 bytes=
2016-10-26T19:27:42.412204+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=zichenblackboard.herokuapp.com request_id=b7a68539-d9b5-485f-8c47-81d78995be2f fwd="129.10.9.121" dyno= connect= service= status=503 bytes=
2016-10-26T19:27:42.781982+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=zichenblackboard.herokuapp.com request_id=621881ff-990b-425f-b31a-e7a990ddbbe5 fwd="129.10.9.121" dyno= connect= service= status=503 bytes=
2016-10-26T19:32:24.969477+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=zichenblackboard.herokuapp.com request_id=5429d788-e362-4769-8d10-f830856ca24a fwd="129.10.9.121" dyno= connect= service= status=503 bytes=
2016-10-26T19:32:25.256442+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=zichenblackboard.herokuapp.com request_id=bbd4c7b8-a8e3-461e-8630-8cd2da7cd58f fwd="129.10.9.121" dyno= connect= service= status=503 bytes=
2016-10-26T19:37:35.811641+00:00 heroku[api]: Deploy e841e2b by mazichen1984#gmail.com
2016-10-26T19:37:35.811736+00:00 heroku[api]: Release v7 created by mazichen1984#gmail.com
2016-10-26T19:37:36.054933+00:00 heroku[slug-compiler]: Slug compilation started
2016-10-26T19:37:36.054944+00:00 heroku[slug-compiler]: Slug compilation finished
2016-10-26T19:37:36.492951+00:00 heroku[web.1]: State changed from crashed to starting
2016-10-26T19:37:37.808413+00:00 heroku[web.1]: Starting process with command `node server.js`
2016-10-26T19:37:39.901939+00:00 app[web.1]: js-bson: Failed to load c++ bson extension, using pure JS version
2016-10-26T19:37:39.900937+00:00 app[web.1]: { [Error: Cannot find module '../build/Release/bson'] code: 'MODULE_NOT_FOUND' }
2016-10-26T19:37:40.050266+00:00 app[web.1]:
2016-10-26T19:37:40.050286+00:00 app[web.1]: ##############################################################
2016-10-26T19:37:40.050325+00:00 app[web.1]: #
2016-10-26T19:37:40.050354+00:00 app[web.1]: # !!! MONGOOSE WARNING !!!
2016-10-26T19:37:40.050392+00:00 app[web.1]: #
2016-10-26T19:37:40.050418+00:00 app[web.1]: # This is an UNSTABLE release of Mongoose.
2016-10-26T19:37:40.050447+00:00 app[web.1]: # DO NOT run this in production.
2016-10-26T19:37:40.050445+00:00 app[web.1]: # Unstable releases are available for preview/testing only.
2016-10-26T19:37:40.050466+00:00 app[web.1]: #
2016-10-26T19:37:40.050515+00:00 app[web.1]:
2016-10-26T19:37:40.050493+00:00 app[web.1]: ##############################################################
2016-10-26T19:37:40.094020+00:00 app[web.1]: Wed, 26 Oct 2016 19:37:40 GMT express-session deprecated undefined resave option; provide resave option at server.js:33:9
2016-10-26T19:37:40.094930+00:00 app[web.1]: Wed, 26 Oct 2016 19:37:40 GMT express-session deprecated undefined saveUninitialized option; provide saveUninitialized option at server.js:33:9
2016-10-26T19:37:40.095011+00:00 app[web.1]: Warning: connect.session() MemoryStore is not
2016-10-26T19:37:40.095012+00:00 app[web.1]: designed for a production environment, as it will leak
2016-10-26T19:37:40.095012+00:00 app[web.1]: memory, and will not scale past a single process.
2016-10-26T19:37:40.134038+00:00 app[web.1]: [Error: failed to connect to [localhost:27017]]
2016-10-26T19:37:40.252494+00:00 heroku[web.1]: State changed from starting to crashed
2016-10-26T19:37:40.253488+00:00 heroku[web.1]: State changed from crashed to starting
2016-10-26T19:37:40.234424+00:00 heroku[web.1]: Process exited with status 0
2016-10-26T19:37:41.790766+00:00 heroku[web.1]: Starting process with command `node server.js`
2016-10-26T19:37:44.134867+00:00 app[web.1]: { [Error: Cannot find module '../build/Release/bson'] code: 'MODULE_NOT_FOUND' }
2016-10-26T19:37:44.135992+00:00 app[web.1]: js-bson: Failed to load c++ bson extension, using pure JS version
2016-10-26T19:37:44.501677+00:00 app[web.1]:
2016-10-26T19:37:44.501724+00:00 app[web.1]: ##############################################################
2016-10-26T19:37:44.501769+00:00 app[web.1]: #
2016-10-26T19:37:44.501809+00:00 app[web.1]: # !!! MONGOOSE WARNING !!!
2016-10-26T19:37:44.501846+00:00 app[web.1]: #
2016-10-26T19:37:44.501886+00:00 app[web.1]: # This is an UNSTABLE release of Mongoose.
2016-10-26T19:37:44.501922+00:00 app[web.1]: # Unstable releases are available for preview/testing only.
2016-10-26T19:37:44.501959+00:00 app[web.1]: # DO NOT run this in production.
2016-10-26T19:37:44.502010+00:00 app[web.1]: #
2016-10-26T19:37:44.502042+00:00 app[web.1]: ##############################################################
2016-10-26T19:37:44.502060+00:00 app[web.1]:
2016-10-26T19:37:44.608668+00:00 app[web.1]: Wed, 26 Oct 2016 19:37:44 GMT express-session deprecated undefined resave option; provide resave option at server.js:33:9
2016-10-26T19:37:44.609658+00:00 app[web.1]: Wed, 26 Oct 2016 19:37:44 GMT express-session deprecated undefined saveUninitialized option; provide saveUninitialized option at server.js:33:9
2016-10-26T19:37:44.609748+00:00 app[web.1]: memory, and will not scale past a single process.
2016-10-26T19:37:44.609745+00:00 app[web.1]: Warning: connect.session() MemoryStore is not
2016-10-26T19:37:44.638489+00:00 app[web.1]: [Error: failed to connect to [localhost:27017]]
2016-10-26T19:37:44.609747+00:00 app[web.1]: designed for a production environment, as it will leak
2016-10-26T19:37:44.730255+00:00 heroku[web.1]: State changed from starting to crashed
2016-10-26T19:37:44.718868+00:00 heroku[web.1]: Process exited with status 0
2016-10-26T19:37:48.073902+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=zichenblackboard.herokuapp.com request_id=e8562216-4639-4014-b497-0f976fe8d463 fwd="129.10.9.121" dyno= connect= service= status=503 bytes=
2016-10-26T19:37:48.424557+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=zichenblackboard.herokuapp.com request_id=70192eaa-2e82-4037-a7a3-43d32e4c8c54 fwd="129.10.9.121" dyno= connect= service= status=503 bytes=
My server.js file:
var express = require('express');
var path = require('path');
var favicon = require('serve-favicon');
var logger = require('morgan');
var cookieParser = require('cookie-parser');
var bodyParser = require('body-parser');
var session = require('express-session');
var passport = require('passport');
//initialize mongoose schemas
require('./models/models');
require('./models/course');
var index = require('./routes/index');
var api = require('./routes/api');
var authenticate = require('./routes/authenticate')(passport);
var mongoose = require('mongoose'); //add for Mongo support
mongoose.connect(process.env.MONGOLAB_URI ||'mongodb://localhost:27017/courseManager', function (err) {
if(err){
console.error(err)
}else {
console.log("connected");
}
}); //connect to Mongo
var app = express();
// view engine setup
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'ejs');
// uncomment after placing your favicon in /public
//app.use(favicon(__dirname + '/public/favicon.ico'));
app.use(logger('dev'));
app.use(session({
secret: 'keyboard cat'
}));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(cookieParser());
app.use(express.static(path.join(__dirname, 'public')));
app.use(passport.initialize());
app.use(passport.session());
app.use('/',index);
app.use('/auth', authenticate);
app.use('/api', api);
// catch 404 and forward to error handler
app.use(function(req, res, next) {
var err = new Error('Not Found');
err.status = 404;
next(err);
});
//// Initialize Passport
var initPassport = require('./passport-init');
initPassport(passport);
// error handlers
// development error handler
// will print stacktrace
if (app.get('env') === 'development') {
app.use(function(err, req, res, next) {
res.status(err.status || 500);
res.render('error', {
message: err.message,
error: err
});
});
}
// production error handler
// no stacktraces leaked to user
app.use(function(err, req, res, next) {
res.status(err.status || 500);
res.render('error', {
message: err.message,
error: {}
});
});
module.exports = app;
Right now your Procfile is instructing Heroku's orchestration to start the process with node server.js. Change that line in your Procfile to web: npm start or web: bin/www.
Related
I have a flask socket io application that used to work a few months ago, but I'm not sure whats happened. I've stripped it down to the basics.
The output logs show a bunch of garbled nonsense that I think is supposed to be the start of a TLS handshake (from the research I've done).
Console is showing a CORS related error. I don't know why that is - shouldn't the origin be the same for local host? Is the server sending secure requests?
I've tried socketio = SocketIO(app, cors_allowed_origins='*')
as mentioned in this question, but the issue is still there.
This is the logging output, in the past it would show the polling url:
My application.py code:
from flask import Flask, render_template
from flask_socketio import SocketIO, emit
app = Flask(__name__)
app.config["SECRET_KEY"] = 'secret?'
socketio = SocketIO(app, engineio_logger=True, logger=True)
#app.route("/", methods=["GET"])
def index():
return render_template("layout.html")
#socketio.on('message')
def handleMessage(msg):
print(msg)
emit(msg, broadcast=True)
if __name__ == '__main__':
socketio.run(app)
Javascript:
document.addEventListener('DOMContentLoaded', () => {
connectSocketIO();
addMessage();
});
var socket;
function connectSocketIO () {
socket = io.connect('http://' + document.domain + ':' + location.port);
socket.on('connect', () => {
console.log('client connected');
socket.on('disconnect', () => console.log('client disconnected'));
});
socket.on('message', (data) => {
console.log(data);
});
}
function addMessage () {
// emit a new message announcement when message is posted
document.querySelector('#btn').onclick = () => {
const message = document.querySelector('input').value;
socket.emit('message', {'message': message});
return false;
};
}
requirements.txt
Flask
Flask-SocketIO
gunicorn
eventlet==0.24.1
Edit:
It appears the initial issue was caused by specifying https protocol in io.connect - changing that has solved the garbled output.
This has caused Firefox to throw an error:
Firefox can't establish a connection to the server as wss://url
In Chrome it works, but the connection changes to http.
Both warn about cookies misusing the sameSite attribute
Cookie "io" will be soon rejected because it has the "sameSite" attribute set to "none" or an invalid value, without the "secure" attribute.
Heroku Procfile:
web: gunicorn --worker-class eventlet -w 1 application:app
On the server side, the logs for Heroku:
2020-07-28T12:41:43.350016+00:00 app[web.1]: https://flack-messaging-app.herokuapp.com is not an accepted origin.
2020-07-28T12:41:43.346991+00:00 heroku[router]: at=info method=POST path="/socket.io/?EIO=3&transport=polling&t=NELSMDM&sid=f25e5af236d347eaa3100951014be579" host=flack-messaging-app.herokuapp.com request_id=1041f8b4-71b8-4cf5-a321-75014d2ccde7 fwd="78.146.97.151" dyno=web.1 connect=1ms service=8ms status=400 bytes=182 protocol=https
2020-07-28T12:41:44.399195+00:00 heroku[router]: at=info method=POST path="/socket.io/?EIO=3&transport=polling&t=NELSMTk&sid=f25e5af236d347eaa3100951014be579" host=flack-messaging-app.herokuapp.com request_id=dba0c5f4-6afd-4621-ad7e-4c511911a714 fwd="78.146.97.151" dyno=web.1 connect=2ms service=3ms status=400 bytes=182 protocol=https
2020-07-28T12:41:44.402016+00:00 app[web.1]: https://flack-messaging-app.herokuapp.com is not an accepted origin.
2020-07-28T12:41:45.481764+00:00 heroku[router]: at=info method=GET path="/socket.io/?EIO=3&transport=polling&t=NELSMkn" host=flack-messaging-app.herokuapp.com request_id=8ba7cc91-5e33-4113-a15d-84e5ceba8ca4 fwd="78.146.97.151" dyno=web.1 connect=1ms service=3ms status=200 bytes=385 protocol=https
2020-07-28T12:41:45.483979+00:00 app[web.1]: 5b1138c7e62a4ea2bff2beb55eb5241d: Sending packet OPEN data {'sid': '5b1138c7e62a4ea2bff2beb55eb5241d', 'upgrades': ['websocket'], 'pingTimeout': 60000, 'pingInterval': 25000}
2020-07-28T12:41:45.484100+00:00 app[web.1]: 5b1138c7e62a4ea2bff2beb55eb5241d: Sending packet MESSAGE data 0
2020-07-28T12:41:45.571836+00:00 app[web.1]: https://flack-messaging-app.herokuapp.com is not an accepted origin.
2020-07-28T12:41:45.566552+00:00 heroku[router]: at=info method=GET path="/socket.io/?EIO=3&transport=websocket&sid=5b1138c7e62a4ea2bff2beb55eb5241d" host=flack-messaging-app.herokuapp.com request_id=d802cd1c-c875-4406-a75e-2c3ca2368de0 fwd="78.146.97.151" dyno=web.1 connect=0ms service=2ms status=400 bytes=187 protocol=https
2020-07-28T12:41:48.383640+00:00 heroku[router]: at=error code=H12 desc="Request timeout" method=GET path="/socket.io/?EIO=3&transport=polling&t=NELSG6k&sid=f25e5af236d347eaa3100951014be579" host=flack-messaging-app.herokuapp.com request_id=26757146-e11f-43d6-a243-65172f72dd5e fwd="78.146.97.151" dyno=web.1 connect=1ms service=30001ms status=503 bytes=0 protocol=https
Ok, it looks like there were two issues:
In io.connect on the client side, the connect parameter used
https:// + document.domain + location.port but the server was using http:// so was causing the garbled output.
Changing https:// to window.location.protocol + '//' + 'rest_of_url' fixed the garbled output.
Heroku uses https:// but my server was configured for http:// - I'm still not sure what settings to change in Flask to use one over the other but in my application.py, for the Socket constructor, adding in cors_allowed_origins='https://myurl' fixed the issue with wss unable to connect. I've since used
cors_allowed_origins=['http://url', 'https://url'] to allow both secure and non-secure access. I'm not familiar enough with Heroku or Flask to force one over the other and this solution works well for me.
Hi I am using Twilio to send text messages to several phone numbers.
When the user gets the text message from my React.js application, I would like them to be able to respond back to that text message and have my application do some processing, then texting back that the processing is completed.
Based on the Twilio web page.
However I keep getting a 404 response.
Here are the details of this issue:
The application is a REACT application running on Heroku
Important stuff from my 'server.js' file
const express = require('express');
const bodyParser = require('body-parser');
const passport = require('passport');
const path = require('path');
const mongoose = require('mongoose');
const sms = require('./routes/api/sms');
const app = express();
// body parser
let size = '50mb';
app.use(bodyParser.urlencoded({limit: size,extended: false}));
app.use(bodyParser.json({limit: size}));
// passport middleware
app.use(passport.initialize());
// passport config file.
// passport uses a strategy
require('./config/passport')(passport);
// use routes
app.use('/api/sms', sms);
// server static assests if in production
if (process.env.NODE_ENV === 'production') {
// Set static folder
app.use(express.static('client/build'));
app.get('*', (req, res) => {
res.sendFile(path.resolve(__dirname, 'client', 'build', 'index.html'));
});
}
const serverPort = require('./config/keys').serverPort;
const port = process.env.PORT || serverPort;
app.listen(port, () => console.log(`server running on port ${port}`));
Here is sms.js file contents (the URL that 'should' respond to the web hook call)
router.post('/twiml', (req, res) => {
let debugThis = true;
if(debugThis){
console.log('post api/sms/twiml');
console.log(req.body);
}
const twiml = new MessagingResponse();
if (req.body.Body == 'hi') {
twiml.message('Hello!');
} else if (req.body.Body == 'bye') {
twiml.message('Goodbye');
} else {
twiml.message(
'No Body param match, Twilio sends this in the request to your server.'
);
}
res.writeHead(200, { 'Content-Type': 'text/xml' });
res.end(twiml.toString());
});
So I think when I make the call the URL I should be using as a web hook should be configured on my phone number in Twilio like this : ( the missing part from the front is HTTPS:// )
when I text my Twilio number, this is what I get in the log:
2020-01-25T23:53:17.755941+00:00 heroku[router]: at=info method=POST path="/sms/twiml" host=choremonger.herokuapp.com request_id=7d44f910-2850-4282-aa14-08270384e99a fwd="54.198.69.37" dyno=web.1 connect=36ms service=23ms status=404 bytes=393 protocol=https
In other words:
My Twilio number is 555-555-5555
Joe's number is 111-111-1111
I envision the messaging looking like this:
SEND from 555-555-5555 to 111-111-1111 "Is Task A completed"
RC'd on 111-111-1111 "Is Task A completed"
SEND from 111-111-1111 to 555-555-5555 "Yes"
RC'd on 555-555-5555 "Yes"
This is where my application is notified via the web hook that "Yes" was texted.
< some processing occurs and sender's phone number is used to reply >
SEND from 555-555-5555 to 111-111-1111 "Task A is closed"
Update 1
the reason I added this is due to a comment that the web hook URL is incorrect.
When I use 'npm run server' from Visual Studio Code and Postman to check the URL I get this:
server output in Visual Studio
[nodemon] 1.18.10
[nodemon] to restart at any time, enter `rs`
[nodemon] watching: *.*
[nodemon] starting `node server.js`
server running on port 5000
DB connected
post api/sms/twiml
{ Body: 'hi' }
PostMan URL call:
http://localhost:5000/api/sms/twiml
PostMan body:
{
"Body" :"hi"
}
PostMan result:
Status: 200 OK
<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Message>Hello!</Message>
</Response>
Update 2
When I removed the 'twilml' from the webhook URL in Twilio and texted, I got this:
2020-01-26T18:05:09.862565+00:00 heroku[router]: at=info method=POST path="/sms" host=choremonger.herokuapp.com request_id=8b0d0987-2907-4796-a8b2-d4e6d14e209a fwd="54.208.241.142" dyno=web.1 connect=0ms service=2ms status=404 bytes=387 protocol=https
When I put it back in and texted again, and got this:
2020-01-26T18:06:26.639155+00:00 heroku[router]: at=info method=POST path="/sms/twiml" host=choremonger.herokuapp.com request_id=0af446f3-4432-40fe-b6e6-1b64ecf6608c fwd="3.89.83.196" dyno=web.1 connect=0ms service=3ms status=404 bytes=393 protocol=https
Update 3
I thought it might be due to HTTPS vs HTTP, so I changed the web hook to HTTP and tried again... the request picked up the http change... but same result.
2020-01-27T03:13:51.506124+00:00 heroku[router]: at=info method=POST path="/sms/twiml" host=choremonger.herokuapp.com request_id=539604b1-3b08-47d9-a124-3d2e30596043 fwd="54.166.158.158" dyno=web.1 connect=1ms service=2ms status=404 bytes=393 protocol=http
Update 4
I went to Twilio's debugger and pulled some information... hopefully somebody can help direct me on how to fix this
Phone numbers and SIDS are correct
Thanks !
OK... for all those that are just as new to web programming and REACT as I am...
THIS is the cause:
This the line in my server.js file that puts the URL into the world:
const sms = require('./routes/api/sms');
I was missing the 'api' from the URL in the Twilio configuration link
We have deployed our application over heroku with basic laravel auth functionality. There not any loop or any heavy query.
Following are the parameters posted to /login function.
_token s7rKa0Ve2XODZcagW1K26qrqoOFyyuCWfxtEcrQI
email test#gmail.com
password 12341234
LoginController Code
public function __construct()
{
$this->middleware('guest')->except('logout');
}
/**
* The user has been authenticated.
* Method copied from"Illumunate\Foundation\Auth\AuthenticateUsers.php"
* #param \Illuminate\Http\Request $request
* #param mixed $user
* #return mixed
*/
protected function authenticated()
{
if( Auth::user()->role == '1') return Redirect('members');
if( Auth::user()->role == '2' ) return Redirect('assignments');
}
and following error is showing in heroku log file.
2018-11-06T09:14:30.519786+00:00 heroku[router]: at=error code=H12
desc="Request timeout" method=POST path="/login"
host=polar-meadow-18285.herokuapp.com
request_id=1cafc4c1-8f72-4b04-854b-c315f9636935 fwd="39.59.198.150"
dyno=web.1 connect=0ms service=30000ms status=503 bytes=0
protocol=https 2018-11-06T09:15:00.578424+00:00 app[web.1]: [Tue Nov
06 09:15:00.577937 2018] [proxy_fcgi:error] [pid 246:tid
140561109444352] (70007)The timeout specified has expired: [client
10.109.225.219:31977] AH01075: Error dispatching request to : (polling), referer: https://polar-meadow-18285.herokuapp.com/login
2018-11-06T09:15:00.578672+00:00 app[web.1]: 10.109.225.219 - -
[06/Nov/2018:09:14:00 +0000] "POST /login HTTP/1.1" 504 247
"https://polar-meadow-18285.herokuapp.com/login" "Mozilla/5.0
(Macintosh; Intel Mac OS X 10.12; rv:63.0) Gecko/20100101 Firefox/63.0
2018-11-06T09:28:20.973811+00:00 heroku[router]: at=info method=GET
path="/login" host=polar-meadow-18285.herokuapp.com
request_id=ac62bbad-2516-455b-bff7-22764cdce842 fwd="39.59.198.150"
dyno=web.1 connect=0ms service=19ms status=200 bytes=6961
protocol=https
i am unable to figure it out. Your thoughts will be appreciated.
you will have to make a .procfile and you can follow the official documentation for further help.
https://devcenter.heroku.com/articles/getting-started-with-laravel
I've been looking around on how to make HTTPS requests using the Shoes GUI builder and I'm getting the SSL_connnect connect error and I'm unsure of what to do about it.
I made a test app in this Gist
Here's the Error:
SSL_connect returned=1 errno=0 state=error: certificate verify failed
/Applications/Shoes.app/Contents/MacOS/lib/ruby/2.2.0/net/http.rb:923:in `connect'
/Applications/Shoes.app/Contents/MacOS/lib/ruby/2.2.0/net/http.rb:923:in `block in connect'
/Applications/Shoes.app/Contents/MacOS/lib/ruby/2.2.0/timeout.rb:73:in `timeout'
/Applications/Shoes.app/Contents/MacOS/lib/ruby/2.2.0/net/http.rb:923:in `connect'
/Applications/Shoes.app/Contents/MacOS/lib/ruby/2.2.0/net/http.rb:863:in `do_start'
/Applications/Shoes.app/Contents/MacOS/lib/ruby/2.2.0/net/http.rb:852:in `start'
/Applications/Shoes.app/Contents/MacOS/lib/ruby/2.2.0/net/http.rb:1375:in `request'
shoes.rb:17:in `request'
shoes.rb:54:in `block (3 levels) in <main>'
-e:1:in `call'
I figured it out. Updating the request to strip the token and setting the verify_mode to OpenSSL::SSL::VERIFY_NONE fixed the problem.
token = Base64.encode64("#{user}:#{pass}").strip
uri = URI("https://example.com/")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Get.new(uri.request_uri)
request["authorization"] = "Bearer #{token}"
request["Content-Type"] = "application/json"
response = http.request(request)
info(response.body)
response
I'm trying to replicate the curl request on this page using Ruby. When I run the curl request from my system it works fine, but Ruby gives me an error. I've tried a few different ways of doing Ruby posts but none of them work. Here's my code:
hr_args = { 'type' => 'todo',
'text' => 'tyy'
}
hr_hd = {"Content-Type"=>"application/json",
'x-api-user'=> habit_user,
'x-api-key' => habit_token
}
url = URI.parse('https://habitrpg.com:443/api/v2/user/tasks')
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Post.new(url.request_uri, hr_hd)
request.body = hr_args.to_json
response = http.request(request)
This is the error I get:
/usr/local/rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/net/protocol.rb:153:in `read_nonblock': end of file reached (EOFError)
from /usr/local/rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/net/protocol.rb:153:in `rbuf_fill'
from /usr/local/rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/net/protocol.rb:134:in `readuntil'
from /usr/local/rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/net/protocol.rb:144:in `readline'
from /usr/local/rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/net/http/response.rb:39:in `read_status_line'
from /usr/local/rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/net/http/response.rb:28:in `read_new'
from /usr/local/rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/net/http.rb:1408:in `block in transport_request'
from /usr/local/rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/net/http.rb:1405:in `catch'
from /usr/local/rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/net/http.rb:1405:in `transport_request'
from /usr/local/rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/net/http.rb:1378:in `request'
from /usr/local/rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/net/http.rb:1371:in `block in request'
from /usr/local/rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/net/http.rb:853:in `start'
from /usr/local/rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/net/http.rb:1369:in `request'
from todo.rb:38:in `<main>'
What am I doing wrong?
The problem was that I needed to set http.use_ssl = true.
try this
...
require 'openssl'
OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE
...
...