Out of interest, you say it's a "softphone" application - is this actually running on a phone of some description, using the compact framework, or is it a desktop app? Basically, make it as close to the real thing as possible. If your actual application is going to connect elsewhere, then that's where your test should check as well. Of course, that may well not be the problem in your case, but it's worth a try. The moral is to always put HttpWebResponses in a using statement. Is the network connection definitely up before you may the request? Are you definitely not making any requests beforehand? I ask because I notice you're not disposing of the response - if that happens elsewhere as well, you may find that you're running up against the connection pool only giving you a couple of connections to a particular server. What is the softphone going to use for its real communication? Is that going over HTTP/HTTPS to the same web site? If so, that's absolutely the right way to go - the next step is to work out why it's taking so long. Private extern static bool InternetGetConnectedState(ref InternetConnectionState_e lpdwFlags, int dwReserved) īool isConnected = InternetGetConnectedState(ref flags, 0) If (response.StatusCode = HttpStatusCode.OK)Ĭonsole.WriteLine("IsSIPServerAvailable: " + response.StatusCode) HttpWebResponse response = (HttpWebResponse)request.GetResponse() Request.Credentials = CredentialCache.DefaultNetworkCredentials HttpWebRequest request = (HttpWebRequest)WebRequest.Create("") So the only one I can think of is the HttpWebRequest class. This is because the softphone would freeze until a response is returned. The proxy doesn't support SOCKS so cannot use the Sockets class. To I can't use the TCPClient class (doesn't have a proxy property). Sometime a proxy will be used at the client's office. But takes too long when I use the HttpWebRequest class However, when I browse to their website, it takes less than a second to load the page. I am not sure if this is not a very efficient way to test. However, I have noticed that the response is taking too long to respond. If the response is ok, then the Internet connection can proceed. So, want I have done is used the httpWebRequest class to connect to our clients website. Before the user makes a call, the softphone has to test if there is an active Internet connection. I am using this code to connect to our client website.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |