Node.js2 minutes to read

Does a Node.js background worker need a port or domain?

Choose a worker for outbound queue consumers and event listeners. Test one message end to end and use acknowledgements to recover work after a restart.

Which side opens the connection?

A Node.js background worker on Bothosting needs no public port or domain when it opens its own outbound connection to a queue, provider or event stream. Choose Always-on worker. If a provider needs to deliver a webhook to your application over HTTPS, choose an HTTP deployment with an incoming route. Compare the Node.js process types.

Consider a thumbnail service. Its web API accepts an image and adds a task to a queue. The thumbnail worker waits for the next task, saves the resized image, then acknowledges the task. Only the web API needs an address that visitors can reach. The worker needs a queue address and its own credentials in Variables.

Tell an idle worker from a stopped process

Start with the Node.js worker example. It prints a timestamp at startup and once per minute. Wait for a second timestamp to confirm that the process survived initialization. With your own consumer, log when the queue connection succeeds and when a test item finishes. Keep a job ID in each line so you can follow a single item through the system.

A script that registers no listeners, timers or other active work may exit immediately. If its purpose is to process one batch and finish, choose a one-off script and inspect the result in Runs.

Test what happens to unfinished work

Put one test image into a development queue and confirm the output and acknowledgement. Then repeat with a second image and stop the worker partway through processing. On restart, check how the queue handles an unacknowledged task. Use the task ID when naming the finished thumbnail so a redelivery can find an existing result. The queue’s acknowledgement and retry settings determine how unfinished work comes back.