-
Notifications
You must be signed in to change notification settings - Fork 26.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RpcContext.getServiceContext().getLocalAddressString() return zero port on consumer side ! #13305
Comments
@namelessssssssssss PTAL |
Line 68 in 7264850
caused by I try to fixed it but found another bug, if there are multiple network interface and using Should we add more parameter to the |
The best way to get real consumer address is from tcp connection. |
@aofall are you solving this issue? |
yes |
@aofall |
The eg.
|
We can set the local port from netty tcp connection |
@AlbumenJ How to get the local port from netty tcp connection, the filter chain is effort before the invoker innvocation. Although the Netty connections established at the application start and it can be reused during the invocation, but the connections can also be set. If the protocol is |
|
please assign to me, ths! |
@AlbumenJ assign it to him, I'm sorry i am too busy recently |
@laywin It may be find another way to reslove? (Or My analysis may also be wrong) . If just for the logs, it can use link tracing to solve the problem. Netty invoke is in the |
i think your analysis is no problem, but the point is get local address in whenCompleteWithContext instead of in filter directly, so only set the address before invoke happens and it can be get in whenCompleteWithContext. |
When you raise a connection to a server,you don't need to specific the local port and local address.We just need to specific the server address and server port,after the tcp connection is established. The socket object would contains four items - local address,local port,target address,target port. Before you return to filter,you set the local address and local port to the filter chain or other variables. so you can get it. |
we all agree that, the point of disagreement is whether to obtain the local address before or after the invoker invoke happens. I think the focus of this issue is to obtain the local address after that. |
where is the invoker in ? Which module, I mean. When the connection established, you can get the local address and local port and set it into RpcContext. You can do this in the |
RpcContext is based on threadLocal. When establishing a connection, there may be multiple clients, which means there are multiple ports. How to set the address into the filter at this time? What I mean is that when DubboInvoker doInvoke, it will determine which client to use, so The port of the client can be determined and set into the RpcContext. When the request is completed, the filter callback will be entered to obtain the address information. |
aha, may be we have the same idea. What I want to do is that we can set local address in TripleInvoker#doInvke function. After the connectionClient.isConnected is called and it returns true, we can get local address, local port from connectClient and set it into RpcContext. |
Describe the feature
I'm doing some logging thing by using
Filter
, and I useRpcContext.getServiceContext().getLocalAddressString()
to get the local address, both on the provider and consumer side. It goes very well on provider side. However, unexpected things happens when it’s running on consumer side.The code is something like follows (here I've kept only the necessary parts for simplicity):
When I'm trying to get local address through
RpcContext.getServiceContext().getLocalAddressString()
, I expect it will return something like "1.2.3.4:56789", in which "1.2.3.4" is the IP address and "56789" is the port. But what I have got is "1.2.3.4:0". I get a zero port here, which clearly is not the truth! That makes me confused. I wonder how can I get the real port value, and I think it should be contained in the return ofRpcContext.getServiceContext().getLocalAddressString()
method, just like when it's called on provider side.The text was updated successfully, but these errors were encountered: