-1

I have checked other questions on this topic, most of which suggest running a task to check for IP address change. I am running a service in Jetty web server. My question is, do HTTP web servers capture such changes for their working? Or does it only require a "port" to bind to. If a web server already does that tracking then I might try to make use of it as a trigger in my application. I could not find any source which says so. I am just interested in knowing if something like that already exists.

kishore
  • 384
  • 2
  • 5
  • 12

1 Answers1

1

When Jetty starts up it creates 1 (or more) Jetty ServerConnector objects.

These ServerConnector objects use the Java (and OS) networking facilities (for TCP/IP) to "bind" to a specific host:port to list for incoming connections.

If the host IP goes down, then it can no longer accept incoming connections.

If the host IP changes, that's essentially the existing host going down, and a new host (on a new IP) being created.

For a server, like Jetty, to respond to this scenario would require being able to hook into the Networking services of the OS and be notified of this kind of change. Then create a new ServerConnector on the new IP for accepting new incoming connections.

Note: existing connections would likely be terminated by the OS.

Unfortunately, standard Java has no such network configuration event to hook into.

But specialty APIs exist.

Example: Android has the Connectivity Manager. Android: Internet connectivity change listener

Joakim Erdfelt
  • 41,193
  • 5
  • 78
  • 124
  • I tried changing the IP address when Jetty server was running and I was able to work with the new IP almost immediately. I wondered if it provided an API for the webapps to register for such events. I wish Java had an option to subscribe for such changes. Guess I will just have to periodically check for an IP change. – kishore Jun 04 '18 at 12:48