-
Notifications
You must be signed in to change notification settings - Fork 420
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Only one ServerStreamingCall can response when Clientconnection built on NIOTSEventLoopGroup #901
Comments
When you say it doesn’t work, what does happen? Have you provisioned appropriate networking entitlements? |
Under this code snippet, I can make multiple let group = MultiThreadedEventLoopGroup(numberOfThreads: 1)
let configuration = ClientConnection.Configuration(target: .hostAndPort(host, port), eventLoopGroup: group, errorDelegate: self, connectivityStateDelegate: self) And under this code snippet : let group = PlatformSupport.makeEventLoopGroup(loopCount: 1)
let configuration = ClientConnection.Configuration(target: .hostAndPort(host, port), eventLoopGroup: group, errorDelegate: self, connectivityStateDelegate: self) I can only get fufilled I want to know why |
When you say once, you mean once per app launch? Once per device? Once per server? |
No, Every time I present a viewcontroller, I can request once. The channel's lifecycle was binding to the controller. |
Can you show the setup code from the view controller? How are you managing the grpc state there? |
here is my code. I use an instance of ChartGrpcClient class in the viewcontroller.I deleted some code final class ChartGrpcClient<T: Codable> {
private var grpcClient: Grpc_Gateway_GateWayCallClient?
private var channel: ClientConnection?
private var channelQueue: DispatchQueue {
return chartDataHandleQueue
}
private var grpcCall: ServerStreamingCall<Grpc_Gateway_GateWayRequest, Grpc_Gateway_GateWayResponse>?
func send(_ request: Grpc_Gateway_GateWayRequest, completionHandler: @escaping (T) -> Void) {
let handler: (Grpc_Gateway_GateWayResponse) -> Void = { (response) in
if let data = response.playLoad.data(using: .utf8),
let result = try? JSONDecoder().decode(T.self, from: data) {
DispatchQueue.main.async {
completionHandler(result)
}
}
}
self.grpcCall = self.grpcClient?.request(
request,
callOptions: self.buildCallOptions(),
handler: handler
)
}
func buildConnection() {
let channel = self.buildChannel()
self.channel = channel
self.bind(toChannel: channel)
}
private func bind(toChannel channel: GRPCChannel) {
_ = self.grpcCall?.cancel()
self.grpcClient = Grpc_Gateway_GateWayCallClient(channel: channel)
}
private func buildChannel() -> ClientConnection {
let group = MultiThreadedEventLoopGroup(numberOfThreads: 1)
let configuration = ClientConnection.Configuration(
target: .hostAndPort(host, port),
eventLoopGroup: group,
errorDelegate: self,
connectivityStateDelegate: self
)
return ClientConnection(configuration: configuration)
}
}
extension ChartGrpcClient: ClientErrorDelegate {
func didCatchError(_ error: Error, logger: Logger, file: StaticString, line: Int) {}
}
extension ChartGrpcClient: ConnectivityStateDelegate {
func connectivityStateDidChange(from oldState: ConnectivityState, to newState: ConnectivityState) {}
} |
Ok, and how do you invoke this object in your view controller? What methods do you call? |
call |
The object is a property of the viewcontroller. |
Can you print the logs from the |
Ok, so While we're here, you are also ignoring any errors that may be returned in |
There will be some changes to our Service, I will do some tests later. |
I have the same Issue:
Is there anything I can provide? |
@Lutzifer What does "works" mean here? If it's the same issue as above, can you aim to get all those diagnostics too? |
@Lukasa Behaviour:
Result:
Expected:
|
Unfortunately I don't reproduce that behaviour. If I run the same hello world server and client, I end up with the following logs (note that I added
You can see the successful completion of both RPCs. Do you have the equivalent logs from your run? |
Did you run on device? or on simulator? I have equivalent log without second Hello_2 |
On device. |
What is iOS version you had? I tested on 13.5.1, now I found, that 13.6 is available. |
@Lukasa This is my log on 13.5.1 iPhone X, will update device shortly and test again. UPD: Reproduced on 13.6 as well
|
Thanks for those logs @Lutzifer, that pinned this issue down. This is the bug that caused us to write apple/swift-nio-transport-services#72. This also explains why I didn't see the issue: the problem is resolved in iOS 14, which is what I was running on my test device. @glbrntt We should add the |
Sorry, didn't find the time to post logs yet, so I thanks to @givip instead ;-) |
Whoops bad tag, sorry @givip! Thank you for the logs. :D |
What are you trying to achieve?
Can't response multiple
ServerStreamingCall
when EventLoopGroup was set to NIOTSEventLoopGroup on a real device, while it woks fine on simulatorsWhat have you tried so far?
I build an app on iOS platform, currently I have two services, first one using UnaryCall, second one use ServerStreamingCall works like
socket
.Both services' channel was provided by
ClientConnection
, andPlatformSupport.makeEventLoopGroup(loopCount:)
was used to provide EventLoopGroup, which useNIOTSEventLoopGroup
by default.Recently I need to build a new service, which use
ServerStreamingCall
to send and response message. when build the channel,MultiThreadedEventLoopGroup
works fine on real devices, whileNIOTSEventLoopGroup
can't.Any ideas will be appreciated. Thanks
The text was updated successfully, but these errors were encountered: