build of rpc fails test

269 views
Skip to first unread message

Hans

unread,
Nov 15, 2009, 4:18:36 AM11/15/09
to golang-nuts
Hi,

I've been trying to play with the rpc package without any luck, and
then noticed that the rpc package is not really passing its tests when
it gets built.

I see the following when I build Go:

gopack grc _test/rpc.a _gotest_.6
make[2]: Leaving directory `/home/hans/GoRoot/src/pkg/rpc'
2009/11/15 00:56:28 Test RPC server listening on [::]:38326
2009/11/15 00:56:28 Test HTTP RPC server listening on [::]:37240
2009/11/15 00:56:28 rpc: client protocol error: gob: type mismatch: no
fields matched compiling decoder for Reply
2009/11/15 00:56:28 rpc: client protocol error: gob: type mismatch: no
fields matched compiling decoder for Reply
2009/11/15 00:56:28 rpc: tearing down Arith connection: gob: type
mismatch: no fields matched compiling decoder for Args
PASS
make[1]: Leaving directory `/home/hans/GoRoot/src/pkg/rpc'

Russ Cox

unread,
Nov 15, 2009, 4:31:22 AM11/15/09
to Hans, golang-nuts
> I see the following when I build Go:
>
> gopack grc _test/rpc.a _gotest_.6
> make[2]: Leaving directory `/home/hans/GoRoot/src/pkg/rpc'
> 2009/11/15 00:56:28 Test RPC server listening on  [::]:38326
> 2009/11/15 00:56:28 Test HTTP RPC server listening on  [::]:37240
> 2009/11/15 00:56:28 rpc: client protocol error: gob: type mismatch: no
> fields matched compiling decoder for Reply
> 2009/11/15 00:56:28 rpc: client protocol error: gob: type mismatch: no
> fields matched compiling decoder for Reply
> 2009/11/15 00:56:28 rpc: tearing down Arith connection: gob: type
> mismatch: no fields matched compiling decoder for Args
> PASS
> make[1]: Leaving directory `/home/hans/GoRoot/src/pkg/rpc'

Those error messages are printed because the test
is exercising error cases in the implementation.
I believe the test is passing.

Can you give more detail about what's not working for
you in the rpc package?

Russ

Hans

unread,
Nov 15, 2009, 11:54:36 AM11/15/09
to golang-nuts
Yes, I made a small program that is almost identical to the example
given in the rpc package documentation.

When I run the client I get this:
2009/11/15 01:26:02 rpc: client protocol error: gob: internal error:
field numbers out of bounds
2009/11/15 01:26:02 error: gob: internal error: field numbers out of
bounds



type Args struct
{
Cmd, Arg int;
}

type Result struct
{
StdOut int;
}

//client
func main()
{
client, err := rpc.DialHTTP("tcp", "127.0.0.1:2000");
if err != nil
{
log.Exit("dialing:", err);
}
// Synchronous call
args := &commands.Args{1,2};
reply := new(commands.Result);

fmt.Println("calling");
err = client.Call("Server.Execute", args, reply);
if err != nil
{
log.Exit("error: ", err);
}
fmt.Println(reply.StdOut);
}

//server

func main()
{
cmdsvr := new(commands.Server);
rpc.Register(cmdsvr);
rpc.HandleHTTP();
l, e := net.Listen("tcp", ":2000");
if e != nil
{
log.Exit("listen error: ", e);
}
http.Serve(l, nil);
}

Rob 'Commander' Pike

unread,
Nov 15, 2009, 12:01:06 PM11/15/09
to Hans, golang-nuts
The error looks like a bug but there's not enough code here to reproduce it. Can you please send me the complete files or, better yet, include them in a new bug report at golang.org? Thanks.

-rob

Hans

unread,
Nov 15, 2009, 1:08:59 PM11/15/09
to Rob 'Commander' Pike, golang-nuts
I can send it later- I'm away from my computer right now. The only
thing I left out was the function that would get called in the server.
It never gets that far.


On Nov 15, 2009, at 9:01 AM, "Rob 'Commander' Pike" <r...@google.com>
wrote:

Hans

unread,
Nov 15, 2009, 5:22:32 PM11/15/09
to golang-nuts
Ok, here are all my source files.

I want to get a simple rpc example running, so I mostly copied the
example in the rpc package documentation. When I run the server and
then the client on the same machine, I get the following error on the
terminal running the client:

2009/11/15 14:20:29 rpc: client protocol error: gob: internal error:
field numbers out of bounds
2009/11/15 14:20:29 error: gob: internal error: field numbers out of
bounds

I get the following message on the terminal running the server:
2009/11/15 14:20:29 rpc: EOF

//---------------------------------------------------------------
// commands.go
package commands

import "fmt"
import "os"

type Args struct
{
Cmd, Arg int;
}

type Result struct
{
Out int;
}

type Server int

func (t *Server) Execute(args *Args, res *Result) os.Error
{
fmt.Println("params = ", args.Cmd, " ", args.Arg );
res.Out = 2;
return nil
}

//---------------------------------------------------------------
// client.go
package main

import "log"
import "rpc"
import "fmt"
import "./commands"

func main()
{
client, err := rpc.DialHTTP("tcp", "127.0.0.1:2000");
if err != nil
{
log.Exit("dialing:", err);
}

// Synchronous call
args := &commands.Args{1,2};
reply := new(commands.Result);

fmt.Println("calling");
err = client.Call("Server.Execute", args, reply);
if err != nil
{
log.Exit("error: ", err);
}
fmt.Println(reply.Out);
}


//---------------------------------------------------------------
// server.go
package main

import "log"
import "http"
import "net"
import "rpc"
import "./commands"

func main()
{
cmdsvr := new(commands.Server);
rpc.Register(cmdsvr);
rpc.HandleHTTP();
l, e := net.Listen("tcp", ":2000");
if e != nil
{
log.Exit("listen error: ", e);
}
http.Serve(l, nil);
}

I build with these commands:
6g commands.go

6g server.go
6l -o server server.6

6g client.go
6l -o client client.6
Reply all
Reply to author
Forward
0 new messages