2
13 Comments

Cheap solution for websockets

Hello everyone !
I am currently developing a click and collect tool, hosted on netlify.

Everything was wonderful until now. I need websockets to play a little ringtone on my clients backoffice everytime their clients placed a new order. And netlify doesn't support them :'( .

I can use amazon websocket service only for this function, I can move my entire backend to heroku so that I could use websockets, or I can move my entire backend to amazon elastic beanstalk (a bit overkill for a mvp in my opinion) .

I may just use my existing heroku instance I use for another project, add a code to handle these websocket requests on it, and it may be enough for now.

To indie hackers who needed websocket on their mvp. What did you choose ? What is the cheapest / quickest solution to get this in your opinion ?

Take care

posted to Icon for group Developers
Developers
on December 25, 2020
  1. 3

    Web sockets are not a must for your case. You can create http polling to check notifications.

  2. 2

    Honestly, if it's for an MVP I would just add a timer that makes a request every couple of seconds against the backend and checks if there's a new order 😁

    You could also use long polling requests. In this case you make a request to the backend and have the backend leave it open for a long time. During this time, if something new comes up, the backend appends that event to the request stream (so the frontend gets it "real time"). Whenever the request times out, you open a new one. You can use socket.io to help you with this

    1. 1

      What I don’t like with long polling is that it will consume a lot of computing time (and money) on my lambdas. I think I’ll go with a call each minute for now. Nothing fancy or scalable but it’ll do the job with no pain

      1. 1

        You can configure your API gateway to cache requests up to a few minutes. If you share a response between multiple users you can take off some load from your lambdas

  3. 2

    IMO, good idea to use websockets since UX will be better if notifications are real time. I dunno about Netlify, but like, I just run my own backend http server - the client connects to it and there's communication over websockets. May be store static assets on a CDN / netlify and create your own backend for websockets?

  4. 1

    I had a similar requirement and ended up using Digital Ocean's App service. You can deploy/ build directly from git and is a cost effective (and simple) method for persisting a websocket.

    I played with AWS Elastic Beanstalk/ Cloudformation templates a lot but never got a satisfactory setup.

  5. 1

    For now, you could use the free tier of Pusher Channels.

  6. 1

    Definitely avoid elastic beanstalk. It will not ace you time. In my experience with it, it felt like a feature that AWS had largely abandoned but can’t sunset because it has too many legacy users.

    What about using a third party service like pubnub? (Not necessarily recommending them, they’re just the only name I recall). If you go that route, you don’t need to spin up any new infra, you just fire events in your backend using their SDK and subscribe to those events in your front end. All the hard parts are handled by a company claiming to be a domain expert.

    1. 2

      Also, vendor lockin shouldn’t be a huge issue with a bit of abstraction; it ought to be fairly straightforward to swap in alternative provider since it’s just pubsub.

  7. 1

    If you happen to use the .NET stack, go SignalR, otherwise go socket.io.

  8. 1

    You could use: https://github.com/nicolasgere/tawny I can help to integrate it, but it will basically provide you exactly what you want. I'm the creator.

  9. 4

    This comment was deleted 3 years ago.

Trending on Indie Hackers
I built a tool that shows what a contract could cost you before signing User Avatar 113 comments The coordination tax: six years watching a one-day feature take four months User Avatar 74 comments My users are making my product better without knowing it. Here's how I designed that. User Avatar 64 comments A simple LinkedIn prospecting trick that improved our lead quality User Avatar 52 comments I changed AIagent2 from dashboard-first to chat-first. Does this feel clearer? User Avatar 39 comments Why I built a SaaS for online front-end projects that need more than a playground User Avatar 17 comments