Javascript libraries for WebSocket-over-HTTP in Compute@Edge

There are many JavaScript libraries that support WebSocket-over-HTTP. They work well locally with Pushpin but fail when running in Fastly Compute@Edge. Which JavaScript library in the following can run well in Fastly Compute, and is there any code sample for WebSocket-over-HTTP dedicated to Fastly Compute? Many thanks.

And I try to use js-grip-compute-js and js-serve-grip-expressly in the Fiddle, but the dependency @fastly/grip-compute-js and @fastly/serve-grip-expressly are not available on Fiddle. Could these two libraries run well in fastly compute?

Hi, thanks for reaching out.

It turns out all four of these can be used with Fastly Compute + Fastly Fanout. You can enable Fanout for your account with the information given on the Fanout page on the Fastly Developer site.

You’ll need one Fastly Compute service that does a “Fanout Handoff” - This will basically behave as your “cloud Pushpin” instance, and will hold your visitors’ connections around the world. We currently support “handoff” in JavaScript and Rust, so you can create your service in either of these languages. In fact we have fully functional starter kits for this purpose, so you can use these, set them up with backends, and be done with it.

You’ll also need a backend server that runs your application. This can be in any language and run on any server so long as it speaks GRIP - the protocol that Fanout uses.

For example, if you use JavaScript on Node, you can use js-grip and js-serve-grip.

If you use JavaScript on Fastly Compute, you can use js-grip and js-serve-grip together with grip-compute-js and serve-grip-expressly. You can see an example of this in our demo application at GitHub - fastly/fanout-compute-js-demo: Fanout Fastly Compute JavaScript demo.

Fiddle can’t currently be used in either of these roles (neither the handoff nor the backend), so these libraries can’t be used there. If we do one day support Fanout on Fiddle then they will become available.

I hope this clears things up but please feel free to follow up with additional questions.


Here are links to the starter kits that I mentioned: