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

Add support for custom transports #1277

Open
notmedia opened this issue Sep 15, 2022 · 2 comments
Open

Add support for custom transports #1277

notmedia opened this issue Sep 15, 2022 · 2 comments
Milestone

Comments

@notmedia
Copy link

Hi!

As we know Node.js doesn't support XMLHttpRequest by default.
We can use polyfills and define them globally, for example this comment introduce solution

It works but Server Streaming doesn't work properly - we are receiving messages only when the stream is ended, more info here.

grpcweb allows server streaming methods to be called, but it doesn’t return data until the stream has closed.

I didn't test it in browsers, maybe this problem is only XHR polyfill related. I've tried all polyfills that I could find.

I've looked to @improbable-eng/grpc-web solution, there we can use custom transport and it already has Node.js HTTP transport.
But seems to me this project was abandoned. I've talked with one contributor and he said that he doesn't have any connection to maintainers and the latest version was 10 months ago. He can't publish new versions to npm registry and I think this is a big problem.

So, here we have a great opportunity to make this lib a real standard of gRPC-Web. And it would be great if you provide ability to setup custom transport or at least Node.js HTTP.

For what needs I'm searching for this feature:
First - electron apps which could use this library. Because of Node.js backend inside it's having problems. For example I'm working on desktop gRPC/gRPC-Web client and can't use this library, but really want :)

Second - integration tests written on top of Node.js also could make a good option for testing gRPC-Web requests.

@sampajano
Copy link
Collaborator

@notmedia Hi! Thanks so much for your interest and ideas here! 😃

I think is a good idea and indeed a potential area of improvement!

I wonder if you have any thoughts/preferences on the APIs here? (e.g. i haven't taken a close look at the solution by @improbable-eng/grpc-web, but wonder if something like what they had exactly fits your use case?)

Also, i'm wondering if you're open to contribute code here as well?

Thanks again! :)

@notmedia
Copy link
Author

notmedia commented Sep 17, 2022

Hi! Thanks for the fast reply.

The @improbable-eng/grpc-web has Transport interface which anyone could implement, then pass it to gRPC client constructor and the client would use this transport.

If we will have this setup here, then we could implement http(s) request via system node.js http(s) module.
Also when https is used we need to have ability to provide TLS credentials for Server-Side/Mutual TLS setup like I did here

I looked to the current implementation and seams to me it will take a lot of time to implement this feature. All methods use xhr without any abstraction. And I didn't work with Google Closure Compiler before. Right now I cloned the repo and trying to figure it out how it works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants