本文介绍了在使用AMF连接发送Flex消息时,获取不支持的AMF版本错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  ClientStatusException $ b $我试图使用AMF连接API发送AMF消息,但得到如下所示的错误。 b消息:不支持的AMF版本

为此,我正在使用blazeds-core-4.0.1.21287.jar



以下是我的代码。

  String url =https ://10.222.73.251:9443 /的vSphere的客户端/#; 
尝试{
amfConnection.connect(url);
System.out.println(amfConnection.getUrl());
} catch(ClientStatusException cse){
System.out.println(Error connecting url:+ cse);
return;


try {

amfConnection.addHttpRequestHeader(Cookie,
6250CED9FBC7D5894B79973DEC1503A6);
amfConnection.addHttpRequestHeader(Content-type,
application / x-amf);
amfConnection.setAmfTrace(new AmfTrace());
//amfConnection.setObjectEncoding(3);
System.out.println(amfConnection.getObjectEncoding());

CommandMessage cmsg = new CommandMessage();
cmsg.setOperation(CommandMessage.CLIENT_PING_OPERATION);
cmsg.setMessageId(UUIDUtils.createUUID());
cmsg.setHeader(Message.FLEX_CLIENT_ID_HEADER,706E5399-D81A-11C8-11F7-BE5F1940632E);
cmsg.setHeader(Message.ENDPOINT_HEADER,amf);
AcknowledgeMes​​sage ack =(AcknowledgeMes​​sage)amfConnection.call(null,cmsg);

任何帮助表示赞赏。 :)

解决方案

我有同样的问题。原因是服务器期望一个独立的AMF数据包。



请参阅



意味着你需要在普通的AMF消息之前添加以下字节:

  byte [] header = 
{0x00,0x03,//版本
0x00,0x00,//要跟随的头部类型结构的数量(无)
0x00,0x01,//消息类型的nr (一)
0x00,0x04,// target-uri-length
0x6e,0x75,0x6c,0x6c,// target urinull
0x00,0x04, //响应uri长度
0x6e,0x75,0x6c,0x6c,//响应urinull

??,??,??,?? //正常消息的长度,32位
};


I am trying to send AMF message using AMF Connection API but getting following error as shown below.

ClientStatusException 
message: Unsupported AMF version

I am using blazeds-core-4.0.1.21287.jar for this purpose.

Following is my code.

String url = "https://10.222.73.251:9443/vsphere-client/#";
        try {
            amfConnection.connect(url);
            System.out.println(amfConnection.getUrl());
        } catch (ClientStatusException cse) {
            System.out.println("Error connecting url: " + cse);
            return;
        }

        try {

            amfConnection.addHttpRequestHeader("Cookie",
                    "6250CED9FBC7D5894B79973DEC1503A6");
            amfConnection.addHttpRequestHeader("Content-type",
                    "application/x-amf");
            amfConnection.setAmfTrace(new AmfTrace());
            //amfConnection.setObjectEncoding(3);
            System.out.println(amfConnection.getObjectEncoding());

            CommandMessage cmsg = new CommandMessage();
            cmsg.setOperation(CommandMessage.CLIENT_PING_OPERATION);
            cmsg.setMessageId(UUIDUtils.createUUID());
            cmsg.setHeader(Message.FLEX_CLIENT_ID_HEADER, "706E5399-D81A-11C8-11F7-BE5F1940632E");
            cmsg.setHeader(Message.ENDPOINT_HEADER, "amf");
            AcknowledgeMessage ack = (AcknowledgeMessage)amfConnection.call(null, cmsg);

Any help is appreciated. :)

解决方案

I had the same problem. The cause was that the server expected a "self-contained AMF packet".

See https://en.wikipedia.org/wiki/Action_Message_Format#AMF_self-contained_packet

This basically means that you need to add the following bytes in front of the "normal" AMF message:

  byte[] header = 
  { 0x00, 0x03,       // version 
    0x00, 0x00,       // nr of "header-type-structures" to follow (none) 
    0x00, 0x01,       // nr of "message-type-structures" to follow (one)
    0x00, 0x04,       // target-uri-length
    0x6e, 0x75, 0x6c, 0x6c, // target uri "null" 
    0x00, 0x04,       // response uri length 
    0x6e, 0x75, 0x6c, 0x6c, // response uri "null" 

    ??, ??, ??, ??    // the length of the "normal" message, 32 bits
  };

这篇关于在使用AMF连接发送Flex消息时,获取不支持的AMF版本错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-20 15:44