1

I have an IIS server which serves a search page using SolrNet. The search index is Solr, running inside Tomcat, on a separate machine on the same subnet (in the same room).

I get intermittent connection errors from IIS to the search server, mainly (InnerException):

Error: The operation has timed out
In: System.Net.WebResponse GetResponse()
Stack Trace: at System.Net.HttpWebRequest.GetResponse()
at HttpWebAdapters.Adapters.HttpWebRequestAdapter.GetResponse()

As well as sometimes (InnerException):

Error: Unable to connect to the remote server
In: System.Net.WebResponse GetResponse()
Stack Trace: at System.Net.HttpWebRequest.GetResponse()

I believe the problem is that IIS only ever has two concurrent connections to Tomcat (which I can see using CurPorts), so eventually the calls get so backed up it times out, but I can't work out why. My preview site, on the same server, is able to create more connections, but increasing the setting using this code in web.config makes no difference:

<connectionManagement>
  <add address="*" maxconnection="100"/>
</connectionManagement>

I have already increased the SolrNet timeout to 30s using:

SolrNet.Startup.Init<SolrDataObject>(new SolrNet.Impl.SolrConnection(System.Configuration.ConfigurationManager.AppSettings["SolrURL"]) { Timeout = 30000 });

I first asked this question about these same errors - I have since found out that there are only ever two connections from IIS to Tomcat, and this seems a very likely cause for this problem to me.

Community
  • 1
  • 1
Ian Grainger
  • 5,148
  • 3
  • 46
  • 72
  • Have you tried setting [ServicePointManager.DefaultConnectionLimit](http://msdn.microsoft.com/en-us/library/system.net.servicepointmanager.defaultconnectionlimit.aspx)? – Nick Butler Jan 18 '12 at 11:39
  • possible duplicate of [Intermittent connection timeouts to Solr server using SolrNet](http://stackoverflow.com/questions/8741080/intermittent-connection-timeouts-to-solr-server-using-solrnet) – Mauricio Scheffer Jan 18 '12 at 12:32
  • 1
    I don't see how this is different from your previous question... it seems you have an issue with your operating system not letting you create more than two simultaneous connections. – Mauricio Scheffer Jan 18 '12 at 12:32
  • I agree with @MauricioScheffer that this is an issue with your operating system. Do you experience the same issues if you manually (not via SolrNet) connect to the Solr instance on Tomcat from the server that is running IIS or even from another computer? – Paige Cook Jan 18 '12 at 12:57
  • You will have to show us the whole code that is doing the HttpWebRequest in order to get more help from the community. Also, the connection limit is not between IIS and Tomcat, it is between HttpWebRequest and all HTTP sites. By default HTTP/1.1 protocol limits outgoing connections to 2 per host. – feroze Jan 18 '12 at 22:56
  • @NicholasButler I was under the impression that's what the maxconnection setting in web.config did? – Ian Grainger Jan 19 '12 at 10:01
  • @Mauricio as I said in the last line, this is a different question only because I'm pretty sure this is the cause of the connection timeouts, so if I solve this I solve that. Would it be better to edit my original question to look like this? – Ian Grainger Jan 19 '12 at 10:18
  • @feroze I didn't write the HttpWebRequest code - it's in SolrNet. Their source is available, but unfortunately involves an interface, factory and adapter, so posting it here would be a couple of screens full. – Ian Grainger Jan 19 '12 at 10:21
  • @PaigeCook I too agree that it may well be a configuration issue, the preview site, running in the same instance of IIS, can get more than two connections to Solr fine... But I don't know what the difference could be. – Ian Grainger Jan 19 '12 at 10:21

1 Answers1

0

This was because the machine.config was apparently locked only for some sites in IIS - though I'm not sure how that happened, changing the machine.config fixed this problem.

(This didn't fix the underlying problem, but I'll update that now)

Ian Grainger
  • 5,148
  • 3
  • 46
  • 72