Skip to content

How can we obtain the client IP address? #3699

@jpforevers

Description

@jpforevers

How can we obtain the client IP address?

We would like to use the IP address to perform an initial localization of the device, so obtaining the client IP is very important to us.

I have reviewed the Hono documentation but did not find a way to retrieve the client’s IP address.

I am a developer and I am more familiar with Hono’s MQTT Adapter.

To implement this feature in the MQTT Adapter, the following approaches seem feasible:

  1. Provide an option to enable the proxy protocol when creating the MQTT server

    MqttServerOptions mqttServerOptions = new MqttServerOptions();
    mqttServerOptions.setUseProxyProtocol(true);
  2. Retrieve the client IP during the client connection via mqttEndpoint.remoteAddress().host()

  3. Add a client IP field in the "Connection Event" (or some other mechanism?)

Is this right?

I’m not entirely sure how other adapters would implement this, but it should be similar.

Could this feature be added?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions