Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. WCF and WF
  4. How to open multiple service host for same address,binding contract?

How to open multiple service host for same address,binding contract?

Scheduled Pinned Locked Moved WCF and WF
wcfhelpcsharpwpftutorial
3 Posts 2 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    Lijo Rajan
    wrote on last edited by
    #1

    Hi All, I am giving my code below. for (int i = 0; i <= 50; i++) { ServiceHost host=new ServiceHost(); host.AddServiceEndpoint(contract, binding,"net.tcp://16.69.13.55:1000/"); host.Open(); ChannelFactory<IAsyncInterface> factory; factory = new ChannelFactory<IAsyncInterface>(binding, fullBaseAddress); iAsync = factory.CreateChannel(); ((IContextChannel)iAsync).OperationTimeout = new TimeSpan(00, 10, 00); iAsync.BeginNew(i.ToString(), new AsyncCallback(OnEndGetNew), null); } i am calling WCF service asynchronously. first time its opening host properly.but when it tries to open second time i am getting error like this. "The ChannelDispatcher at 'net.tcp://16.69.13.55:1000/FlexiAsyncServer' with contract(s) '"IAsyncInterface"' is unable to open its IChannelListener.". can any one please tell me how to solve this issue? or is there any other way to do this? Thanks Lijo.

    L 1 Reply Last reply
    0
    • L Lijo Rajan

      Hi All, I am giving my code below. for (int i = 0; i <= 50; i++) { ServiceHost host=new ServiceHost(); host.AddServiceEndpoint(contract, binding,"net.tcp://16.69.13.55:1000/"); host.Open(); ChannelFactory<IAsyncInterface> factory; factory = new ChannelFactory<IAsyncInterface>(binding, fullBaseAddress); iAsync = factory.CreateChannel(); ((IContextChannel)iAsync).OperationTimeout = new TimeSpan(00, 10, 00); iAsync.BeginNew(i.ToString(), new AsyncCallback(OnEndGetNew), null); } i am calling WCF service asynchronously. first time its opening host properly.but when it tries to open second time i am getting error like this. "The ChannelDispatcher at 'net.tcp://16.69.13.55:1000/FlexiAsyncServer' with contract(s) '"IAsyncInterface"' is unable to open its IChannelListener.". can any one please tell me how to solve this issue? or is there any other way to do this? Thanks Lijo.

      L Offline
      L Offline
      Ladislav Mrnka
      wrote on last edited by
      #2

      Hello, if you open multiple channel listeners on the same TCP port you have to use Port Sharing service and port sharing has to be allowed on the endpoint: NET.TCP Port sharing. Btw. why do you try to open 50 instances of the host for the same service when single host instance can handle 50 requests? Best regards, Ladislav

      L 1 Reply Last reply
      0
      • L Ladislav Mrnka

        Hello, if you open multiple channel listeners on the same TCP port you have to use Port Sharing service and port sharing has to be allowed on the endpoint: NET.TCP Port sharing. Btw. why do you try to open 50 instances of the host for the same service when single host instance can handle 50 requests? Best regards, Ladislav

        L Offline
        L Offline
        Lijo Rajan
        wrote on last edited by
        #3

        Hi, Thanks a lot for your reply. I will clearly explain my scenario. I have a single Service Contract. And this Interface will be implemented in different classes. Because in each class the implimentation will be different.So for opening the service host i need to provide the type of these classes. That i will come to know ony at run time. I am getting that type information from database. So each time when loop comes in the type will be diffrent.In that case how i can do it? because i will be getting multiple types from database.thats why i put it in loop. Can u please suggest me a better way to do this? Thanks Lijo

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups