How to force websockets on Firebase 9?

Before Firebase 9, you could force websockets instead of long polling. After upgrading to 9, we can’t get long-polling working, even after loosening out content security policy a lot. What’s the right approach to enable this?

We used to be able to enable this easily with: database.app.firebase_.database.INTERNAL.forceWebSockets()


Related to this question but the answer requires hardcoding ws:// instead of http:// (and further says this is not recommended.)

Our code is shared across platforms and we need to be able to force websockets on one platform while leaving the values untouched on another.