Reputation: 11430
I have a background application that caches data from websocket stream, do some calculations on it and sends out the data via REST APIs and/or (to be decided) another outgoing websocket stream.
I have another frontend application that consumes the API and/or websocket stream and display data in the browser.
I have successfully deployed the frontend as "web" and the backend as "worker", but I can't seem to find the setting to make the worker accessible via Heroku app URL.
How can I deploy the applications on Heroku such that a backend URL exists for my frontend app to access and connect to?
Upvotes: 2
Views: 1593
Reputation: 320
Simply put, a worker dyno cannot be accessed over HTTP. Only web dynos can. From heroku's documentation:
Web: Web dynos are dynos of the “web” process type that is defined in your Procfile. Only web dynos receive HTTP traffic from the routers.
https://devcenter.heroku.com/articles/dynos#dyno-configurations
In your case, you might be better creating a separate web dyno for your front end, an another one for your server. Or, you could run both under the same dyno and domain. For instance, an express/node/react app.
Upvotes: 0
Reputation: 5261
If you are using Heroku Private Spaces then you could enable Dyno DNS Service Discovery that would allow your web dyno to send jobs to your worker dyno via its DNS name. That is not possible, however (as far as I know), in the Common Runtime.
Furthermore, even in Private Spaces, I'm not sure if your front end app could directly access a backend URL for your worker.
Instead, the front end app accesses the web dyno(s) via the app URL. The web dyno can then enqueue jobs for worker dynos using various messaging schemes, as described here.
Upvotes: 1