You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by GitBox <gi...@apache.org> on 2022/08/16 08:58:57 UTC

[GitHub] [dubbo] AypakNanot opened a new issue, #10469: 客户端如何设置payload?

AypakNanot opened a new issue, #10469:
URL: https://github.com/apache/dubbo/issues/10469

   <!-- If you need to report a security issue please visit https://github.com/apache/dubbo/security/policy -->
   
   - [ ] I have searched the [issues](https://github.com/apache/dubbo/issues) of this repository and believe that this is not a duplicate.
   
   ## Environment
   Dubbo version: 2.7.12
   Java version: 1.8
   
   ## 配置文件`payload`大小
   ```
   dubbo.provider.payload=10485760
   dubbo.protocol.payload=10485760
   ```
   
   服务器和客户端都加上配置
   
   在服务器上可以通过大小的限制,但是客户端不能通过,断点到 `ExchangeCodec`  116行,发现在`channel`中的`url`并没有`payload`属性,说明客户端`payload`没有加对,如果在`url`上没有`payload`,那么方法`finishRespWhenOverPayload`就会获取到默认值`8M`。
   请问如何给客户端添加`payload`???
   查看文档并没有发现客户端有设置`payload`属性的位置,求教如何设置?
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo] AypakNanot commented on issue #10469: 客户端如何设置payload?

Posted by GitBox <gi...@apache.org>.
AypakNanot commented on issue #10469:
URL: https://github.com/apache/dubbo/issues/10469#issuecomment-1220373714

   找到问题了,
   
   `dubbo.registry.simplified=true` 
   
   此配置,不会将`payload`配置传入到消费端,所以导致在`channel`中获取不到此值,从而获取了默认值


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo] AlbumenJ commented on issue #10469: 客户端如何设置payload?

Posted by GitBox <gi...@apache.org>.
AlbumenJ commented on issue #10469:
URL: https://github.com/apache/dubbo/issues/10469#issuecomment-1220168011

   配置在服务端的 payload 参数会通过注册中心传递给消费端


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo] AypakNanot commented on issue #10469: 客户端如何设置payload?

Posted by GitBox <gi...@apache.org>.
AypakNanot commented on issue #10469:
URL: https://github.com/apache/dubbo/issues/10469#issuecomment-1218227791

       protected static int getPayload(Channel channel) {
           int payload = Constants.DEFAULT_PAYLOAD;
           if (channel != null && channel.getUrl() != null) {
               payload = channel.getUrl().getParameter(Constants.PAYLOAD_KEY, Constants.DEFAULT_PAYLOAD);
           }
           return payload;
       }
   
   这个方法中的` channel.getUrl().getParameter(Constants.PAYLOAD_KEY, Constants.DEFAULT_PAYLOAD)` 获取不到服务器设置的`payload` 值。 或者**需要怎么设置才能通过`channel`获取到服务器设置的`payload`值 ???**
   
   服务器设置的`payload`是生效了的,报错是在客户端,服务器通过了的。
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo] AlbumenJ commented on issue #10469: 客户端如何设置payload?

Posted by GitBox <gi...@apache.org>.
AlbumenJ commented on issue #10469:
URL: https://github.com/apache/dubbo/issues/10469#issuecomment-1218010036

   目前是不支持通过 config 配置客户端的 payload 大小的,只能通过直连或者在 ReferenceConfig 的 parameters 中配置 payload=xxx


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo] AypakNanot commented on issue #10469: 客户端如何设置payload?

Posted by GitBox <gi...@apache.org>.
AypakNanot commented on issue #10469:
URL: https://github.com/apache/dubbo/issues/10469#issuecomment-1218203955

   > 目前是不支持通过 config 配置客户端的 payload 大小的,只能通过直连或者在 ReferenceConfig 的 parameters 中配置 payload=xxx
   
   既然客户端不支持 配置payload 大小,为什么客户端还要校验 请求返回结果的 payload 大小呢,每次拿默认值8m校验,那服务器设置了`payload`不是没有效果了么?
   
   `ExchangeCodec.java` 中  客户端需要校验 返回大小。而返回的大小每次取的都是默认值8M。 这是为什么呢?
   
   ```
    @Override
       protected Object decode(Channel channel, ChannelBuffer buffer, int readable, byte[] header) throws IOException {
           // check magic number.
           if (readable > 0 && header[0] != MAGIC_HIGH
                   || readable > 1 && header[1] != MAGIC_LOW) {
               int length = header.length;
               if (header.length < readable) {
                   header = Bytes.copyOf(header, readable);
                   buffer.readBytes(header, length, readable - length);
               }
               for (int i = 1; i < header.length - 1; i++) {
                   if (header[i] == MAGIC_HIGH && header[i + 1] == MAGIC_LOW) {
                       buffer.readerIndex(buffer.readerIndex() - header.length + i);
                       header = Bytes.copyOf(header, i);
                       break;
                   }
               }
               return super.decode(channel, buffer, readable, header);
           }
           // check length.
           if (readable < HEADER_LENGTH) {
               return DecodeResult.NEED_MORE_INPUT;
           }
   
           // get data length.
           int len = Bytes.bytes2int(header, 12);
   
           // When receiving response, how to exceed the length, then directly construct a response to the client.
           // see more detail from https://github.com/apache/dubbo/issues/7021.
           Object obj = finishRespWhenOverPayload(channel, len, header);
           if (null != obj) {
               return obj;
           }
   
           checkPayload(channel, len);
   
           int tt = len + HEADER_LENGTH;
           if (readable < tt) {
               return DecodeResult.NEED_MORE_INPUT;
           }
   
           // limit input stream.
           ChannelBufferInputStream is = new ChannelBufferInputStream(buffer, len);
   
           try {
               return decodeBody(channel, is, header);
           } finally {
               if (is.available() > 0) {
                   try {
                       if (logger.isWarnEnabled()) {
                           logger.warn("Skip input stream " + is.available());
                       }
                       StreamUtils.skipUnusedStream(is);
                   } catch (IOException e) {
                       logger.warn(e.getMessage(), e);
                   }
               }
           }
       }
   
   ```
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo] AypakNanot closed issue #10469: 客户端如何设置payload?

Posted by GitBox <gi...@apache.org>.
AypakNanot closed issue #10469: 客户端如何设置payload?
URL: https://github.com/apache/dubbo/issues/10469


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org