abagshaw abagshaw - 1 year ago 135
Node.js Question

Trying to install deepstream.io on heroku

I've spent the past hour banging my head against a wall trying to get a

server up and running on heroku with no success.

I've tried using the following: https://github.com/deepstreamIO/ds-demo-heroku

I've cloned that repo exactly with no modifications whatsoever and placed it in my own repo which my heroku app pulls from. When heroku tries to build it and run it I see this in my logs:

enter image description here

And that's the end of that. What am I doing wrong?

Sidenote: I have read that Heroku does not allow any desired port to be left open for apps, but it passes one that an app can use in the
variable? If this is correct, how would this work in a production environment where endpoints need to connect reliably to a server at a specific port. If for some reason the server app crashed, was restarted and then Heroku assigned it a different port now all the endpoints would be unable to connect.

Secondly, it appears that deepstream.io requires two ports to be specified (one for TCP incomming traffic and the other from "browser" traffic, see https://deepstream.io/tutorials/core/getting-started-quickstart/). If Heroku only provides one port that the app can bind to how can deepstream.io work if it requires two?

Any help is much appreciated - thanks!

Answer Source

The error is Error invalid schema, expected mongodb. You see it in the logs.

To get this setup working you need to set an environment variable: MONGODB_URI which is used in the configuration file

This repo was created in combination with a tutorial which is not published yet, I didn't expect that someone will try it before :)

So I just put the tutorial now into the readme: https://github.com/deepstreamIO/ds-demo-heroku

To solve your issue you could just disable the cache and storage connector in your config file or read the tutorial and do all the steps.

Sidenote 1:

The $PORT is an internal port which is assigned automatically by heroku. You should always use the external port which is always 80 for web applications. The internal port will only work within your app. This is also explained in the tutorial.

Sidenote 2:

Deepstream provides connections via HTTP websocket and TCP socket. You're right, you can't use both ports with heroku, because heroku doesn't allow you to manage more than one port. Actually heroku also does NOT allow TCP connections at all. You can just use the HTTP websocket connection, which can be used by browsers and via Node.js (after this issue is fixed).

You need TCP socket connections only if performance is very important to you. But in that case you should move from heroku to another provider anyways ;) This part is also mentioned in the tutorial.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download