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
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
I hope you're doing well. I'm struggling since several days with Laravel Passport, trying to consume my own api with javascript / vuejs. The last evenings were spend reading nearly every existing post about my problem, but I could not find any solution. I hope you can help me, thank you at this point.
I've set up a fresh laravel application and installed Laravel Passport like it its described in this offical doc for Laravel 5.8 (https://laravel.com/docs/5.8/passport#introduction). I've done every single point from the tutorial multiple times in different applications, without any success. To test my setup, I'm using this small axios request.
axios.get('/oauth/clients')
.then(response => {
console.log(response);
}).catch(error => {
console.log(response);
})
When I'm logged in, its works fine, when I use a bearer token and use postman to test '/oauth/clients' it works also fine, but when I'm not logged in it always returns 401 Unauthenticated. My goal is to create an api, that I can consume from my own application as an unauthenticated user without a bearer token, but not from the outside. I thought Laravel Passport is the correct way to do this.
My request headers:
:authority: laravel.dev
:method: GET
:path: /oauth/clients
:scheme: https
accept: application/json, text/plain, */*
accept-encoding: gzip, deflate, br
accept-language: de-DE,de;q=0.9,en-US;q=0.8,en;q=0.7
cache-control: no-cache
cookie: XSRF-TOKEN=eyJpdiI6IkxTTGs2cEtvbXc5cmhIZDhEV1lBXC9nPT0iLCJ2YWx1ZSI6IlpPcjdCbmlDcURraG03MndjUTVYeTV1WXl1YWx3MVdNWjFrZ1QrRENJcnlhZVVCNWtZdzl5VDN6ZjdkclBGK0siLCJtYWMiOiI3ZmQ4YjlkZmU3OWMyNjNiYWVhNzJhMWVkOGRhOGJhMzJkNWQwZmZjMDhmZDM2Y2IxYWRkODJiNzFhNmQ5NDA1In0%3D; laravel_session=eyJpdiI6IlpKc3EyS2R4NjAyM0t5XC8xaTR6SjJBPT0iLCJ2YWx1ZSI6Im1JRlRReVFHQ01jTlNQT3BkYlI1V0dNeE1BMkVvODhnWXNjM1VPRUFBRWRBRnl1N1diUmpOSkVJUmc0NTdsVFgiLCJtYWMiOiI0ZTZkNzE2OGQ5MzJkY2FmYzEzOWZiYjA3YTRiM2MxOGQ3OGJmNWIzMTI4ODA5MDMxYWVlMjJmOTk1M2FjZDdlIn0%3D
pragma: no-cache
referer: https://laravel.dev/
user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.100 Safari/537.36
x-csrf-token: 4Opsva9oDk6LkAapLGqqh9AuPzWKfVH4PYoxcMB1
x-requested-with: XMLHttpRequest
x-xsrf-token: eyJpdiI6IkxTTGs2cEtvbXc5cmhIZDhEV1lBXC9nPT0iLCJ2YWx1ZSI6IlpPcjdCbmlDcURraG03MndjUTVYeTV1WXl1YWx3MVdNWjFrZ1QrRENJcnlhZVVCNWtZdzl5VDN6ZjdkclBGK0siLCJtYWMiOiI3ZmQ4YjlkZmU3OWMyNjNiYWVhNzJhMWVkOGRhOGJhMzJkNWQwZmZjMDhmZDM2Y2IxYWRkODJiNzFhNmQ5NDA1In0=
Response headers:
cache-control: no-cache, private
content-type: application/json
date: Sun, 07 Jul 2019 19:05:25 GMT
server: nginx/1.15.5
set-cookie: XSRF-TOKEN=eyJpdiI6IklTWEkrRTJxYXpiRFNQUm0zM3RLYWc9PSIsInZhbHVlIjoiMDEzSmVlMldQOXBrVUQxQjlCUGVVN2dpUk9VWmwrUlRjend3XC9CaUk1S2V6dUFlTDZtVWttREV5cVBPOFwveVQ0IiwibWFjIjoiZWZhMzA3OGVhYmY2NWNjNjgyMTg4NzAxZjQzNWYxZGQyMjVmMWY3MjAwNjllZTM5ODFiNjFiNWY1NGFjOGM0NiJ9; expires=Sun, 07-Jul-2019 21:05:25 GMT; Max-Age=7200; path=/
set-cookie: laravel_session=eyJpdiI6IlFLUDN0bGhBNW1UTytlbGgrcEZ0ekE9PSIsInZhbHVlIjoibHFvM09CSTFyZ05Kd0E0REVCekNOYmRocm01cnBVY3h1YjFOaXpyTXVcL05QSTNYdFFBdVpXZHd4NDVURGwralwvIiwibWFjIjoiYzM0ZWNhNzQ5MTJhY2VmNTZjZmM1YjFiNTgzYjU0NmZhZGIzZjVjYTFkOGNjYWEwNDEwODUyMzc5OWI2Njc3YiJ9; expires=Sun, 07-Jul-2019 21:05:25 GMT; Max-Age=7200; path=/; httponly
status: 401
Important note: I've shared the project with a friend of mine, he works on MacOs with Laravel in a docker container and the authorization works on his device without any changes. I'm running on a windows machine with Laravel Homestead. Could this problem be caused by Laravel Homestead or nginx?
The route 'oauth/clients' is defined under the 'oauth' prefix (e.g., /oauth/any-route) using both the 'web' and 'auth' middlewares. This explains why you are receiving a 401 error when you are not logged in, as the 'auth' middleware is failing.
/vendor/laravel/passport/src/RouteRegistrar.php
/**
* Register the routes needed for managing clients.
*
* #return void
*/
public function forClients()
{
$this->router->group(['middleware' => ['web', 'auth']], function ($router) {
$router->get('/clients', [
'uses' => 'ClientController#forUser',
'as' => 'passport.clients.index',
]);
...
});
}
Also, you should not be using 'web' middleware for your API routes. The API is stateless and should not receive or respond with any session data. This means no need for CSRF/XSRF tokens, which I can see are being transmitted in your example.
You need to place your API routes within the specified API routes file. You'll notice that the authorization middleware 'auth:api' is also slightly different for API routes.
/routes/api.php
Route::middleware(['auth:api'])->group(function () {
Route::get('/your/path', 'Api\YourController#index');
});
Then in Postman, simply pass your bearer token and expected response type. And don't forget to add the 'api' prefix to your route, as you will do for all routes within the api.php routes file.
/api/your/path
Authorization Bearer {your_token}
Accept application/json
Hope this helps and good luck!
Thank you for your answer #matticustard. I've written a small controller to test the authorization and put the route in the following groupe with auth:api middleware:
Route::group(['prefix' => 'v1', 'middleware' => 'auth:api', 'namespace' => 'Api\v1', 'as' => 'api.'], function () {});
When I use a bearer token and postman it works fine, but I want to use this route also from my application as an user who is not logged in. But only from my application not from the outside, how can I achieve this?
axios.get('/api/v1/test')
.then(response => {
console.log(response);
}).catch(error => {
console.log(response);
})
Thank you for your time :)
After pointed in the right direction here Laravel 5.4 relative instead of absolute 302 redirects
I've been trying to get Laravel TrustProxies middleware to work, but seems to be ignoring X_FORWARDED_PROTO header.
My scenario
My app in Laravel (just upgraded from 5.4 to 5.5) is behind a load balancer, which translates all traffic from HTTPS to HTTP.
My problem
All redirects are going over HTTP instead of original protocol HTTPS.
Attempted Solution
Upgrade from Laravel 5.4 to 5.5 and take advantage of the TrustProxies middleware now shipped with Laravel out of the box.
Middleware has:
protected $proxies = '*';
/**
* The current proxy header mappings.
*
* #var array
*/
protected $headers = [
Request::HEADER_FORWARDED => 'FORWARDED',
Request::HEADER_X_FORWARDED_FOR => 'X_FORWARDED_FOR',
Request::HEADER_X_FORWARDED_HOST => 'X_FORWARDED_HOST',
Request::HEADER_X_FORWARDED_PORT => 'X_FORWARDED_PORT',
Request::HEADER_X_FORWARDED_PROTO => 'X_FORWARDED_PROTO',
];
App\Http\Kernel has registered the middleware:
protected $middleware = [
\Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode::class,
\Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
\App\Http\Middleware\TrimStrings::class,
\Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
\App\Http\Middleware\TrustProxies::class,
];
My findings:
Tcp dump from the server reveals the header:
Request:
GET / HTTP/1.1
X_FORWARDED_PROTO: HTTPS
Host: mywebsiteaddress.com
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:56.0) Gecko/20100101 Firefox/56.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate, br
Connection: keep-alive
Upgrade-Insecure-Requests: 1
But the Response has Location over HTTP:
HTTP/1.1 302 Found
Date: Wed, 08 Nov 2017 18:03:48 GMT
Server: Apache/2.4.18 (Ubuntu)
Cache-Control: no-cache, private
Location: http://mywebsiteaddress.com/home
Set-Cookie: laravel_session=eyJp...In0%3D; expires=Wed, 08-Nov-2017 20:03:48 GMT; Max-Age=7200; path=/; HttpOnly
Content-Length: 376
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Content-Type: text/html; charset=UTF-8
Additional comments:
Since my app was upgraded from 5.4 to 5.5, I copied the class TrustProxies that otherwise would've been there in a 5.5 fresh installation. Then I registered it in the Kernel.
Maybe I'm missing a step here.
My hope:
That my tiredness is not clouding my mind that I'm overlooking a simple mistake.
Any suggestions, thank you in advance!
Update:
Enabled log_forensics module in Apache and I see the x-forwarded-proto header in the request.
GET / HTTP/1.1
X_FORWARDED_PROTO:HTTPS
Host:mywebsiteaddress.com
User-Agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv%3a56.0) Gecko/20100101 Firefox/56.0
Accept:text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language:en-US,en;q=0.5
Accept-Encoding:gzip, deflate, br
Connection:keep-alive
Upgrade-Insecure-Requests:1
Cache-Control:max-age=0
Any clue why Laravel may not have in the headers array?
It was indeed tiredness.
The load balancer has been working with X_FORWARDED_PROTO header for C# (IIS) apps, so the network team set the header the same way this time.
But for Laravel, the header has to be in the form of X-FORWARDED-PROTO which I understand is the right name (dashes instead of underscores).
That is why Laravel (Symfony in reality) was discarding the header from the request.
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.