Get an IP address of Client RRS feed

  • General discussion

  • I have already an implementation of Client / Server where both entities are sending message using WCF MSMQ.
    As usual, Client always starts communication.

    My Client is connected to internet using Wireless Air Card.
    When Client sends a message to Server, it also provides the IP address / net.msmq address of himself for server to send message back to.

    But the problem is, my Client doesnt have a fixed IP address. Its Dynamic. So the address provided to server could change and may not valid be any more.

    What options I have to keep track of my Client as what address it is available on?
    How can I make him to use the Fixed Address?


    Thursday, April 23, 2009 6:31 PM

All replies

  • Hi saqib,

    you could use dynamic dns (www.dyndns.com is free and popular) or implement the same logic by yourself, i.e. have your client notify the service when IP changes.

    Fixed address would be an option if you can rent a static IP connection but it's costly and it isn't an option if your client application is going to be used on great number of machines.

    Thursday, April 23, 2009 7:00 PM
  • There are two things:

    Client can go offline as well when there is no connectivity. So if there is a message in the Server queue is waiting for client to become online, it will try to send it to its OLD address which is not valid any more.

    How would I change that thing?

    Thursday, April 23, 2009 7:10 PM
  • If message fails to deliver, it will be written to the dead-letter queue. When you get a notice that your client changed its IP, you can check that queue for messages and resend them. Please refer to this article for more info on the subject.

    Thursday, April 23, 2009 7:20 PM
  • John,

    How often my Client should be checking if its own ip address is changed ? Is there any way that will just invoke the client to send notification to service whenever its changes the ip address?

    Any already existed function that will help client as well that the new ip address is different than the prev one?
    Monday, April 27, 2009 4:44 PM
  • Hi saqib,

    this is a tricky one... The problem here is that once you hook up to a router, you get an internal IP address so basically you can't monitor the IP of your client machine. The real IP address you need to monitor is the address of your router. You could monitor the address of your router by pinging some server and parsing the response but this isn't practical at all.

    On the other hand, you could have a special method in your service that would implement the IP notification logic. Client would call that method first time around and in case of an operation timeout. When this method gets called, client's IP should be extracted (using the RemoteEndpointMessageProperty contained in the IncomingMessageProperties collection of the current operation context) and persisted.


    Wednesday, April 29, 2009 12:18 AM
  • Hi John,

    Thanks for your prompt reply. I am currently working with the sample provided here  http://msdn.microsoft.com/en-us/library/ms752254.aspx and would like to  improve it to deal with dynamic ips on the client side. Can please point me to anything that would help with this?

    Thanking you in advance.

    Monday, May 11, 2009 3:30 PM