Closed yuluo-yx closed 6 months ago
Any idea? 🥲🥲🥲
According to thw config the server should start on port 9000 but in the error message it uses 9090.
Have you checked locally whether the issue can be reproduced there and whether it is caused by the server alone or only in combination with the client? Also a common cause for these kind of issues are kubernetes autogenerated env variables where a service called grpc-server automatically creates an env property grpc_server_port which is then used by spring to set the property accordingly.
According to thw config the server should start on port 9000 but in the error message it uses 9090.
Have you checked locally whether the issue can be reproduced there and whether it is caused by the server alone or only in combination with the client? Also a common cause for these kind of issues are kubernetes autogenerated env variables where a service called grpc-server automatically creates an env property grpc_server_port which is then used by spring to set the property accordingly.
I am sure this problem exists locally. This problem only exists on the client side and the server side is normal.
And, I did not start it in the k8s environment, k8s is just the name of my project, please exclude it. You can run the project demo I provided and comment out the code related to nacos, and you can still reproduce this problem.
The problem is that common contains both the server and the client, thus when you start provider and consumer on the same machine, they both try to be server on port 9090 AFACIT.
The problem is that common contains both the server and the client, thus when you start provider and consumer on the same machine, they both try to be server on port 9090 AFACIT.
Tks, when I removed the server dependency introduced in common from the client, it started successfully.
<dependencies>
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-k8s-common</artifactId>
<version>2024.01.08</version>
<exclusions>
<exclusion>
<groupId>net.devh</groupId>
<artifactId>grpc-server-spring-boot-starter</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
I have a question, how should I handle the following exception when calling the service? @ST-DDT
java.lang.IllegalStateException: call already closed
at com.google.common.base.Preconditions.checkState(Preconditions.java:512) ~[guava-32.0.1-android.jar:na]
at io.grpc.internal.ServerCallImpl.closeInternal(ServerCallImpl.java:213) ~[grpc-core-1.58.0.jar:1.58.0]
at io.grpc.internal.ServerCallImpl.close(ServerCallImpl.java:208) ~[grpc-core-1.58.0.jar:1.58.0]
at io.grpc.stub.ServerCalls$ServerCallStreamObserverImpl.onError(ServerCalls.java:389) ~[grpc-stub-1.58.0.jar:1.58.0]
at io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall(ServerCalls.java:460) ~[grpc-stub-1.58.0.jar:1.58.0]
at com.alibaba.cloud.grpc.lib.SCAk8sProviderGrpc$SCAk8sProviderImplBase.providerA(SCAk8sProviderGrpc.java:144) ~[classes/:na]
at com.alibaba.cloud.k8s.service.ProviderServiceImpl.providerA(ProviderServiceImpl.java:32) ~[classes/:na]
at com.alibaba.cloud.grpc.lib.SCAk8sProviderGrpc$MethodHandlers.invoke(SCAk8sProviderGrpc.java:286) ~[classes/:na]
Dont call super.providerA(request, responseObserver);
Dont call
super.providerA(request, responseObserver);
Tks. I solved it. 🫡
When I request the client interface, the following exception occurs. Do you have any solution?
java.lang.illegalstateexception: call already closed
When I request the client interface, the following exception occurs. Do you have any solution?
java.lang.illegalstateexception: call already closed
Can you please give me some more code or a reference that I can work with?
The error is likely caused by some code that either calls onCompleted()
or onError()
before calling onNext
.
Please also include the full stacktrace.
When I request the client interface, the following exception occurs. Do you have any solution?
java.lang.illegalstateexception: call already closed
Can you please give me some more code or a reference that I can work with? The error is likely caused by some code that either calls
onCompleted()
oronError()
before callingonNext
. Please also include the full stacktrace.
java.lang.IllegalStateException: call already closed
at com.google.common.base.Preconditions.checkState(Preconditions.java:512) ~[guava-32.0.1-android.jar:na]
at io.grpc.internal.ServerCallImpl.closeInternal(ServerCallImpl.java:213) ~[grpc-core-1.58.0.jar:1.58.0]
at io.grpc.internal.ServerCallImpl.close(ServerCallImpl.java:208) ~[grpc-core-1.58.0.jar:1.58.0]
at io.grpc.stub.ServerCalls$ServerCallStreamObserverImpl.onError(ServerCalls.java:389) ~[grpc-stub-1.58.0.jar:1.58.0]
at io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall(ServerCalls.java:460) ~[grpc-stub-1.58.0.jar:1.58.0]
at com.alibaba.cloud.grpc.lib.SCAk8sProviderGrpc$SCAk8sProviderImplBase.providerA(SCAk8sProviderGrpc.java:144) ~[classes/:na]
at com.alibaba.cloud.k8s.service.ProviderServiceImpl.providerA(ProviderServiceImpl.java:28) ~[classes/:na]
at com.alibaba.cloud.grpc.lib.SCAk8sProviderGrpc$MethodHandlers.invoke(SCAk8sProviderGrpc.java:286) ~[classes/:na]
at io.grpc.stub.ServerCalls$UnaryServerCallHandler$UnaryServerCallListener.onHalfClose(ServerCalls.java:182) ~[grpc-stub-1.58.0.jar:1.58.0]
at io.grpc.PartialForwardingServerCallListener.onHalfClose(PartialForwardingServerCallListener.java:35) ~[grpc-api-1.58.0.jar:1.58.0]
at io.grpc.ForwardingServerCallListener.onHalfClose(ForwardingServerCallListener.java:23) ~[grpc-api-1.58.0.jar:1.58.0]
at io.grpc.ForwardingServerCallListener$SimpleForwardingServerCallListener.onHalfClose(ForwardingServerCallListener.java:40) ~[grpc-api-1.58.0.jar:1.58.0]
at io.grpc.Contexts$ContextualizedServerCallListener.onHalfClose(Contexts.java:86) ~[grpc-api-1.58.0.jar:1.58.0]
at io.grpc.internal.ServerCallImpl$ServerStreamListenerImpl.halfClosed(ServerCallImpl.java:351) ~[grpc-core-1.58.0.jar:1.58.0]
at io.grpc.internal.ServerImpl$JumpToApplicationThreadServerStreamListener$1HalfClosed.runInContext(ServerImpl.java:860) ~[grpc-core-1.58.0.jar:1.58.0]
at io.grpc.internal.ContextRunnable.run(ContextRunnable.java:37) ~[grpc-core-1.58.0.jar:1.58.0]
at io.grpc.internal.SerializingExecutor.run(SerializingExecutor.java:133) ~[grpc-core-1.58.0.jar:1.58.0]
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) ~[na:na]
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) ~[na:na]
at java.base/java.lang.Thread.run(Thread.java:833) ~[na:na]
Consumer Method A
@Override
public String consumerB() {
System.out.println(blockingStub);
try {
ResponseBody responseBody = blockingStub.providerB(
RequestBody
.newBuilder()
.setConsumer(CONSUMER_NAME + "B")
.build());
return responseBody.getMessage();
}
catch (Exception e) {
throw new RuntimeException(e);
}
}
Provider Method A
@Override
public void providerA(RequestBody request, StreamObserver<ResponseBody> responseObserver) {
responseObserver.onNext(
ResponseBody
.newBuilder()
.setMessage("This response from provider A!")
.build()
);
responseObserver.onCompleted();
super.providerA(request, responseObserver);
}
Tks! 🫡
https://github.com/yuluo-yx/sca-k8s-demo.git My latest code is automatically sent to the github repository in a timely manner
super.providerA(request, responseObserver);
Do not call super.providerA
as mentioned before.
at io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall(ServerCalls.java:460) ~[grpc-stub-1.58.0.jar:1.58.0] at com.alibaba.cloud.grpc.lib.SCAk8sProviderGrpc$SCAk8sProviderImplBase.providerA(SCAk8sProviderGrpc.java:144) ~[classes/:na]
super.providerA(request, responseObserver);
Do not call
super.providerA
as mentioned before.at io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall(ServerCalls.java:460) ~[grpc-stub-1.58.0.jar:1.58.0] at com.alibaba.cloud.grpc.lib.SCAk8sProviderGrpc$SCAk8sProviderImplBase.providerA(SCAk8sProviderGrpc.java:144) ~[classes/:na]
Thank you so much! 🫡🫡
The context
The bug
Steps to Reproduce
Steps to reproduce the behavior: