2

Here is an issue I am having with an app on Parse-Server (/Heroku).

I keep getting the message:

WARNING, Unable to connect to 'https://myapp.herokuapp.com/'. Cloud code and push notifications may be unavailable!

Here is the complete log I have when running the command: git push heroku master

2018-02-2...+00:00 app[api]: Build started by user me@xyz.com
2018-02-2...+00:00 app[api]: Deploy bduxedc8 by user me@xyz.com
2018-02-2...+00:00 app[api]: Build succeeded
2018-02-2...+00:00 app[api]: Release v25 created by user me@xyz.com
2018-02-2...+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2018-02-2...+00:00 heroku[web.1]: Process exited with status 143
2018-02-2...+00:00 heroku[web.1]: Restarting
2018-02-2...+00:00 heroku[web.1]: State changed from up to starting
2018-02-2...+00:00 heroku[web.1]: Starting process with command `npm start`
2018-02-2...+00:00 app[web.1]: 
2018-02-2...+00:00 app[web.1]: > parse-server-example@1.4.0 start /app
2018-02-2...+00:00 app[web.1]: > node index.js
2018-02-2...+00:00 app[web.1]: 
2018-02-2...+00:00 app[web.1]: parse-server-example running on port 23377.
2018-02-2...+00:00 heroku[web.1]: State changed from starting to up
2018-02-2...+00:00 heroku[router]: at=info method=GET path="/health" host=myapp.herokuapp.com request_id=fb429287-9b14-4373-97ab-30dac19a4db7 fwd="1.2.3.438" dyno=web.1 connect=2ms service=20ms status=404 bytes=217 protocol=https
2018-02-28T04:03:21.595649+00:00 app[web.1]: 
2018-02-28T04:03:21.595660+00:00 app[web.1]: WARNING, Unable to connect to 'https://myapp.herokuapp.com/'. Cloud code and push notifications may be unavailable!
2018-02-28T04:03:21.595663+00:00 app[web.1]: 

And if I change https to http in my configuration, I see exactly the same behavior.

Beside if I try to access to https://myapp.herokuapp.com/ in a browser I can do it with no problem.

I have read many post on the issue but nothing drove me to a solution. That would be great if someone could let me know how to solve this.

Michel
  • 10,303
  • 17
  • 82
  • 179

2 Answers2

2

I faced this issue and it might help someone in the future.

Note that this is one of the reasons why this warning might be thrown. This is for parse server version: 2.8.2

To create your own standalone parse server, using express, the basic steps involved are close to:

  1. Create a parse-server object with all your config like. For example: const api = new ParseServer(config);
  2. config will contain the server URL along with all other requirements.
  3. Create an express app object. For example: const app = express();
  4. Then mount the parse server API on the express like -> app.use(mountPath, api);
  5. And then create the server like: const httpServer = require('http').createServer(app);
  6. And then start listening on a port like: httpServer.listen(port);

As soon as the mount is called, the parse-server will verify the url mentioned in the config by making a request to /health endpoint.

If for some reason there is a delay in listening to the port (point 6) after mounting the API (point 4), then the above warning will be thrown.

For example, in one case I was establishing a mongoose connection and only then started listening to the port. Because of this, the verification of URL from parse server failed, although everything worked fine after that.

And one of the possible solutions is to get done with all such work before mounting the parse API and ensuring no delay between mounting and listening to the port as described above.

While this may not be the exact steps for creating a parse server on heroku, the idea is that:

parse server will call verify url on the server url mentioned in the configs.

And if there is delay in starting the server after you have mouted the parse apis, the above warning will be thrown.

daksh_019
  • 802
  • 7
  • 16
0

2018-02-2...+00:00 heroku[router]: at=info method=GET path="/health" host=myapp.herokuapp.com request_id=fb429287-9b14-4373-97ab-30dac19a4db7 fwd="1.2.3.438" dyno=web.1 connect=2ms service=20ms status=404 bytes=217 protocol=https

Notice status is 404, this doesn't exist, and the host says myapp.herokuapp.com

Do you perhaps have a server_url key set to literally myapp.heroku.com, or did you redact the name of your app?

Jake T.
  • 4,308
  • 2
  • 20
  • 48
  • I can access https://myapp.herokuapp.com/ ("myapp" is fake, but the real name works) in a browser, so why do I get this 404 that you are mentioning is my question.... In the meanwhile the problem has vanished, I do not exactly know why. Anyway, thank you for your help. – Michel Mar 01 '18 at 02:41
  • Sorry, I meant it does not necessarily prevent the system from working, but I still get this strange message. I don't know why. – Michel Mar 01 '18 at 03:15