grpc-web-devtools icon indicating copy to clipboard operation
grpc-web-devtools copied to clipboard

compatibility with Improbable grpc-web library

Open kinotto opened this issue 5 years ago • 2 comments

Hello, i was wondering if you're going to add support for the Improbable grpc-web library https://github.com/improbable-eng/grpc-web

at the moment it doesn't seem to work,

Thank you.

kinotto avatar Apr 23 '20 16:04 kinotto

This was specifically designed for use with the official version of grpc-web I think the improbable version uses different set of transports (fetch, websockets etc) so would be not have the same "hooks" as the official version. There is also thoughts on using the new Client Interceptor API to provide this, but again for it to work with improbable, it would have to have the same API.

If anyone is keen to research the possibilities, open to any PRs

rogchap avatar May 27 '20 06:05 rogchap

Improbable supports interceptors as well as grpc-web by Google Here is the code snippet to use interceptor with improbable :

function noopWrapTransport(t: Transport): Transport
{
    return <Transport>{
        cancel: t.cancel.bind(t),
        finishSend: t.finishSend.bind(t),
        sendMessage: t.sendMessage.bind(t),
        start:  t.start.bind(t)
    };
}

new MyServiceClient(url,
      <grpc.RpcOptions>{transport: options => noopWrapTransport(grpc.CrossBrowserHttpTransport({withCredentials: false})(options))}
                    );

jvmlet avatar Jun 30 '20 10:06 jvmlet