Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jetty-users] jetty11 Connection.Listener#onClosed does not provide remote IP

You could, alternatively, just set a Request attribute at the start the Request lifecycle with the remote address.
Then just use the Request attribute everywhere else, even in Connection.Listener.onClosed

Joakim Erdfelt / joakim@xxxxxxxxxxx


On Thu, Aug 18, 2022 at 2:37 AM Matthias Pfau via jetty-users <jetty-users@xxxxxxxxxxx> wrote:
Just analyzed this further and found that you should not rely on connection.getEndPoint().getRemoteSocketAddress() to return a non null value.

SockenChannelImpl#getRemoteAddress will throw a ClosedChannelException in case the Channel is not open anymore. This will be catched and converted to null in SocketChannelEndpoint#getRemoteSocketAddress (since jetty 10).

What helped us to find out about the problem is that that exception logging was added to AbstractConnection#onClosed. This is actually a good thing and everything seems fine on Jettys side!

So this was a flaw in our implementation. We need to maintain our own mapping from ip to Connections/Endpoints...

Best,
Matthias
Aug 17, 2022, 16:47 by jetty-users@xxxxxxxxxxx:

> Hi there,
> when upgrading from 9 to 11, we noted that connection.getEndPoint().getRemoteSocketAddress() returns null when ConnectionListener#onClosed is invoked.
>
> This was different in jetty 9. One could retrieve the remote ip via endPoint.getRemoteAddress(). We used the ip to track certain attributes regarding connections. Is there any way to get the ip or do we somehow need to build our own mapping from Connection to ip?
>
> Best,
> Matthias
> _______________________________________________
> jetty-users mailing list
> jetty-users@xxxxxxxxxxx
> To unsubscribe from this list, visit https://www.eclipse.org/mailman/listinfo/jetty-users
>

_______________________________________________
jetty-users mailing list
jetty-users@xxxxxxxxxxx
To unsubscribe from this list, visit https://www.eclipse.org/mailman/listinfo/jetty-users

Back to the top