{"action":"created","issue":{"url":"https://api.github.com/repos/hashicorp/raft/issues/246","repository_url":"https://api.github.com/repos/hashicorp/raft","labels_url":"https://api.github.com/repos/hashicorp/raft/issues/246/labels{/name}","comments_url":"https://api.github.com/repos/hashicorp/raft/issues/246/comments","events_url":"https://api.github.com/repos/hashicorp/raft/issues/246/events","html_url":"https://github.com/hashicorp/raft/issues/246","id":254837010,"number":246,"title":"Failed to decode incoming command: unknown rpc type 80","user":{"login":"s4ayub","id":16456972,"avatar_url":"https://avatars1.githubusercontent.com/u/16456972?v=4","gravatar_id":"","url":"https://api.github.com/users/s4ayub","html_url":"https://github.com/s4ayub","followers_url":"https://api.github.com/users/s4ayub/followers","following_url":"https://api.github.com/users/s4ayub/following{/other_user}","gists_url":"https://api.github.com/users/s4ayub/gists{/gist_id}","starred_url":"https://api.github.com/users/s4ayub/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/s4ayub/subscriptions","organizations_url":"https://api.github.com/users/s4ayub/orgs","repos_url":"https://api.github.com/users/s4ayub/repos","events_url":"https://api.github.com/users/s4ayub/events{/privacy}","received_events_url":"https://api.github.com/users/s4ayub/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2017-09-02T21:27:35Z","updated_at":"2017-09-02T22:55:19Z","closed_at":"2017-09-02T22:55:19Z","author_association":"NONE","body":"I was trying out:\r\n(hraftd)[https://github.com/otoolep/hraftd]\r\n\r\nWhich is a simple implementation of a dist. key value store using hashicorp/raft. When trying to set a key, I received the following error:\r\n```\r\n2017/09/02 17:19:05 [DEBUG] raft-net: :12000 accepted connection from: [::1]:56220\r\n2017/09/02 17:19:05 [ERR] raft-net: Failed to decode incoming command: unknown rpc type 80\r\n```\r\nI was thinking this was an error with the implementation and not hashicorp/raft, but then I tried to make my own simple dist. key value store with a slightly different implementation and I received the same error when making a request to the raft server. \r\n\r\nMy methods look like the following: \r\n``` Go\r\n// Set routes to handle operations on raft servers\r\nrs.router.HandleFunc(\"/raftkv_set\", rs.redirectedSet)\r\n```\r\n---\r\n```Go\r\n// Set sets the value for the given key.\r\nfunc (rs *RaftStore) Set(key, value string) error {\r\n\tm := map[string]string{key: value}\r\n\r\n  var b bytes.Buffer\r\n\tif err := json.NewEncoder(&b).Encode(m); err != nil {\r\n\t\treturn err\r\n\t}\r\n\r\n\t_, err := rs.redirectToLeader(rs.Leader(), \"raftkv_set\", b)\r\n\treturn err\r\n}\r\n```\r\n---\r\n```Go\r\n// Redirects the request to the leader\r\nfunc (rs *RaftStore) redirectToLeader(leader, op string, command bytes.Buffer) ([]byte, error) {\r\n\treply, err := processRequest(fmt.Sprintf(\"http://%s/%s\", rs.RaftServer.Leader(), op), \"application/json\", &command)\r\n  if err != nil {\r\n\t\treturn nil, err\r\n\t}\r\n\r\n\treturn reply, nil\r\n}\r\n```\r\n---\r\n**This is where the process messes up, when posting to the server, it doesn't get to the route**\r\n```Go\r\nfunc processRequest(target string, contentType string, b *bytes.Buffer) ([]byte, error) {\r\n\tresp, err := http.Post(target, contentType, b)\r\n\tif err != nil {\r\n\t\treturn nil, err\r\n\t}\r\n\tdefer resp.Body.Close()\r\n\r\n\treply, _ := ioutil.ReadAll(resp.Body)\r\n\tstatusCode := resp.StatusCode\r\n\tif statusCode != http.StatusOK {\r\n\t\treturn nil, errors.New(string(reply))\r\n\t}\r\n\r\n\treturn reply, nil\r\n}\r\n```\r\n---\r\n```Go\r\n// The function that isn't being hit after the post request which applies the command\r\nfunc (rs *RaftStore) redirectedSet(w http.ResponseWriter, req *http.Request) {\r\n\tm := map[string]string{}\r\n\tif err := json.NewDecoder(req.Body).Decode(&m); err != nil {\r\n\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\r\n\t\treturn\r\n\t}\r\n  fmt.Println(m)\r\n\r\n\tc := &command{\r\n\t\tOp:    \"set\",\r\n\t\tKey:   m[\"key\"],\r\n\t\tValue: m[\"value\"],\r\n\t}\r\n\tb, err := json.Marshal(c)\r\n\tif err != nil {\r\n\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\r\n\t\treturn\r\n\t}\r\n\r\n\trs.RaftServer.Apply(b, raftTimeout)\r\n}\r\n```"},"comment":{"url":"https://api.github.com/repos/hashicorp/raft/issues/comments/326773629","html_url":"https://github.com/hashicorp/raft/issues/246#issuecomment-326773629","issue_url":"https://api.github.com/repos/hashicorp/raft/issues/246","id":326773629,"user":{"login":"s4ayub","id":16456972,"avatar_url":"https://avatars1.githubusercontent.com/u/16456972?v=4","gravatar_id":"","url":"https://api.github.com/users/s4ayub","html_url":"https://github.com/s4ayub","followers_url":"https://api.github.com/users/s4ayub/followers","following_url":"https://api.github.com/users/s4ayub/following{/other_user}","gists_url":"https://api.github.com/users/s4ayub/gists{/gist_id}","starred_url":"https://api.github.com/users/s4ayub/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/s4ayub/subscriptions","organizations_url":"https://api.github.com/users/s4ayub/orgs","repos_url":"https://api.github.com/users/s4ayub/repos","events_url":"https://api.github.com/users/s4ayub/events{/privacy}","received_events_url":"https://api.github.com/users/s4ayub/received_events","type":"User","site_admin":false},"created_at":"2017-09-02T22:55:19Z","updated_at":"2017-09-02T22:55:19Z","author_association":"NONE","body":"@otoolep addressed this in hraftd, thank you!"}}
{"actor":{"display_login":"s4ayub"}}