DEV Community

Wojtek Siudzinski
Wojtek Siudzinski

Posted on • Originally published at suda.pl on

Spinning up a free IPFS webrtc-star discovery server with Heroku

Spinning up a free IPFS webrtc-star discovery server with Heroku

While building the Web Microphone app with IPFS I sumbled upon an error when trying to use older examples but using the latest js-ipfs:

Error: no valid addresses were provided for transports [WebSockets,WebRTCStar,Circuit]

It got me puzzled but Vasco cleared it out in this thread:

It turns out that it's necessary to use a new discovery mechanism, webrtc-star. This seemed like an easy way to fix it, just change the server to the hosted randezvous server mentioned in readme and we're done! But nothing is ever that easy. It was failing for me with a 500 error and I shouldn't be surprised as the documentation clearly states:

it should not be used for apps in production

The recommended route is to deploy it on your own. So I tried to get it done in shortes amount of time and preferably without a need to pay for the whole server. Fortunately, Heroku supports Docker containers now and they can be deployed literally with couple of lines! Here's how you do it:

Instructions

First install the Heroku CLI and then run:

# Login to Heroku
$ heroku login
# Login to the Container Registry
$ heroku container:login
# Clone the webrtc-star repo
$ git clone https://github.com/libp2p/js-libp2p-webrtc-star.git
$ cd js-libp2p-webrtc-star
# Create a Heroku app
$ heroku create
# Build and push the image
$ heroku container:push web
# Release the image to your app
$ heroku container:release web
# Scale to one free worker
$ heroku ps:scale web=1
# Open the app in the browser
$ heroku open

Now the server should welcome you with its address:

Spinning up a free IPFS webrtc-star discovery server with Heroku

Use this address in your IPFS app and you're done!

Top comments (0)