Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DOMException: An invalid or illegal string was specified #194

Closed
siegfried opened this issue Mar 21, 2022 · 4 comments
Closed

DOMException: An invalid or illegal string was specified #194

siegfried opened this issue Mar 21, 2022 · 4 comments
Labels
bug Something isn't working client/TypeScript Issues which regard the TypeScript client help welcomed Good for newcomers

Comments

@siegfried
Copy link
Contributor

I cannot create a InteractionContext in browser (Latest Firefox and Chrome). After a while of troubleshooting, I believe the issue lies here.

I tried this successfully in browser console:

new WebSocket('ws://localhost:1338')

This gives the error: Uncaught DOMException: An invalid or illegal string was specified

new WebSocket('ws://localhost:1338', { maxPayload: 128 * 1024 * 1024 })
@KtorZ
Copy link
Member

KtorZ commented Mar 21, 2022

Eew. Yes, the so-called "isomorphic" Javascript WebSockets aren't quite isomorphic. We resorted to building our own wrapper around the websocket API to cover both browser and node. Note however that the browser support in the TypeScript client is only a best effort as Ogmios is mostly intended to be used server-side in a controlled environment.

@KtorZ KtorZ added bug Something isn't working help welcomed Good for newcomers client/TypeScript Issues which regard the TypeScript client labels Mar 21, 2022
@siegfried
Copy link
Contributor Author

So is Ogmios not supposed to be exposed to the public?

@KtorZ
Copy link
Member

KtorZ commented Mar 22, 2022

@siegfried in principle no; Ogmios exposes the cardano-node's node-to-client protocols which have been designed to be local protocols between a limited set of clients and one node acting as a server. Some protocols are quite heavy on the node (for example, the chain-sync protocol can drive the node at 200% CPU for an extended period of time).

This isn't a security risk though, but more of a resource constraint issue. We've been experimenting having hundreds of clients connected to a node. And while this works, it is quite slow (especially if all clients are doing chain-sync). So in general, no, exposing an instance over the public internet is not a good idea unless you are in a somewhat controlled environment or, unless there's way to spread the load over many relays.

One thing I still envision in the long-run are relays running and exposing Ogmios for clients. If we take a gross approximation of 100 clients per relay, with a thousand of relays we can already get into serving a reasonable number of clients; provided that the clients have some load-balancing logic allowing them to pick a relay that isn't too busy.

Spinning up new relays on-demand to cope with spikes should also be relatively easy.

@KtorZ
Copy link
Member

KtorZ commented Mar 22, 2022

Fixed in #195

@KtorZ KtorZ closed this as completed Mar 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working client/TypeScript Issues which regard the TypeScript client help welcomed Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants