One thought ...

Hi,

Is there any reason why when I run the sample from the search SDK on my personal server at home it works perfectly fine, yet when I load the same code to my hosted server I get an error message saying that the service did not repond correctly?

(System.Net.WebException: Unable to connect to the remote server > System.Net.Sockets.SocketException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress) at System.Net.Sockets.Socket.InternalConnect(EndPoint remoteEP) at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Int32 timeout, Exception& exception) End of inner exception stack trace at System.Net.HttpWebRequest.GetRequestStream() at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters) at com.msn.search.soap.MSNSearchService.Search(SearchRequest Request) in c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\da57b35a\195329d3\App_WebReferences.e3jjpxdh.0.cs:line 47 at ASP.searchproxy_aspx.Page_Load(Object sender, EventArgs e) in e:\kunden\homepages\33\d174594834\searchProxy.aspx:line 57)...

Any thoughts? I'm rather stumped. No code has changed. The only thing that comes to mind is that maybe the hosting server doesn't allow communication via services? I can run services fine, but this is the only code that I have that accesses any services. Any help is greatly appreciated.

[1821 byte] By [StevenSyfuhs] at [2007-12-24]
# 1

"The only thing that comes to mind is that maybe the hosting server doesn't allow communication via services?"

I don't think so.

Have you verified that the code, the files and the directory structure are the same on the local server and the shared hosting server?

me* at 2007-8-31 > top of Msdn Tech,Windows Live Developer Forums,Windows Live Search: Development...
# 2

I figured that could be a possibility, but it's very straightforward: everything is in the root directory except the .js files, which is the same setup locally.

/masterpage.master - Holds the search stuff
/searchProxy.aspx - the file called from within the masterpage to display the search results
/scripts/layoutLibrary.js - used for html rendering
/scripts/searchClient.js - the code that does all the XMLHTTPRequest junk

the masterpage and layoutlibrary are unimportant to communications.

heres the searchProxy.aspx file:
(Sorry about the formatting)

<%@ Page Language="C#" AutoEventWireup="true" Debug="true" %>
<%
@ Import Namespace="com.msn.search.soap" %>
<%
@ Import Namespace="System.Web.Configuration" %>
<%
@ Import Namespace="System.Globalization" %>
<%
@ Import Namespace="Microsoft.Security.Application" %>
script language="C#" runat="server">

void Page_Load(object sender, EventArgs e) {
try {

string key = Request.QueryString["searchKey"];

if (!String.IsNullOrEmpty(key)) {
string offset = Request.QueryString["searchOffset"];
string count = Request.QueryString["searchCount"];
CultureInfo ci = new CultureInfo("en-us");
MSNSearchService s = new MSNSearchService();
SearchRequest sr = new SearchRequest();
SourceRequest[] srcr = new SourceRequest[1];
srcr[0] =
new SourceRequest();
srcr[0].Source =
SourceType.Web;
if (!String.IsNullOrEmpty(count)) {
int iCount = Int32.Parse(count, ci);
if (iCount > 0 && iCount <= 50)
srcr[0].Count = iCount;
else
srcr[0].Count = 10;
}
else
srcr[0].Count = 10;
if (!String.IsNullOrEmpty(offset)) {
int iOffset = Int32.Parse(offset, ci);
if (iOffset > 0 && iOffset <= 250)
srcr[0].Offset = iOffset;
else
srcr[0].Offset = 0;
}
else
srcr[0].Offset = 0;
sr.Requests = srcr;
sr.CultureInfo =
"en-us";
sr.Flags =
SearchFlags.MarkQueryWords;
sr.Query = Server.UrlDecode(key);
sr.SafeSearch =
SafeSearchOptions.Strict;
sr.ApID = WebConfigurationManager.AppSettings.Get("appIDSearch");
SearchResponse srsp = s.Search(sr);
PrintResults(srsp);
}
}
catch (Exception fault) {
Response.Write(fault.ToString());
}
}

private void PrintResults(SearchResponse searchResponse)
{
...... nothing important here
}
</script>

StevenSyfuhs at 2007-8-31 > top of Msdn Tech,Windows Live Developer Forums,Windows Live Search: Development...
# 3

Hello Steven,

have you really verified the whole application including the configuration file web.config? For example your code shows that you have stored the Application ID for the Web Service in the the web.config. The web.config also sets the url of the service. Does your web.config on the hosting server has the correct settings?

me* at 2007-8-31 > top of Msdn Tech,Windows Live Developer Forums,Windows Live Search: Development...
# 4
For the time being I switched it so the AppID is directly in the code. That is appID = "...". I checked the web.config file and that too is the same. Just for kicks I tried creating a new web resource and overwrote the old discomap file with no avail. Is there any source that you would like to take a look at that might help?
StevenSyfuhs at 2007-8-31 > top of Msdn Tech,Windows Live Developer Forums,Windows Live Search: Development...
# 5

I do not know why you get this error message, Steve.

You should check your whole concept, the whole deployment and the hosting server.

Call the support of your hosting provider and ask if they have a problem to connect to external ressources.

Add a Web Reference to a Service and test if the server is able to connect.

me* at 2007-8-31 > top of Msdn Tech,Windows Live Developer Forums,Windows Live Search: Development...
# 6
Thanks for the suggestions. I'll see what I can do. With any luck it will be something simple. I'll write up how I managed to fix it, when I finally get it to work. Thanks again for the suggestions.
StevenSyfuhs at 2007-8-31 > top of Msdn Tech,Windows Live Developer Forums,Windows Live Search: Development...
# 7
I tried copying the SDK sample to the remote server to see if there was a problem with my own changes, however I end up with the same errors. I am thinking it may be the result of the host.
StevenSyfuhs at 2007-8-31 > top of Msdn Tech,Windows Live Developer Forums,Windows Live Search: Development...
# 8

Did you configure a proxy in your ASP.Net app?

if not, there are two solutions for you:

1. MSNSearchService s = new MSNSearchService();

WebProxy p = new WebProxy("YourProxy", true);

s.Proxy = p;

2. add Node system.net in your web.config file

<system.net>
<defaultProxy>
<proxy usesystemdefault="false" proxyaddress="YourProxy" bypassonlocal="true"/>
</defaultProxy>
</system.net>

I wish it can help you.

Good luck.

PeterPeng at 2007-8-31 > top of Msdn Tech,Windows Live Developer Forums,Windows Live Search: Development...
# 9

The other way round:

Perhaps his problem was that he might have configured a proxy server for local testing but there is no proxy on the web farm. This would explain the connection problems.

me* at 2007-8-31 > top of Msdn Tech,Windows Live Developer Forums,Windows Live Search: Development...

Windows Live Developer Forums

Site Classified