Bluehouse-Technology / grpc

Erlang library for GRPC
Apache License 2.0
100 stars 38 forks source link

Failed to create stream #20

Open kchrome opened 2 years ago

kchrome commented 2 years ago

Following the tutorial I try to run my own service and get an error. What could I have done wrong?

{ok, Connection} = grpc_client:connect(tcp, "localhost", 10000).
{ok, Stream} = grpc_client:new_stream(Connection, 'Send', 'SendMessage', speak).

** exception error: no match of right hand side value {error,<<"failed to create stream">>}

speak.proto

syntax = "proto3";

  option java_multiple_files = true;

package Send;

service Send {

rpc SendMessage(Message) returns (readReciept) {}

}

message Message {

string messageContent = 1;

}

message readReciept {

string reciept = 1;

}

speak_client.erl

-module(speak_client).

%% this file was generated by grpc

-export(['SendMessage'/3]).

-type 'Message'() ::
    #{messageContent => string()}.

-type readReciept() ::
    #{reciept => string()}.

-export_type(['Message'/0,
              readReciept/0]).

-spec decoder() -> module().
%% The module (generated by gpb) used to encode and decode protobuf
%% messages.
decoder() -> speak.

%% RPCs for service 'Send'

-spec 'SendMessage'(
        Connection::grpc_client:connection(),
        Message::'Message'(),
        Options::[grpc_client:stream_option() |
                  {timeout, timeout()}]) ->
        grpc_client:unary_response(readReciept()).
%% This is a unary RPC
'SendMessage'(Connection, Message, Options) ->
    grpc_client:unary(Connection, Message,
                      'Send', 'SendMessage',
                       decoder(), Options).