Skip to content
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

[Bug and found the cause] Error: io.grpc.StatusRuntimeException: INTERNAL: protocol is empty due to wrong param sequence in Filebox contruction #75

Closed
Charles-Wu-Chen opened this issue Sep 24, 2020 · 2 comments

Comments

@Charles-Wu-Chen
Copy link

Scenario and simulation steps:
Trying to receive an image and send to another contact:

Code
` Contact from = message.from();
Room room = message.room();

    switch (message.type()) {
        case Image:
            if (room != null) {
                room.say(message.toImage().artwork());
            } else {
                Image image = message.toImage();
                logger.info("Image String" + image.toString());
                FileBox fileBox = image.artwork();
                logger.info("FileBox name:" + fileBox.getName());
                logger.info("FileBox url:" + fileBox.getRemoteUrl());
                logger.info("FileBox json:" + fileBox.toJsonString());
                from.say(fileBox);
            }

}`

Error in the log:

Caused by: io.grpc.StatusRuntimeException: INTERNAL: protocol is empty
at io.grpc.stub.ClientCalls.toStatusRuntimeException(ClientCalls.java:244)
at io.grpc.stub.ClientCalls.getUnchecked(ClientCalls.java:225)
at io.grpc.stub.ClientCalls.blockingUnaryCall(ClientCalls.java:142)
at io.github.wechaty.grpc.PuppetGrpc$PuppetBlockingStub.messageSendFile(PuppetGrpc.java:2940)
at io.github.wechaty.grpc.GrpcPuppet$messageSendFile$1.get(GrpcPuppet.kt:593)
at io.github.wechaty.grpc.GrpcPuppet$messageSendFile$1.get(GrpcPuppet.kt:29)
at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1700)
at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.exec(CompletableFuture.java:1692)
at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)
at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)
at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)
at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:177)

The output from above code is below:

21:05:15.245 [pool-2-thread-2]INFO io.github.charles.model.SingleWechaty-[177] - FileBox name:http://siyouyunsy-1253559996.cos.ap-guangzhou.myqcloud.com/msg/0FAPG/20200924/3556451347864015849_wxid_37gn4v1xgwvf22_1600944110389_.png?sign=q-sign-algorithm%3Dsha1%26q-ak%3DAKIDBi7d3I4UK7iDXkAhQyQsDMNGxY2KmlCY%26q-sign-time%3D1600944110%3B1687257710%26q-key-time%3D1600944110%3B1687257710%26q-header-list%3D%26q-url-param-list%3D%26q-signature%3D72784a91be44376ac57b6e8aa41137a00a9b9cd5
21:05:15.245 [pool-2-thread-2]INFO io.github.charles.model.SingleWechaty-[178] - FileBox url:3556451347864015849_wxid_37gn4v1xgwvf22_1600944110389_.png
21:05:15.462 [pool-2-thread-2]INFO io.github.charles.model.SingleWechaty-[179] - FileBox json:{**"remoteUrl":"3556451347864015849_wxid_37gn4v1xgwvf22_1600944110389_.png","name":"http://siyouyunsy-1253559996.cos.ap-guangzhou.myqcloud.com/msg/0FAPG/20200924/3556451347864015849_wxid_37gn4v1xgwvf22_1600944110389_.png?sign=q-sign-algorithm%3Dsha1%26q-ak%3DAKIDBi7d3I4UK7iDXkAhQyQsDMNGxY2KmlCY%26q-sign-time%3D1600944110%3B1687257710%26q-key-time%3D1600944110%3B1687257710%26q-header-list%3D%26q-url-param-list%3D%26q-signature%3D72784a91be44376ac57b6e8aa41137a00a9b9cd5"**,"boxType":2}
21:05:15.463 [pool-2-thread-2]DEBUG io.github.wechaty.grpc.GrpcPuppet-[584] - json is {"remoteUrl":"3556451347864015849_wxid_37gn4v1xgwvf22_1600944110389_.png","name":"http://siyouyunsy-1253559996.cos.ap-guangzhou.myqcloud.com/msg/0FAPG/20200924/3556451347864015849_wxid_37gn4v1xgwvf22_1600944110389_.png?sign=q-sign-algorithm%3Dsha1%26q-ak%3DAKIDBi7d3I4UK7iDXkAhQyQsDMNGxY2KmlCY%26q-sign-time%3D1600944110%3B1687257710%26q-key-time%3D1600944110%3B1687257710%26q-header-list%3D%26q-url-param-list%3D%26q-signature%3D72784a91be44376ac57b6e8aa41137a00a9b9cd5","boxType":2}
21:05:15.463 [pool-2-thread-2]DEBUG io.github.wechaty.grpc.GrpcPuppet-[585] - json size is 484

The cause is that the name and value of the filebox.fromUrl() are setup in wrong sequence. so the puppet cannot locate the http protocal from URL value.

Message signature is
fromUrl(url: String, name: String?, headers: OutgoingHttpHeaders? = null)
and the caller is calling in a wrong way:

fileBox = fromUrl(
                        jsonNode.findValue("name").asText(),
                        jsonNode.findValue("remoteUrl").asText()
                    )

The file and line number causes the bug:
FileBox.kt

203
FileBoxType.Url.code -> {
fileBox = fromUrl(
jsonNode.findValue("name").asText(),
jsonNode.findValue("remoteUrl").asText()
)
}

242
@JvmStatic
fun fromUrl(url: String, name: String?, headers: OutgoingHttpHeaders? = null): FileBox {

@Charles-Wu-Chen
Copy link
Author

I can try to fix this by a PR. how can I assign this to myself ?

@Charles-Wu-Chen
Copy link
Author

Fixed and merged

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant