Coder Social home page Coder Social logo

Add a client example about grpc-websocket-proxy HOT 5 OPEN

tmc avatar tmc commented on August 28, 2024 6
Add a client example

from grpc-websocket-proxy.

Comments (5)

prince-mishra avatar prince-mishra commented on August 28, 2024

@tmc @johanbrandhorst Can you please add an example client code? I cannot get my head around it. I have a "streamingCall" exposed over gRPC. How do I interact with it once I add the wsproxy?

from grpc-websocket-proxy.

johanbrandhorst avatar johanbrandhorst commented on August 28, 2024

@prince-mishra you'll need to write a websocket client. It'll depend very much on how you're talking to your server. You can look at https://github.com/johanbrandhorst/gopherjs-grpc-websocket/blob/master/client/client.go for a GopherJS example of how to use the websocket.

from grpc-websocket-proxy.

prince-mishra avatar prince-mishra commented on August 28, 2024

@johanbrandhorst Thank you so much! That helps a lot. I'll be testing it out in the browser.

from grpc-websocket-proxy.

prince-mishra avatar prince-mishra commented on August 28, 2024

@johanbrandhorst using your go client code as referrence, I was able to connect and send messages to the proxy layer. The goes like this:

var wsUri = "ws://localhost:8089/v1/bidi";

websocket = new WebSocket(wsUri);

....

websocket.send(message);

This means I need to open new websockets for every API. Is there a way to reuse the websocket on client side? Can I use the existing websocket for /v1/bidi and /api2/bidi2?

from grpc-websocket-proxy.

johanbrandhorst avatar johanbrandhorst commented on August 28, 2024

I'm afraid I don't know enough about websockets, but it appears you'll need to create a new websocket for each API endpoint. Also the connection will be closed when the bidi stream is closed so you'll need to create a new websocket every time to want to make the call.

from grpc-websocket-proxy.

Related Issues (18)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.