'How to detect and handle the dynamic IP address for web-socket connection by using JavaScript?

  var webSocketURL = null;
  var ws_protocol = "ws";
  var ws_hostname = "";//here I pass Dynamic IP
  var ws_port     = "80";
  webSocketURL = protocol + "://" + hostname + ":" + port;

Router have dynamic IP which changes eventually how I can detect this private IP using JavaScript or there is any way to handle and get IP information in JavaScript to pass it to websocket connection.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source