question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

RpcContext.getContext().getAttachment(RootContext.KEY_XID) is null

See original GitHub issue
  • I have searched the issues of this repository and believe that this is not a duplicate.

Ⅰ. Issue Description

dubbo远程调用,hessian协议,在TransactionPropagationFilter.invoke方法中getAttachment(RootContext.KEY_XID),这个key是大写的,但是RpcContext#attachments中的key是小写的,导致此处无法获取获取传递过来的全局事务id。

导致attachments中的key为小写是因为: Http11InputBuffer#parseHeader中对用户添加的head name都置为了小写。 然后org.apache.dubbo.rpc.protocol.hessian.HessianProtocol.HessianHandler#handle直接从request取参数,代码如下: // 直接从request head里取出传递的参数 Enumeration<String> enumeration = request.getHeaderNames(); while (enumeration.hasMoreElements()) { String key = enumeration.nextElement(); if (key.startsWith(Constants.DEFAULT_EXCHANGER)) { RpcContext.getContext().setAttachment(key.substring(Constants.DEFAULT_EXCHANGER.length()), request.getHeader(key)); } } // …

请问这个怎么能解决?

Ⅱ. Describe what happened

If there is an exception, please attach the exception trace:

Just paste your stack trace here!

Ⅲ. Describe what you expected to happen

Ⅳ. How to reproduce it (as minimally and precisely as possible)

服务提供方用hessian协议暴露服务即可: <dubbo:protocol name=“hessian” server=“servlet” port=“${server.port}”/>

Ⅴ. Anything else we need to know?

Ⅵ. Environment:

  • JDK version :1.8
  • OS : win10_64
  • spring boot : 2.1.8.RELEASE
  • apache dubbo : 2.7.0
  • hessian : 4.0.38
  • seata-all : 0.8.1

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
jsbxyyxcommented, Oct 28, 2019

@slievrly nginx default auto filter _ header, back end server may be get the header is null, otherwise nginx need configuration underscores_in_headers on; in http {...}, I suggest the header update to tx-xid

0reactions
xingfudeshicommented, Oct 12, 2019

@Daidalose I understand that.It may cause by the similar problem.So i refer that issue here.

Read more comments on GitHub >

github_iconTop Results From Across the Web

seata tcc - OSCHINA - 中文开源技术交流社区
getContext().getAttachment(RootContext.KEY_XID); if (rpcXid == null) { rpcXid = RpcContext.getContext().getAttachment(RootContext.KEY_XID.
Read more >
seata 子线程
getContext().getAttachment(RootContext.KEY_XID); if (rpcXid == null) { rpcXid = RpcContext.getContext().getAttachment(RootContext.KEY_XID.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found