If your needs cannot be met, please submit an issue on the Kitex GitHub repository, and the community maintainers will promptly follow up and address it.
Q1: Does Kitex support Windows?
Q2: Does Kitex support HTTP?
Q3: How to configure multiplexing?
Q4: In the scenario of direct local call, why does the configuration of connection pool not take effect?
Q5: What are the differences between “Kitex Protobuf” and “gRPC” protocol?
Q6: Issues regarding Thrift interface compiling, such as “not enough arguments in call to iprot.ReadStructBegin”
go mod edit -replace github.com/apache/thrift=github.com/apache/thrift@v0.13.0
Q1:’not enough arguments’ problem when installing the code generation tool
Q2: Why ‘set’ in IDL becomes slice in generated codes?
Q3: Why is there an underscore after some field names?
Q4: Would code generated by new interface overwrite handler.go
Q5: Do the templates of the code generator support customization?
Q6: Is it possible for the ‘-type’ argument of the code generator to be determined automatically by IDL filename extension?
According to the CPU profile, there is a hotspot issue with errors.Is
or errors.As
, and the CPU usage even reaches its maximum.
Cause: The custom error type has implemented the Unwrap
method, but the implementation is incorrect. It returns the error object itself, causing an infinite loop. Here is an example:
func (e *XError) Unwrap() error {
if e == nil {
return nil
}
return e.InnerError // Actually returns itself
}
func (e *XError) NewXError(outMsg *XError) *XError {
err := &XError{
OutCode: outMsg.OutCode,
OutMsg: outMsg.OutMsg,
InnerError: innerErr(outMsg.Msg),
}
err.InnerError = err // Points to itself here
return err
}
Solution: The Unwrap
method should return the wrapped error instead of itself. If there is no wrapped error, it should return nil
. Avoid circular references.
Cause: The Kitex client handles request timeouts based on the context
provided by context.WithTimeout(ctx, timeout)
. If the ctx
passed from the business logic already has a deadline
set and it is earlier than the RPC timeout, the ctx deadline
from the business logic will be used.
Solution: Do not set deadline
for the ctx
used by Kitex.
Troubleshooting:
context.Done()
method: Before the RPC request, output the following information about the ctx
. If ctx.Done() != nil
, it indicates that WithTimeout
or WithDeadline
has been set.deadline, _ := ctx.Deadline()
klog.Infof("before rpc call, ctxDone=%t, deadline=%v", ctx.Done() != nil, deadline)
WithTimeout
, WithDeadline
, or equivalent operations are called. Sometimes you may not directly set the timeout
. It is common to pass the ctx
used by another framework to the kitex client
, and that ctx
has already been modified with the mentioned operations. Regardless of who made the modification, trace back the assignment of ctx
starting from the code segment where the call to Client
is made, and you will find the point of tampering. You can use dlv
(the Go debugger) or the debugging mode of your IDE to help trace the call chain.Cause: If the business code calls the cancel
function returned by WithTimeout
, WithDeadline
, or WithCancel
before the actual timeout deadline set by the Kitex client, Kitex will append additional information stating context canceled by business
.
Troubleshooting: Refer to the troubleshooting method for “Context Deadline Earlier Than Timeout”.
Note: If multiple goroutines share the same ctx
(typical when starting a new goroutine and passing the ctx
to it), calling the cancel
method of that ctx
will affect all goroutines.
This error indicates a protocol mismatch between the client and server. Below are some common scenarios for reference.
To quickly determine whether the issue lies with the client or server, you can consider the following:
Message | Description |
---|---|
first4Bytes=0x48545450, second4Bytes=0x2f312e31 | These 8 bytes correspond to the ASCII characters “HTTP/1.1,” indicating a typical HTTP server response. This indicates that the Kitex client requested an HTTP server. |
first4Bytes=0x47455420 | These 4 bytes correspond to the ASCII characters “GET,” indicating a typical HTTP GET request. This indicates that the Kitex server received an HTTP request. Please avoid directly using an HTTP client to request Kitex server. |
first4Bytes=0x504f5354 | These 4 bytes correspond to the ASCII characters “POST,” indicating a typical HTTP POST request. This indicates that the Kitex server received an HTTP request. Please avoid directly using an HTTP client to request Kitex server. |
first4Bytes=0x16030100 | This is a TLS protocol message, and Kitex does not natively support the TLS protocol. |
first4Bytes=0x50524920, second4Bytes=0x2a204854 | This is an HTTP2 PRI request, indicating that the service received an HTTP2 request. Please check the corresponding client. |
Q1: How to identify the source of the request?
Q2: Why doesn’t the error message include the method name of the request?