SocketException from code not caught in try catch or Application_Error

Discussion in 'ASP .Net' started by mc, Dec 18, 2007.

  1. mc

    mc Guest

    I have a function (shown below) that I call to check if a server is present. when a server is
    present, everything is ok. however when it fails. I get an SocketException fired. On my development
    machine all seems to work and the exception is fired and caught. however on my production server the
    exception fires, it's not caught by the try catch and it's also not caught in my application_error
    handler in Global.asax. Can anyone shed any light on this?

    private bool CheckServer(string p){
    try{
    using (Socket s = new Socket(AddressFamily.Internetwork, SocketType.Stream, ProtocolType.Tcp)){
    IPEndPoint iep = new IPEndPoint(DNS.GetHostEntry(p).AddressList[0], 80);
    s.Connect(iep);
    return true;
    }
    }
    catch{
    return false;
    }
    }

    TIA


    MC
     
    mc, Dec 18, 2007
    #1
    1. Advertisements

  2. mc

    Aidy Guest

    It might be something to do with the fact that you're using "using" inside a
    try block. Try it without the "using".
     
    Aidy, Dec 18, 2007
    #2
    1. Advertisements

  3. mc

    bruce barker Guest

    most likely the page request is timing out before the socket connection
    timeout. explicity set the values.

    -- bruce (sqlwork.com)
     
    bruce barker, Dec 18, 2007
    #3
  4. mc

    mc Guest

    No change! still broke.
     
    mc, Dec 18, 2007
    #4
  5. Hi MC,

    It is also likely that there is something related to the account running
    the application. Is there any proxy that requires to visit the certain
    remote server/site? You can try switch the ASP.NET process to a domain
    account to see whether it works.

    Sincerely,

    Steven Cheng

    Microsoft MSDN Online Support Lead

    This posting is provided "AS IS" with no warranties, and confers no rights.


    --------------------
     
    Steven Cheng[MSFT], Dec 19, 2007
    #5
  6. Hi MC,

    Have you got progress on this? If still need any help, welcome to post here.

    Sincerely,

    Steven Cheng

    Microsoft MSDN Online Support Lead


    This posting is provided "AS IS" with no warranties, and confers no rights.


    --------------------
     
    Steven Cheng[MSFT], Dec 21, 2007
    #6
  7. mc

    mc Guest

    The AppPool Identity for the site in question is already a domain account is this the setting you meant.

    Consider this closed as I've moved onto an alternative solution, not perfect but it works.
     
    mc, Jan 9, 2008
    #7
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.