I'm trying to implement a RPC server in Go using Hprose. It worked fine but then after adding some more functions it didn't :/
Funny thing is that it doesn't work even on other http libraries such as fasthttp. The ListenAndServe() method just seems to be stuck somewhere during execution as it never returns. What might be causing this?
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()
}
ListenAndServe is blocking, it won't return unless it hits an error. You seem to be expecting your final lines to print out
Waiting for incoming connections...
But that will never happen as the server is running. Are you sure it isn't just working as expected?