I created a RPC server using the basic instructions listed here: https://golang.org/pkg/net/rpc/. I am building a application that might not be in Go to communicate with a RPC server and was curious how to manually connect to the server using curl or anything else.
I have tried:
curl -v -X CONNECT --url localhost:1234/_goRPC
but the output I get is:
* Hostname was NOT found in DNS cache
* Trying ::1...
* Connected to localhost (::1) port 1234 (#0)
> CONNECT /_goRPC HTTP/1.1
> User-Agent: curl/7.37.1
> Host: localhost:1234
> Accept: */*
>
< HTTP/1.1 404 Not Found
< Content-Type: text/plain; charset=utf-8
< Date: Tue, 29 Sep 2015 15:04:29 GMT
< Content-Length: 19
<
404 page not found
* Connection #0 to host localhost left intact
This is mainly more to understand how to connect to it language agnostically, in the future I will most likely be using libraries from whatever language to communicate to the server.
Edit: for the above error, the url is actually localhost:1234/goRPC
But the question still remains to how to create a curl request that performs the same functionality as in the link https://golang.org/pkg/net/rpc/ that the client performs. How does the method call and arguments get serialized and placed in the CONNECT request
For anyone wondering, it is easier to use JSONRPC from the rpc/jsonrpc library and the curl request looks like:
curl -X CONNECT --url <url>/_goRPC_ -d '{"method":"your rpc method","params":["args"],"id":<some number to represent your request>}'