Anuj Varma Software • Cloud • Security • AI

WCF and Publish Subscribe–A Full Example: Running the Client (Subscriber)

This entry is part 6 of 6 in the series WCF Publish Subscribe - A Full Example in C#, Step by Step

Now that all the pieces are in place, we are ready to run our client program.  The first error I encountered was:

AddressAccessDeniedException: HTTP could not register URL http://+:8080/

Step 1 – On running the Subscriber project, you may get an AddressAccessDenied exception (especially if you are on Windows Vista). To work around this error, launch a command prompt as administrator (right click and Run As Admin). In the command prompt, type :

netsh http add urlacl url=http://+:26836/ user=DOMAIN\UserName (do you need to lookup your username or your domain name ?).

Step 2 – What I needed was to provide local access to the address on which the client was running (the callback address). A tool called HttpNamespaceManager allowed me to grant that access to the http address+port that I needed. (See http://blogs.msdn.com/b/paulwh/archive/2007/05/04/addressaccessdeniedexception-http-could-not-register-url-http-8080.aspx for details). A quick summary of how to work around this error is given below:

1. Copy the http namespace from your DOS prompt.

dos_copy_url

2. Launch HttpNamespaces exe – Click Add – Paste the copied URL into the URL textbox that appears.

add_http_namespace

3. Grant access to the following USER GROUPS – USERS and LOCAL SERVICE. Once you add these groups, select them and check the ‘GenericExecute’ box as shown below.

USERS_group   execute_perms_users_group

Summary

Once you get past the Unhandled Exception: System.ServiceModel.AddressAccessDeniedException (using the steps above), you should be able to run the Subscriber console app (make sure you run the service first by starting the MagazineService project as shown below. You CAN run both from the same Visual Studio Solution Explorer).

launch_service

 

download full source codeWCFPublishSubscribe.zip

Anuj holds professional certifications in Google Cloud, AWS as well as certifications in Docker and App Performance Tools such as New Relic. He specializes in Cloud Security, Data Encryption and Container Technologies.

Initial Consultation

Anuj Varma – who has written posts on Anuj Varma.


Series NavigationWCF and Publish Subscribe–A Full Example: Client Code

11 comments

  1. Hi. Great post! I downloaded your solution, run it and something went wrong. There’s an error: “Source file ‘WCFPublishService\Consoleapplication1\Properies\AssemblyInfo.cs’ could not be opened(‘Unspecified error’)”

    Im new in WCF as well as in Publish-Subcribe framework. I’d like your example be my guide in this. Please help. Thank you.

    1. Source code should be on the last post (number 6).
      Also, I would recommend trying another post – just search for IObservable on the website – you should see a post describing two new interfaces in c# for pub-sub.

  2. Hello
    Thanks for this nice article.

    I tried to have a look with the source code associated and I get something strange
    I execute the wcf from vs and I run from the command line the subscriber.

    Do you have any ideas why when I tried to execute this example I egt the following error :

    Unhandled Exception: System.ServiceModel.AddressAlreadyInUseException: HTTP coul
    d not register URL http://+:26836/myClienta1c0ab96-20ab-40bc-958a-6acf5794c8b2/
    because TCP port 26836 is being used by another application. —> System.Net.Htt
    pListenerException: The process cannot access the file because it is being used
    by another process
    at System.Net.HttpListener.AddAllPrefixes()

    Everything seems ok but I dont know what I do wrong on my usage.

    Thanks by advance

      1. I have retest with your suggestion but I till having the issue ( and different from the page)

        I execute the service first on port 26836
        I try to subscribe to the service using the subscribe project and I still having an issue coming : port already opened

        the error came with folling exception
        System.ServiceModel.AddressAlreadyInUseException:

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.