Beginners question - cannot query data remotely

Nov 10, 2014 at 11:06 AM
I've installed complete brightstardb on one computer. BrightstarDB win service is running, so it looks OK.
I've started Polaris management tool, created connection (type rest) and new store.
On second computer where VS2013 is, I've installed SDK and created console app as described in Developing Quick start. I changed type connection string to be of type rest, and set endpoint to http://myfirstmachine:8090/brigthstar.
I've seed some data from my console application (remotely). It exits without error.
But when I try to run a query against my store I get timeout.
Example query that gets timeout:
var qs = ctx.Queues.OrderBy(qq=>qq.Client.Name).ToList<IQueue>();
When I copy my application to the computer with brightstardb service and run it. It shows data. So the code is working.
So I have succeeded to write to brightstar remotely but not to read data.
Any Idea or tip how to use brightstardb from another computer?
Thanks in advance.
Coordinator
Nov 10, 2014 at 11:16 AM
Hi,

It seems strange if you can post data to the server but then not query it - are you sure that your console app is actually writing to the remote server?

A few questions to get started:

1) Can you access the remote BrightstarDB service from your browser (e.g. if you open a browser with the address http://myfirstmachine:8090/brightstar/ do you see anything)?
2) What is the connection string you are using in your console app to access the remote BrightstarDB service?
3) Did you set up any security on the remote server or are you just using the standard "out of the box" configuration?
4) Is the remote service running under IIS or are you just running the console application / windows service?

Cheers

Kal
Nov 10, 2014 at 11:58 AM
Hi Kal,
I'm pretty sure because it was an empty store. What I did:
  • I installed BrightstarDB
  • I started polaris and create new connection and termstore (TicketingStore)
  • I created a console app on remote computer
  • I ran it, without error. I didn't verify it, because i don't know how to create sparql query in polaris
  • I change the code in my app (commented seed code and add query code) and ran it. Got timeout error
  • I copied app binaries to server with brightstardb installed, and ran it. It showed my 3 items (I've added in first iteration)
  • So my conclusion was that I successfully added those items when my code ran without error.
And regarding your questions:
1)No I cannot. I get Http error 500
2)Here it is
string connString = "type=rest;endpoint=http://dbdev3:8090/brightstar;storename=TicketingStore;";
3) No It's out of the box configuration
4) Windows service,
Coordinator
Nov 10, 2014 at 12:29 PM
Hi again,

Yep, it does sound like the code ran the update in that case. That is really strange - the connection string looks fine, and if you get a 500 error when you try to browse to the service that would indicate something bad happening on the server side. It might be worth looking in the BrightstarDB server data directory for the log.txt file (the service should be logging there) - some fatal errors will also get logged to the event log so it would be worth looking there too. Did you get a stack trace or any other information from the 500 error. A fatal error of some sort seems the most likely explanation - it sounds like something is causing the service to die and of course once it is dead any subsequent connections will timeout.

BTW I am assuming that you are running BrightstarDB version 1.7.1 (the most recent release), but if you are using an older release or if you are using code from GitHub that you have built yourself, let me know.

Its hard to analyse these sorts of issues remotely unfortunately, but if you do have the log file that could be really helpful. In the meantime, some other things to check out are:

1) Do you have any other applications on there trying to access the same BrightstarDB data directory directly rather than through the REST interface of the service?. This includes Polaris. If so, stop them all and restart the service.

2) Does the user that your Windows service is running as have full control on the BrightstarDB data directory and all of its subdirectories and files. If not, update the directory security permissions and restart the service.

3) Are you sure the endpoint reservation has been registered correctly - if you installed through the BrightstarDB installer, then it should have done this for you, but if you installed manually or built BrightstarDB from source then you need to use the following command in an elevated command prompt:
netsh http add urlacl url=http://+:8090/brightstar/ user=Everyone
It might also be worthwhile trying to run the service in a command prompt window so you can see it logging as it runs. To do this, stop the Windows Service, then start up a command prompt (run as Administrator) and cd to the directory where the service is installed and run BrightstarService.exe - this should start up the server in its "application" mode where it copies its log messages to the console. If there is a problem with the service starting up then it should also be easier to see that in the console because it will be much more obvious when the application exits.

Cheers

