我正在尝试使用Hprose在Go中实现RPC服务器。它工作正常,但是在添加了更多功能之后却没有:/
有趣的是,即使在其他http库(例如fasthttp)上,它也不起作用。ListenAndServe()方法似乎在执行过程中被卡在某个位置,因为它永远不会返回。可能是什么原因造成的?
package main
import (
"net/http"
"fmt"
"github.com/hprose/hprose-golang/rpc"
log "logutil"
)
func main() {
log.InitializeLogger()
InitializeEthClient()
InitializeClients()
server := rpc.NewHTTPService()
// TxtStorage functions
server.AddFunction("DeployTxtStorage", DeployNewTxtStorage)
server.AddFunction("GetPackedData", GetPackedData)
server.AddFunction("GetReputation", GetReputation)
server.AddFunction("GetEventsForReputation", GetEventsForReputation)
server.AddFunction("GetEventsForData", GetEventsForData)
// Clients functions
server.AddFunction("RegisterClient", RegisterClient)
log.Info("Registered server functions!")
err := http.ListenAndServe(":8080", server)
fmt.Println(err)
log.Info("Waiting for incoming connections...")
log.WriteAway()
}
胡说叔叔
相关分类