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 a client example #3

Open
johanbrandhorst opened this issue Apr 6, 2017 · 5 comments
Open

Add a client example #3

johanbrandhorst opened this issue Apr 6, 2017 · 5 comments

Comments

@johanbrandhorst
Copy link
Collaborator

Either using gopherjs or pure JS, just to illustrate how the MethodOverrideParam interacts with the grpc-gateway exposed gRPC methods. Probably an example of authentication too would be nice.

@prince-mishra
Copy link

prince-mishra commented May 30, 2017

@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?

@johanbrandhorst
Copy link
Collaborator Author

@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.

@prince-mishra
Copy link

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

@prince-mishra
Copy link

prince-mishra commented May 30, 2017

@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?

@johanbrandhorst
Copy link
Collaborator Author

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.

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

No branches or pull requests

2 participants