BrightStarDB Under IIS in Amazon EC2 instance

Nov 29, 2016 at 3:33 AM
Edited Nov 29, 2016 at 8:07 AM

I have set up brightstardb on a amazon virtual server with IIS. I can access the management site from a remote machine fine. However with the following code:
            using (var Ctx = new MyEntityContext())
                Console.WriteLine($"{(DateTime.Now - t)} to open the first database connection.");

            t = DateTime.Now;
            using (var Ctx2 = new MyEntityContext())
                Console.WriteLine($"{(DateTime.Now - t)} to open the second database connection.");
the first new MyEntityContext appears to succed but the second new MyEntityContext() fails with an exception BrightstarDB.Client.BrightstarClientException - "HTTP HEAD to MachSvcTest failed. Could not process server response." This same code works fine with a local windows service based brightstardb server. It makes no difference whether I configure authentication, standard port or customer port.
This may be the same thing as in this discussion

What am I missing?
Nov 29, 2016 at 8:21 AM
Edited Nov 29, 2016 at 9:17 AM
Further information. The following is the exception and call stack information:

Unhandled Exception: BrightstarDB.Client.BrightstarClientException: HTTP HEAD to MachSvcTest failed. Could not process server response. ---> System.Net.WebException: The operation has timed out
at System.Net.HttpWebRequest.GetResponse()
at BrightstarDB.Client.BrightstarRestClient.AuthenticatedHead(String relativePath)
--- End of inner exception stack trace ---
at BrightstarDB.Client.BrightstarRestClient.AuthenticatedHead(String relativePath)
at BrightstarDB.Client.BrightstarRestClient.DoesStoreExist(String storeName)
at BrightstarDB.EntityFramework.BrightstarEntityContext.AssertStoreFromConnectionString(ConnectionString connectionString)
at BrightstarDB.EntityFramework.BrightstarEntityContext..ctor(String updateGraphUri, IEnumerable`1 datasetGraphUris, String versionGraphUri)
at MachSvc.Models.MyEntityContext..ctor() in C:\Development\Projects\KDP\MachSvc\MachSvc.Core\Models\MyEntityContext.cs:line 87
at ContextProfile.Program.Main(String[] args) in C:\Development\Projects\KDP\MachSvc\ContextProfile\Program.cs:line 22

Oh yes I am using the latest release of BrightSTarDB version 1.13.2. The server is a server 2016 server with IIS 10. Should I try a 2012 server?

Nov 29, 2016 at 9:20 AM
Edited Nov 29, 2016 at 9:21 AM
I found a post on a forum where the second http request was timing out and calling GC.Collect() after disposing of the resquest solved the issue. So I tried that and called GL.Collect() after each EntityContext instance and that works in this case also. It is a bit weird though that it is an issue for a remote server but not the local server. Kevin.
Nov 29, 2016 at 11:07 PM
Edited Nov 29, 2016 at 11:08 PM
With a little research I discovered it has to do with the number of connections the client is allowed to make to a remote server and I placed the following in the App.config and removed the GC.Collect() lines.
      <add address="*" maxconnection="500"/>
The number of 500 was arbitrary, I am sure it doesn't need to be that many. All works good now. So I hope this helps somebody else.