HighTechTalks DotNet Forums  

SocketException from code not caught in try catch or Application_Error

ASP.net ASP.net discussions (microsoft.public.dotnet.framework.aspnet)


Discuss SocketException from code not caught in try catch or Application_Error in the ASP.net forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
mc
 
Posts: n/a

Default SocketException from code not caught in try catch or Application_Error - 12-18-2007 , 09:17 AM






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

Reply With Quote
  #2  
Old   
Aidy
 
Posts: n/a

Default Re: SocketException from code not caught in try catch or Application_Error - 12-18-2007 , 10:27 AM






It might be something to do with the fact that you're using "using" inside a
try block. Try it without the "using".

"mc" <mc (AT) community (DOT) nospam> wrote

Quote:
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



Reply With Quote
  #3  
Old   
bruce barker
 
Posts: n/a

Default RE: SocketException from code not caught in try catch or Application_E - 12-18-2007 , 12:17 PM



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

-- bruce (sqlwork.com)


"mc" wrote:

Quote:
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


Reply With Quote
  #4  
Old   
mc
 
Posts: n/a

Default Re: SocketException from code not caught in try catch or Application_Error - 12-18-2007 , 12:26 PM



No change! still broke.
Aidy wrote:
Quote:
It might be something to do with the fact that you're using "using" inside a
try block. Try it without the "using".

"mc" <mc (AT) community (DOT) nospam> wrote in message
news:4767d662$1 (AT) mail (DOT) hmgcc.gov.uk...

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




Reply With Quote
  #5  
Old   
Steven Cheng[MSFT]
 
Posts: n/a

Default Re: SocketException from code not caught in try catch or Application_Error - 12-19-2007 , 04:55 AM



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.


--------------------
Quote:
Date: Tue, 18 Dec 2007 17:26:43 +0000
From: mc <mc (AT) community (DOT) nospam
Newsgroups: microsoft.public.dotnet.framework.aspnet
Subject: Re: SocketException from code not caught in try catch or
Application_Error

No change! still broke.
Aidy wrote:
It might be something to do with the fact that you're using "using"
inside a
try block. Try it without the "using".

"mc" <mc (AT) community (DOT) nospam> wrote in message
news:4767d662$1 (AT) mail (DOT) hmgcc.gov.uk...

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






Reply With Quote
  #6  
Old   
Steven Cheng[MSFT]
 
Posts: n/a

Default Re: SocketException from code not caught in try catch or Application_Error - 12-21-2007 , 07:22 AM



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.


--------------------
Quote:
Organization: Microsoft
Date: Wed, 19 Dec 2007 09:55:58 GMT
Subject: Re: SocketException from code not caught in try catch or
Application_Error

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.


Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.