[libRETS-users] librets and innovia

689 views
Skip to first unread message

Majid Tahir

unread,
Dec 16, 2011, 4:01:32 PM12/16/11
to libret...@crt.realtors.org
Hello all,

I am trying to make a search request using the C# librets wrapper and I am getting the following error:

The data stream ended before the XML parser could parse everything.
This can happen if the network connection terminates before all the data has been received.

I am using the sample code on the developer guide to make my search request:

 SearchRequest searchRequest = session.CreateSearchRequest(
                    "Property", 
                    "RES", 
                    "(ListPrice=300000-)");
                searchRequest.SetStandardNames(true);
                searchRequest.SetSelect("ListingID,ListPrice,Beds,City");
                searchRequest.SetLimit(SearchRequest.LIMIT_DEFAULT);
                searchRequest.SetOffset(SearchRequest.OFFSET_NONE);
                searchRequest.SetCountType(SearchRequest.CountType.RECORD_COUNT_AND_RESULTS);
                session.SetModeFlags(RetsSession.MODE_CACHE);
                session.SetModeFlags(RetsSession.MODE_NO_STREAM);
                SearchResultSet searchResults = session.Search(searchRequest);
I am successfully logged in before I run the search query.  Does anyone have any suggestions as to what I am doing wrong?

Thanks in advance


Dylan Thompson

unread,
Dec 16, 2011, 4:56:40 PM12/16/11
to For discussion and help for and by the users of the libRETS C++ library
Majid Tahir,

In my experience getting this error means that you need to use either a less complicated query or a query that returns a smaller set of data, in your case I would assume the latter.

Perhaps the RETS server stores non-active listings in the table, so when you query for any listing under $300,000, it may be pulling many thousands of inactive listings.  Then the connection terminates before all the information is sent through and then you get your error.  You might specify to only get active listings (if thats what you are looking for) or some other criteria which would narrow down the query.

Maybe you should be using offset to download information?  Using offset would allow you to download all the listings in a series of small batches instead of all at once.

You could even write something that can do multiple smaller queries instead of one large one.  E.G. instead of querying for every listing under $300,000, first query for listings between 0 and $50,000, then $50,001 and $100,000, then $100,000 and $150,000, etc.

When you have exhausted all means of reducing the complexity of the query and/or reducing the size of the data set resulting from each individual query, and you still get this error, you will probably have to contact Innovia tech support.  I had an experience with an Innovia server where any query on a particular field would result in this error, no matter how small or large the data set may have been or how complicated the query was.  They were able to resolve this issue for us over the course of a couple months.

Does anyone know if the flags that are being set could contribute to causing the error?

Best of luck.

-Dylan Thompson

_______________________________________________
libRETS-users mailing list
libRET...@crt.realtors.org
http://mail.crt.realtors.org/mailman/listinfo/librets-users


Majid Tahir

unread,
Dec 16, 2011, 5:43:47 PM12/16/11
to For discussion and help for and by the users of the libRETS C++ library
Dylan, 

Thanks for responding.  I dont think that it is the data set size that is the problem because even if I change the query to something that should return a very small number  of hits if any like (ListPrice=0-) or (ListPrice=5-)

I am still getting the same error. I also tried setting an offset to see if that would alleviate the issue but no luck. Ill try to change the search criteria to something 
other than ListPrice to see if that is somehow related.

Keith T. Garner

unread,
Dec 16, 2011, 6:09:23 PM12/16/11
to For discussion and help for and by the users of the libRETS C++ library
The code snippet you send doesn't actually show you processing the search results. What's your loop on searchResults.hasNext look like?

Right now its closing off because you haven't processed any data that I can see. Also, you might want to try explicitly setting the RETS version to 1.5 or 1.72 when you set up the session.

Keith

--
Keith T. Garner - kga...@realtors.org - 312-329-3294 - http://realtor.org/
National Association of REALTORS® - VP - Information Technology Services

Dylan Thompson

unread,
Dec 16, 2011, 6:09:50 PM12/16/11
to For discussion and help for and by the users of the libRETS C++ library
Majid,

This sounds very similar to the problem I had mentioned previously.  Perhaps looking for another suitable field to query on will be the fastest way to get around this.  Having Innovia look at and fix my problem took quite a while.  Hope you get this resolved.

-Dylan

Mark Klein

unread,
Dec 16, 2011, 6:14:29 PM12/16/11
to For discussion and help for and by the users of the libRETS C++library
On Dec 16, 2011, at 4:01 PM, Majid Tahir <mta...@gmail.com> wrote:

I am using the sample code on the developer guide to make my search request:

 SearchRequest searchRequest = session.CreateSearchRequest(
                    "Property", 
                    "RES", 
                    "(ListPrice=300000-)");
                searchRequest.SetStandardNames(true);
                searchRequest.SetSelect("ListingID,ListPrice,Beds,City");
                searchRequest.SetLimit(SearchRequest.LIMIT_DEFAULT);
                searchRequest.SetOffset(SearchRequest.OFFSET_NONE);
                searchRequest.SetCountType(SearchRequest.CountType.RECORD_COUNT_AND_RESULTS);
                session.SetModeFlags(RetsSession.MODE_CACHE);
                session.SetModeFlags(RetsSession.MODE_NO_STREAM);
                SearchResultSet searchResults = session.Search(searchRequest);
Don't use the MODE_NO_CACHE and MODE_NO_STREAM and see what happens.  If that fails, use the sample program I provide and see if your installation is functional.  Use the --url switch to set the URL to  http://www.dis.com:6103/rets/login Instead of the NAR demo site which I believe is no longer up. 



Regards,

M.
--
To quote my Bro: "Please forgive spelling and grammar mistakes, they're the fault of [his] iPhone."

Majid Tahir

unread,
Dec 21, 2011, 12:05:43 PM12/21/11
to For discussion and help for and by the users of the libRETS C++ library
No luck.  Ive tried changing the search query, setting an offset, setting a limit, removing the mode flags but I keep getting the same error.  I think I may have to not use libRETS and just manually create the http posts via c# and see if i can do it that way.  Does anyone have any good examples of accessing RETS data manually instead of using libRETS?  I havent found any so far.  Thanks for the help everyone.  

Dylan Thompson

unread,
Dec 21, 2011, 12:59:12 PM12/21/11
to For discussion and help for and by the users of the libRETS C++ library
Majid,

You might want to contact the RETS vendor first and see if there is something they can do to help.  The real problem could be server-side, so you might still have issues even with a lower level solution.

Also did you try explicitly setting the RETS version to 1.7.2 or 1.5 as Keith suggested?

Best of luck!

-Dylan

Majid Tahir

unread,
Dec 21, 2011, 1:57:32 PM12/21/11
to For discussion and help for and by the users of the libRETS C++ library
I think you might be right Dylan.  I tried without libRETS and I am still getting errors.  looks like the XML being returned is not valid for some reason.  Secondly, I just got access to another MLS and just with some minor modifications I got my original code working and successfully making queries.  I did try setting the RETS version but it made no difference.

Tony Manhollan

unread,
Dec 21, 2011, 2:31:27 PM12/21/11
to Majid Tahir, For discussion and help for and by the users of the libRETS C++ library
Are you sure your class and field names are correct? In all of the Innovia systems I've worked with, RES is not a valid class and Beds is not a valid field--in my experience, they are ResidentialProperty and Bedrooms, respectively. Check your metadata to be sure. Also you're using StandardNames. In my experience with Innovia's systems, the SystemNames match the StandardNames (so the names I mentioned are valid for either standard or system names), but that's not necessarily always the case. Be careful with StandardNames.

Majid Tahir

unread,
Dec 21, 2011, 4:06:07 PM12/21/11
to Tony Manhollan, For discussion and help for and by the users of the libRETS C++ library
Tony, 

