首页 \ 问答 \ camel with netty4-http - EncoderException(camel with netty4-http - EncoderException)

camel with netty4-http - EncoderException(camel with netty4-http - EncoderException)

我正在使用带有netty4-http的camel 2.14.0,我得到以下异常。

场景是这样的:我有一个发送请求的路由,等待响应(inOut),然后发送另一个请求。 第一个请求有效,然后第二个请求失败。

另外,如果我在失败后迅速做到这一点 - 第一个请求也将失败。

在调试一下(HttpObjectEncoder) - 我看到在工作流程中请求的状态是:state = ST_INIT(0)并且在失败的请求中是:ST_CONTENT_NON_CHUNK(1)当导致非法状态时的类型消息是HttpMessage

这是一个错误还是我可以配置什么来修复它?

引起:io.netty.handler.codec.EncoderException:java.lang.IllegalStateException:意外消息类型:io.netty.channel上的io.netty.handler.codec.MessageToMessageEncoder.write(MessageToMessageEncoder.java:107)中的DefaultFullHttpRequest。 CombinedChannelDuplexHandler.write(combinedChannelDuplexHandler.java:192)位于io.netty的io.netty.channel.AbstractChannelHandlerContext.invokeWrite(AbstractChannelHandlerContext.java:658)io.netty.channel.AbstractChannelHandlerContext.access $ 2000(AbstractChannelHandlerContext.java:32)。 channel.AbstractChannelHandlerContext $ AbstractWriteTask.write(AbstractChannelHandlerContext.java:939)at io.netty.channel.AbstractChannelHandlerContext $ WriteAndFlushTask.write(AbstractChannelHandlerContext.java:991)at io.netty.channel.AbstractChannelHandlerContext $ AbstractWriteTask.run(AbstractChannelHandlerContext.java: 924)at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTask​​s(SingleThreadEventExecutor.java:380)at io.netty.channel.nio.NioEventLoop.r un(NioEventLoop.java:357)at io.netty.util.concurrent.SingleThreadEventExecutor $ 2.run(SingleThreadEventExecutor.java:116)at java.lang.Thread.run(Thread.java:745)引起:java.lang。 IllegalStateException:意外消息类型:io.netty.handler.codec.http.HttpObjectEncoder.encode(HttpObjectEncoder.java:63)中的DefaultFullHttpRequest,位于io.netty.handler.codec.http.HttpClientCodec $ Encoder.encode(HttpClientCodec.java:106) )at io.netty.handler.codec.MessageToMessageEncoder.write(MessageToMessageEncoder.java:89)... 10更多


I'm using camel 2.14.0 with netty4-http and I get the following exception.

the scenario is this: I have a route that sends a request, waits for the response (inOut) and then sends another request. the first request works, and then the second one fails.

also, if I do it quickly enough after the failure - the first request will also fail.

while debugging a bit (HttpObjectEncoder) - I saw that in the working flow the state of the request is: state = ST_INIT (0) and in the request that failed it is: ST_CONTENT_NON_CHUNK (1) which causes the illegal state when the type of message is HttpMessage

is this a bug or is there anything I can configure to fix it?

Caused by: io.netty.handler.codec.EncoderException: java.lang.IllegalStateException: unexpected message type: DefaultFullHttpRequest at io.netty.handler.codec.MessageToMessageEncoder.write(MessageToMessageEncoder.java:107) at io.netty.channel.CombinedChannelDuplexHandler.write(CombinedChannelDuplexHandler.java:192) at io.netty.channel.AbstractChannelHandlerContext.invokeWrite(AbstractChannelHandlerContext.java:658) at io.netty.channel.AbstractChannelHandlerContext.access$2000(AbstractChannelHandlerContext.java:32) at io.netty.channel.AbstractChannelHandlerContext$AbstractWriteTask.write(AbstractChannelHandlerContext.java:939) at io.netty.channel.AbstractChannelHandlerContext$WriteAndFlushTask.write(AbstractChannelHandlerContext.java:991) at io.netty.channel.AbstractChannelHandlerContext$AbstractWriteTask.run(AbstractChannelHandlerContext.java:924) at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:380) at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:357) at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:116) at java.lang.Thread.run(Thread.java:745) Caused by: java.lang.IllegalStateException: unexpected message type: DefaultFullHttpRequest at io.netty.handler.codec.http.HttpObjectEncoder.encode(HttpObjectEncoder.java:63) at io.netty.handler.codec.http.HttpClientCodec$Encoder.encode(HttpClientCodec.java:106) at io.netty.handler.codec.MessageToMessageEncoder.write(MessageToMessageEncoder.java:89) ... 10 more


原文:https://stackoverflow.com/questions/26201196
更新时间:2023-10-24 20:10

最满意答案

你遇到的问题的原因是由于范围界定。 具体来说, forEach this内部不再绑定到Vue实例。 为了解决这个问题,请尝试在进入循环之前将参考存储在变量中,如下所示:

select_rowse: function () {
    this.deselect_rows();
    var this_vue_instance = this;
    this.get_rows().forEach(function (entry) {
        this_vue_instance.selectedRows.push(entry.id);
    });
}

一般来说,您应尽可能避免使用vm.$data 。 尤其是,如果您有多个对整个代码中散布的变量的引用,并且您需要重命名该变量,而this将保持一致,则会遇到问题。 如果绝对必要,只能使用变量引用,这应该是不常见的。


The reason you run into the issue you're having is due to scoping. Specifically, this inside of the forEach is no longer bound to the Vue instance. In order to resolve this problem, try storing the reference in a variable prior to entering the loop, like in the following:

select_rowse: function () {
    this.deselect_rows();
    var this_vue_instance = this;
    this.get_rows().forEach(function (entry) {
        this_vue_instance.selectedRows.push(entry.id);
    });
}

In general, you should try to avoid using vm.$data whenever possible. In particular, you will run into issues if you have multiple references to the variable scattered throughout your code and if you ever need to rename the variable, whereas this will remain consistent. Only use a variable reference if absolutely necessary, which should be infrequent.

相关问答

更多

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。