Windows Service using Sockets

I am experiencing a wierd problem...

I have a C#.Net application Server which uses Sockets.
It listens on port 11000. and it runs as a Windows Service.

-- If I run it as a consple Application, I can connect to that port/Application from any machine on the network as well as from my local machine.

-- BUT If i install it as a Windows Service, I cannot connect to it from the network though it works just fine form the local machine.

--And one more strange issue, If I install it using the InstallUtil.exe, it works fine ! That is I can connect to that port/Application from any machine on the network as well as from my local machine.

So there must be something on the Windows Installer. Either I am missing a configuration property or Windows Installer doesnt go well with sockets at least in assigining permissions ..I dont know.

Can anyone help me out...I have spent enough time searching for it on the web.

FYI: I have tried service running under Local Service/Local System/ and also under Administrator account..but no luck.




Answer this question

Windows Service using Sockets

  • Sneath

    I am sure you have already gone through this but this is what I would do. Using the Windows Installer

    1. is the service registered
    2. Is it running
    3. Are there any config files missing
    4. Can you put some tracing and make sure that it is running and binding to the right IP Address
    5. when you connect from external machines capture a netmon trace and find out what exactly is going on - and what exception you are getting...



  • Will Barns

    Thanks for the response JonCole...

    Okay.. Let me explain it in this way.

    The Service always installs correctly, I can see it in the services list and ALWAYS I can connect to it from my local machine.  So its never a problem on the local machine. The problem is being able to access that service from the other machine.

    When I say its not working:  The Problem is (always) not being able to access the service from another machine on the network. 

    When I say it works fine: It can be accessed from another machine in the network (as well as from the local machine).

    So the problem is: It works fine if I install it using InstallUtil.exe or If I run it as a Console App. But When I install it using the Windows Installer it doesnt work.

    And in all the above cases, I am running it under Domain user account ( which belongs to admin group). I have never run it as a Network Service.

    I am on WinXP Pro.

     

     

     

     



  • eyekron

    It should not depend on how you are really installing.
    Are you sure that you are installing correctly

    Secondly if you bind to a loopback address, you won't be able to
    reach it from an external machine



  • NiravNeo

    Could this be a firewall problem

  • Leoviveke

    No, I dont have firewall installed..



  • Sepultang

    It should not depend on how you are really installing.
    Are you sure that you are installing correctly

    Thats what is wondering me. I already know what address it is binding to. Its not the loopback, but the Ip address of this machine (192.168.1.199). And I can connect to this ip from any where in the network.

    JonCole...I am not getting any SOAP Exception for this.

    This is just making me more curious.



  • pgyb

    Thanks for the clarification. Can you add logging to the application so that it logs the local IPAddress that it is binding to under both success and failure conditions Are you getting any SocketExceptions in either case

  • natashaj

    Kumar Shetgar wrote:

    --And one more strange issue, If I install it using the InstallUtil.exe, it works fine ! That is I can connect to that port/Application from any machine on the network as well as from my local machine.

    Can you expand on what you mean Here is what I understood:

    1) When Application installed on machine with Windows Installer it does not work. You cannot connect to the application.

    • Did you verify that the service was added to the list of services on the machine and that the system service is started
    • Can you add any kind of logging to your system service so that you can verify that it is running and that it has successfully bound to the port

    2) When you manually use InstallUtil.exe to install the system service, everything works fine.

    • Are you running under "Network Service" in this case also

    What OS are you on



  • rjnealtx

    Thanks guys,

    It was firewall problem.
    Earlier to turn the firewall off, I opened the Network connection, and clicked on Change Windows firewall settings and turned 'off' the firewall.
    And I always thought that this made the firewall off.
    But No....That doesnt seems to turn off the firewall...as long as the Windows Firewall Service is running. When I stopped this service, my program works.
    huh.!

    Why do I have an option (to turn off firewall)which doesnt work !




  • Windows Service using Sockets