I have a working RPC TCP service written in Go, but when using Ruby to
connect to the service it hangs because no data appears to be sent back
through the open socket connection.

Remote RPC Function:

     package remote

     import "fmt"

     // Compose is our RPC functions return type
     type Compose string

     // Details is our exposed RPC function
     func (c *Compose) Details(arg string, reply *string) error {
         fmt.Printf("Arg received: %+v\n", arg)
         *c = "some value"
         *reply = "Blah!"
         return nil

Remote RPC Endpoint Exposed:

     package remote

     import (

     // Endpoint exposes our RPC over TCP service
     func Endpoint() {
         compose := new(Compose)

         listener, err := net.Listen("tcp", ":8080")
         // error handling omitted

         for {
             conn, err := listener.Accept()
             // error handling omitted

             go rpc.ServeConn(conn)

Client Connection over TCP to Remote RPC function (using Golang so I know
it works at least in that respect):

     package main

     import (

     func main() {
         client, err := rpc.Dial("tcp", "localhost:8080")
         if err != nil {
             log.Fatal("dialing:", err)

         var reply string

         e := client.Call("Compose.Details", "my string", &reply)
         if e != nil {
             log.Fatalf("Something went wrong: %v", e.Error())

         fmt.Printf("The 'reply' pointer value has been changed to: %s",

Here is the Ruby code I'm attempting to use:

     require "socket"
     require "json"

     socket = TCPSocket.new "localhost", "8080"

     b = {
       method: "Compose.Details",
       params: "foobar"


     resp = JSON.load(socket.readline)

     p resp

The reason I think it doesn't work is because the Go RPC requires a pointer
to be provided as the second argument to the exposed RPC function but I'm
not sure how that works in a different programming language such as Ruby?

I've also tried utilising a library such as

     require "jimson"

     client = Jimson::Client.new("localhost:8080")
     result = client.Details("foobar")

But all I get back is:

     RestClient::ServerBrokeConnection: Server broke connection

You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Search Discussions

Discussion Posts

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 1 of 7 | next ›
Discussion Overview
groupgolang-nuts @
postedFeb 15, '16 at 12:39p
activeFeb 18, '16 at 10:01a



site design / logo © 2022 Grokbase