diff --git a/protocol/dubbo/hessian2/hessian_request.go b/protocol/dubbo/hessian2/hessian_request.go index 4ebb4aa1be05d4d1941661fed452dda06cf55fa0..2a1d5f736d986d8f23930144140461ad9ba52dc6 100644 --- a/protocol/dubbo/hessian2/hessian_request.go +++ b/protocol/dubbo/hessian2/hessian_request.go @@ -30,6 +30,10 @@ import ( perrors "github.com/pkg/errors" ) +import ( + "github.com/apache/dubbo-go/common/logger" +) + ///////////////////////////////////////// // dubbo ///////////////////////////////////////// @@ -221,10 +225,18 @@ func packRequest(service Service, header DubboHeader, req interface{}) ([]byte, } // dubbo version + path + version + method - encoder.Encode(DEFAULT_DUBBO_PROTOCOL_VERSION) - encoder.Encode(service.Path) - encoder.Encode(service.Version) - encoder.Encode(service.Method) + if err := encoder.Encode(DEFAULT_DUBBO_PROTOCOL_VERSION); err != nil { + logger.Error("Encode(DEFAULT_DUBBO_PROTOCOL_VERSION) = error: %v", err) + } + if err := encoder.Encode(service.Path); err != nil { + logger.Error("Encode(service.Path) = error: %v", err) + } + if err := encoder.Encode(service.Version); err != nil { + logger.Error("Encode(service.Version) = error: %v", err) + } + if err := encoder.Encode(service.Method); err != nil { + logger.Error("Encode(service.Method) = error: %v", err) + } // args = args type list + args value list if types, err = getArgsTypeList(args); err != nil { diff --git a/protocol/jsonrpc/http.go b/protocol/jsonrpc/http.go index 869617ea4eb512df6287d21e9d811145c1944e57..7ab1a8942da62deba17df991c019fc4f71a69366 100644 --- a/protocol/jsonrpc/http.go +++ b/protocol/jsonrpc/http.go @@ -181,15 +181,17 @@ func (c *HTTPClient) Do(addr, path string, httpHeader http.Header, body []byte) return nil, perrors.WithStack(err) } defer tcpConn.Close() - setNetConnTimeout := func(conn net.Conn, timeout time.Duration) { + setNetConnTimeout := func(conn net.Conn, timeout time.Duration) error { t := time.Time{} if timeout > time.Duration(0) { t = time.Now().Add(timeout) } - conn.SetDeadline(t) + return conn.SetDeadline(t) + } + if err := setNetConnTimeout(tcpConn, c.options.HTTPTimeout); err != nil { + return nil, err } - setNetConnTimeout(tcpConn, c.options.HTTPTimeout) if _, err = reqBuf.WriteTo(tcpConn); err != nil { return nil, perrors.WithStack(err) diff --git a/protocol/jsonrpc/server.go b/protocol/jsonrpc/server.go index 755aa7da79384842d5a3f3c4364fc991d84b47df..76901bff6e62748e103d8691f75aedcf68dd202a 100644 --- a/protocol/jsonrpc/server.go +++ b/protocol/jsonrpc/server.go @@ -92,7 +92,9 @@ func (s *Server) handlePkg(conn net.Conn) { t = time.Now().Add(timeout) } - conn.SetDeadline(t) + if err := conn.SetDeadline(t); err != nil { + logger.Error("connection.SetDeadline(t:%v) = error:%v", t, err) + } } sendErrorResp := func(header http.Header, body []byte) error { @@ -239,7 +241,9 @@ func (s *Server) Start(url *common.URL) { s.wg.Add(1) go func() { - accept(listener, func(conn net.Conn) { s.handlePkg(conn) }) + if err := accept(listener, func(conn net.Conn) { s.handlePkg(conn) }); err != nil { + logger.Error("accept() = error:%v", err) + } s.wg.Done() }()