Kal
Nov 10, 2014 at 2:37 PM
Edited Nov 10, 2014 at 2:43 PM
Here is quick update
  1. I'm using version 1.7.1 and setup BrightstarDB-1.7.1.0-Setup.exe
  2. I enabled logging (config file had wrong log file path)
  3. When I try to open http://localhost:8090/brightstar in browser all i got is BrightstarDB Information: 0 : List Stores DateTime=2014-11-10T15:15:31.7632453Z
  4. When I try to run my app remotely I got:
    BrightstarDB Information: 0 : check store exists store TicketingStore
    DateTime=2014-11-10T15:17:24.9995905Z
    BrightstarDB Information: 0 : check store exists store TicketingStore
    DateTime=2014-11-10T15:17:25.0776925Z
  5. When I delete store and create new one.
    a)On first run I can read data remotely (I tried write and read in same session)
    b) on second run I get the timeout with following callstack:
  at System.Net.HttpWebRequest.GetRequestStream(TransportContext& context)
   at System.Net.HttpWebRequest.GetRequestStream()
   at BrightstarDB.Client.BrightstarRestClient.AuthenticatedFormPost(String relativePath, IEnumerable`1 postBodyParameters, String acceptType)
   at BrightstarDB.Client.BrightstarRestClient.ExecuteQuery(String storeName, String queryExpression, IEnumerable`1 defaultGraphUris, Nullable`1 ifNotModifiedSince, SparqlResultsFormat resultsFormat, RdfFormat graphFormat, ISerializationFormat& streamFormat)
   at BrightstarDB.Client.BrightstarRestClient.ExecuteQuery(String storeName, String queryExpression, IEnumerable`1 defaultGraphUris, Nullable`1 ifNotModifiedSince, SparqlResultsFormat resultsFormat, RdfFormat graphFormat)
   at BrightstarDB.Client.BrightstarRestUpdatableStore.ExecuteQuery(String queryExpression, IList`1 datasetGraphUris)
   at BrightstarDB.Client.RemoteDataObjectStore.ExecuteSparql(SparqlQueryContext sparqlQueryContext)
   at BrightstarDB.EntityFramework.BrightstarEntityContext.ExecuteQuery[T](SparqlLinqQueryContext sparqlLinqQueryContext)
   at BrightstarDB.EntityFramework.Query.EntityFrameworkQueryExecutor.ExecuteCollection[T](QueryModel queryModel)
   at Remotion.Linq.Clauses.StreamedData.StreamedSequenceInfo.ExecuteCollectionQueryModel[T](QueryModel queryModel, IQueryExecutor executor)
   at Remotion.Linq.Clauses.StreamedData.StreamedSequenceInfo.ExecuteQueryModel(QueryModel queryModel, IQueryExecutor executor)
   at Remotion.Linq.QueryModel.Execute(IQueryExecutor executor)
   at Remotion.Linq.QueryProviderBase.Execute(Expression expression)
   at Remotion.Linq.QueryProviderBase.System.Linq.IQueryProvider.Execute[TResult](Expression expression)
   at Remotion.Linq.QueryableBase`1.GetEnumerator()
   at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
   at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
   at BrightStarDbTest.Program.Main(String[] args) in c:\Users\drasko.popovic\Documents\Visual Studio 2013\Projects\BrightStarDbTest\BrightStarDbTest\Program.cs:line 19
   at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
   at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
   at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
   at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.ThreadHelper.ThreadStart()
  1. When I ran it from the same computer. everything works no meter how many times I ran it. And log is full with statements and queries.
BrightstarDB Information: 0 : Query TicketingStore CONSTRUCT {?qq ?qq_p ?qq_o .?qq <http://www.brightstardb.com/.well-known/model/sortValue0> ?qq_sort0 .?qq <http://www.brightstardb.com/.well-known/model/selectVariable> "qq" .}WHERE {?qq ?qq_p ?qq_o .{ SELECT ?qq ?qq_sort0 WHERE {?qq a <http://brightstardb.com/namespaces/default/Queue> .?qq <http://brightstardb.com/namespaces/default/client> ?v0 .?v0 <http://brightstardb.com/namespaces/default/name> ?v1 . BIND (?v1 AS ?qq_sort0) .} ORDER BY ASC(?v1)} }
    DateTime=2014-11-10T15:40:47.5092149Z
BrightstarDB Information: 0 : Query CONSTRUCT { 
Coordinator
Nov 10, 2014 at 2:58 PM
Hi,

Thanks for the update! The stack trace you quoted above looks like it is from the client side - I just wonder if the server-side log of the same operations might help me work out what is going on. Do you have anything else in the server log from when you make the remote connections? It might have got lost in the log files by now if you did lots of local testing with the same store, so it might be an idea to to stop the service, delete the log file and the store directory on the server and then restart the server and just run your application on the client machine.

This seems like basic functionality that should just work. Of course most of my unit testing is based on client and server running on the same machine (which as you say is working just fine). The fact that you can create one session remotely and then it is the subsequent session that fails is also really strange. I'll have to set up a little two-machine test environment and try this out locally. If you can share your code (either here or email me at kal AT brightstardb DOT com), that would also help so that we are on the same page.

A couple of networking things to check:

1) Can you ping the server by name from the client ?
2) Can you connect to another service (e.g. IIS) on the server ?
3) Is the firewall active on the server and if it is does turning it off help ? (This isn't a permanent solution but just to rule it out)
4) If there is anything else about your environment / machines that you think might be relevant please let me know.

Cheers

Kal
Nov 12, 2014 at 8:27 AM
It's not the network problem, because when I create new store in brigstardb I can read and write data to it remotely, but any subsequent remote access to bristardb gives me timeout.
if I delete store and create new one I can access it again remotely first time. And of course next time I try to get data I get timeout.


When timeout occurs, there is nothing in the log file except this four lines I already sent you:
BrightstarDB Information: 0 : check store exists store TicketingStore
DateTime=2014-11-10T15:17:24.9995905Z
BrightstarDB Information: 0 : check store exists store TicketingStore
DateTime=2014-11-10T15:17:25.0776925Z
Computer where I installed BrightstarDB is hyper-V virtual machine with Windows Server 2008 R2. It does not have IIS (as I understand it's not required)

After last tests I've made, I can see that I made a wrong question. It's not that I can write and not read remotely.
Real problem is:
I can write and read remotely on a newly created store. Any subsequent access gives me timeout error.