I think your comments made me progress a little further.  I am no longer getting an error when calling session.Search(searchRequest), however it is returning me an empty set.  Here is my code:


SearchRequest searchRequest = session.CreateSearchRequest(
                "Property",
                "ResidentialProperty",
                "(LIST_87=2009-02-01T00:00:00+)");
            searchRequest.SetStandardNames(false);
           
            searchRequest.SetLimit(5);
            searchRequest.SetCountType(SearchRequest.CountType.RECORD_COUNT_AND_RESULTS);
         
          SearchResultSet searchResults = session.Search(searchRequest);
           
          
            Console.WriteLine("Record count: " + searchResults.GetCount());
            Console.WriteLine();
           IEnumerable columns = searchResults.GetColumns();
            while (searchResults.HasNext())
            {
               foreach (string column in columns)
               {
                    Console.WriteLine(column + ": " + searchResults.GetString(column));
               }
                Console.WriteLine();
            }

Is something wrong with my query?  I tried a few queries and none of them returned any data.  The query that you see above does work with another MLS provider.  

Tony Manhollan

unread,
Dec 22, 2011, 10:00:13 AM12/22/11
to Majid Tahir, For discussion and help for and by the users of the libRETS C++ library
I think your field names are still mixed up, although I'm not sure why that resulted in an empty dataset rather than another error. But LIST_87 doesn't look like an Innovia fieldname. Perhaps that's one of the fields in the other system. Using SystemNames (i.e. with SetStandardNames(false)), you need to look at the metadata for each system and supply the SystemName of each field within that system. That goes for the ResourceId and ClassNames as well. ResidentialProperty is a ClassName in Innovia's system, but it's probably something different in the other one. You'll probably need to set up some variables for the values you supply to session.CreateSearchRequest if you intend to use that block of code for more than one system, but in any case you need to make sure those values are all consistent with the metadata for the system you're connecting to.

Tony

Majid Tahir

unread,
Dec 22, 2011, 10:46:27 AM12/22/11
to Tony Manhollan, For discussion and help for and by the users of the libRETS C++ library
Thanks Tony!

I have it working.  I just didnt have the right field name in the query which was causing a problem.  Here is the code that worked:

         SearchRequest searchRequest = session.CreateSearchRequest(
                "Property",
                "ResidentialProperty",
                "(ListDate=2009-02-01T00:00:00+)");
            searchRequest.SetStandardNames(false);            
            searchRequest.SetLimit(5);
            searchRequest.SetCountType(SearchRequest.CountType.RECORD_COUNT_AND_RESULTS);            
            SearchResultSet searchResults = session.Search(searchRequest);
            RetsMetadata metadata = session.GetMetadata();
            
            /*IEnumerable resources = metadata.GetAllResources();
            foreach (MetadataResource resource in resources)
            {
                dumpAllClasses(metadata, resource);
            }
            */

            Console.WriteLine("Record count: " + searchResults.GetCount());
            Console.WriteLine();
            IEnumerable columns = searchResults.GetColumns();
            while (searchResults.HasNext())
            {
                foreach (string column in columns)
                {
                    Console.WriteLine(column + ": " + searchResults.GetString(column));
                }
                Console.WriteLine();
            }

As you said, the key is to understanding what the GetMetaData call is for.  Using that you can understand how the field names are labeled for each MLS.  Thanks for the help everyone.  

M.Hassan Hojjati

unread,
Dec 26, 2019, 1:50:38 PM12/26/19
to LibRets Mirror
Hi All, Thanks for your responds, I have a simple problem that is I can connect to librets and search for listings, but it returns only 130 records. how can I download all records of 3800+ listings.

thanks in advance

Alfredo Duenas

unread,
Apr 2, 2020, 4:30:20 PM4/2/20
to LibRets Mirror
do you have any sample code? 
Reply all
Reply to author
Forward
0 new messages