Native Messaging host tried sending a message that is 977472013 bytes long

后端 未结 2 364
渐次进展
渐次进展 2021-01-28 18:40

I\'m using a java jar to send and receive messages using Chrome Native Messaging.

I enabled logging of Chrome so I could read C:\\Users\\%UserName%\\AppData\\Local

相关标签:
2条回答
  • 2021-01-28 19:07

    I think you have to swap the order of the bytes defining your message length. Change your getBytes() method to this:

    public byte[] getBytes(int length) {
        byte[] bytes = new byte[4];
        bytes[3] = (byte) (length & 0xFF);
        bytes[2] = (byte) ((length >> 8) & 0xFF);
        bytes[1] = (byte) ((length >> 16) & 0xFF);
        bytes[0] = (byte) ((length >> 24) & 0xFF);
        return bytes;
    }
    
    0 讨论(0)
  • 2021-01-28 19:09

    Many answers suggest checking the correctness of processing the first four bytes. But this is not always the real reason. It seems that in your case the reason is the absence of an @echo off in launch.bat.

    When an error occurs

    Native Messaging host tried sending a message that is 977472013 bytes long

    First of all, try to start the application from the command line, it is possible that the output is "trash"

    0 讨论(0)
提交回复
热议问题