1
votes

I am starting to learn RavenDB. I installed Server version on the server machine, and added Client dlls to a simple console application. When I am trying to run the application, it gives me a WebException: "The request was aborted: The request was canceled."

Here is the code:

public class Article : AbstractIndexCreationTask<Article>  
  {
    public string Id { get; set; }
    public string Text { get; set; }
    public string Title { get; set; }

    public Article()
    {
        Map = articles => from article in articles select new { article.Text };  
    }
} 

       static void Main(string[] args)
    {
        var ravenIntroArticle = new Article()
        {
            Text = "RavenDB fits into a movement that is called ...",
            Title = "RavenDB Introduction",
        };

        var csharpUsingArticle = new Article()
        {
            Text = "The full value of the C# using statement ...",
            Title = "Your Friend the C# Using Statement",
        };

        var nutsAndProteinArticle = new Article()
        {
            Text = "Nuts are a great source of protein ...",
            Title = "Nuts and Protein",
        };

        using (IDocumentStore documentStore = new DocumentStore() { Url = "http://rtest01:8081" })
        {
            documentStore.Initialize();
            using (IDocumentSession session = documentStore.OpenSession())
            {
                session.Store(ravenIntroArticle); // the exception happens here
                session.Store(csharpUsingArticle);
                session.Store(nutsAndProteinArticle);
                session.SaveChanges();
            }
        }

enter image description here

Here is what happens when I try to run it on local server "http://localhost:8080"

enter image description here

Could you please tell what I am missing?

Thanks.

2
We need some more information like: Is the server running in IIS? If thats the case, then you may need to adjust persmissions, and chage it from "Get" to "All" in raven.server.config. - VoidMain
Please see the picture in my edited post. - David Shochet
Do you have any firewalls between the machines? What is the security setup? What happens when you run it all on a single machine? - Ayende Rahien
I should be able to connect to the server. In fact, I can access sample data on the server through the Studio: rtest01:8081/raven/studio.html#/home?database=Default - David Shochet
I tried it on the local host. Please see my updated question. - David Shochet

2 Answers

1
votes

Your port 8080 in the Code Url "http://rtest01:8080" does not match the port 8081 shown in the console running RavenDb Server.

0
votes

Well it took me a bit to realize what was wrong with that code but now that i see its really clear, you're trying to store an AbstractIndexCreationTask<Article> instead of a POCO class, lets show it witha a sample:

//This is the POCO entity that we will be storing into Raven
public class Article
{
    public string Id { get; set; }
    public string Text { get; set; }
    public string Title { get; set; }
}

//This is the IndexCreationTask that builds the index
public class Article_Text : AbstractIndexCreationTask<Article>
{
    public Article_Text()
    {
        Map = articles => from article in articles select new { article.Text };
    }
}

static class Program
{
    static void Main()
    {
        var ravenIntroArticle = new Article()
        {
            Text = "RavenDB fits into a movement that is called ...",
            Title = "RavenDB Introduction",
        };

        var csharpUsingArticle = new Article()
        {
            Text = "The full value of the C# using statement ...",
            Title = "Your Friend the C# Using Statement",
        };

        var nutsAndProteinArticle = new Article()
        {
            Text = "Nuts are a great source of protein ...",
            Title = "Nuts and Protein",
        };

        using ( IDocumentStore documentStore = new DocumentStore { Url = "http://rtest01:8081" }.Initialize() )
        {
            // This is the static call to create the index
            IndexCreation.CreateIndexes( typeof( Article_Text ).Assembly, documentStore );
            using ( IDocumentSession session = documentStore.OpenSession() )
            {
                session.Store( ravenIntroArticle ); // no more exceptions here!
                session.Store( csharpUsingArticle );
                session.Store( nutsAndProteinArticle );
                session.SaveChanges();
            }
        }

    }
}