Skip to content

The remote address could not be obtained from the context after the request #11790

@chaoyoung

Description

@chaoyoung

Environment

  • Dubbo version: 3.1.6
  • Operating System version: macOS 13.2
  • Java version: 1.8.0_362

Steps to reproduce this issue

  1. add a filter in consumer
    @Slf4j
    public class RpcContextFilter implements Filter {
        @Override
        public Result invoke(Invoker<?> invoker, Invocation invocation) throws RpcException {
            log.info("invoker url: {}:{}", invoker.getUrl().getHost(), invoker.getUrl().getPort());
            Result result = invoker.invoke(invocation);
            log.info("remote address: {}", RpcContext.getContext().getRemoteAddress());
            return result;
        }
    }
  2. resources/META-INF/dubbo/org.apache.dubbo.rpc.Filter content
    rpcContextFilter=org.example.dubbo.filter.RpcContextFilter
  3. dubbo consumer dependency
    @DubboReference(filter = "rpcContextFilter")
  4. After a request, the filter prints the log as follows:
    2023-03-10 19:08:45.667  INFO 77228 --- [nio-8081-exec-1] o.example.dubbo.filter.RpcContextFilter  : invoker url: 10.9.0.162:50051
    2023-03-10 19:08:45.817  INFO 77228 --- [nio-8081-exec-1] o.example.dubbo.filter.RpcContextFilter  : remote address: null
    

Expected Behavior

The remote address can be obtained.

Actual Behavior

The remote address is empty

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


Metadata

Metadata

Assignees

No one assigned

    Labels

    type/bugBugs to being fixed

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions