userSession getAddress returns null

I am trying to get the client IP address in the Business Logic layer but the user session getAddress() is returning null. How do I get this field ?

Also, can I use setAttribute with userSession to set attributes in the request object ?

The user IP address is set by the client tier and in case of web client with standard authentication procedure it is taken from ServletRequest. So check if you can get the user address on the web tier:

VaadinService.getCurrentRequest().getRemoteAddr()

When you set a UserSession attributes on the client tier, it becomes available in this client block and all middleware blocks. If you set an attribute on the middleware, it is available only on the middleware, i.e. it’s not sent back to the clients.