php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #59416 No results being returned
Submitted: 2010-09-13 14:54 UTC Modified: 2010-09-20 02:25 UTC
From: rich06 at gmail dot com Assigned:
Status: Closed Package: sphinx (PECL)
PHP Version: 5.3.2 OS: Mac OS X 10.5.8
Private report: No CVE-ID: None
 [2010-09-13 14:54 UTC] rich06 at gmail dot com
Description:
------------
I am trying to test Sphinx on my Mac development server (I am actually running PHP 5.3.3 however that version is absent from the selection list) and have installed the PECL extension to PHP. Sending a search query as follows:-

$s = new SphinxClient;
$s->setServer('localhost',6712);
$s->setMatchMode(SPH_MATCH_ANY);
$s->setMaxQueryTime(3);
$result = $s->query('foo');

Several results are obtained using the CLI search tool with the same search string;

The error returned by searchd is 'failed to send client protocol version'. This issue is discussed on the Sphinx site here -> http://www.sphinxsearch.com/forum/view.html?id=4919 and there is a fix described for the userland PHP API but I cannot see how to send the client protocol string using the PECL extension...




Reproduce code:
---------------
$s = new SphinxClient;
$s->setServer('localhost',6712);
$s->setMatchMode(SPH_MATCH_ANY);
$s->setMaxQueryTime(3);
$result = $s->query('foo');


Expected result:
----------------
Expect to get several results.

Actual result:
--------------
bool(false)

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-09-15 12:11 UTC] santiago739 at gmail dot com
What is a version number of your Sphinx server and 
libsphinxclient?
 [2010-09-15 14:39 UTC] rich06 at gmail dot com
Sphinx server is 0.9.9 and the libsphinxclient is the one that came with the server source code under the api directory.. following is from the .h file

// $Id: sphinxclient.h 2067 2009-11-13 23:23:06Z shodan $

HTH
 [2010-09-16 10:51 UTC] santiago739 at gmail dot com
Unfortunately, I can't reproduce this bug, everything works 
fine with the same versions. Do you face this issue every 
query or time to time?
If it possible could you reproduce this issue on the 
different platform?
It seems this is specific bug in libsphinxclient and it's 
related with your platform.
 [2010-09-16 17:01 UTC] rich06 at gmail dot com
OK I just tested on a Ubuntu 10.04 server with the same code as below:

$s = new SphinxClient;
$s->setServer('localhost',6712);
$s->setMatchMode(SPH_MATCH_ANY);
$s->setMaxQueryTime(3);
$result = $s->query('foo','getProductsByName');

var_dump($result);
var_dump($s);

produces:
bool(false)
object(SphinxClient)#1 (2) {
  ["error"]=>
  string(38) "failed to send client protocol version"
  ["warning"]=>
  string(0) ""
}
 [2010-09-17 12:19 UTC] santiago739 at gmail dot com
Are you sure that your searchd is running on localhost:6712?

If it's ok, please try to compile and run this code:

------------------------------------------
# test.c

#include <stdio.h>
#include <stdlib.h>

#include "sphinxclient.h"

int main ()
{
    sphinx_client *client;
    sphinx_result *res;
    sphinx_bool res_bool;
    const char *query, *index;
    
    query = "foo";
    index = "getProductsByName";

    client = sphinx_create(SPH_TRUE);
    if (!client) {
        printf("failed to create client\n");
        exit(1);
    }
    
    res_bool = sphinx_set_server(client, "localhost", 6712);
    if (!res_bool) {
        printf("failed to set server\n");
        exit(1);
    }
    
    res_bool = sphinx_set_match_mode(client, SPH_MATCH_ANY);
    if (!res_bool) {
        printf("failed to set match mode\n");
        exit(1);
    }
    
    res_bool = sphinx_set_max_query_time(client, 3);
    if (!res_bool) {
        printf("failed to set max query time\n");
        exit(1);
    }
    
    res = sphinx_query(client, query, index, NULL);
    if (!res) {
        printf("query failed: %s\n", sphinx_error(client));
        exit(1);
    } 
        
    printf("Query '%s' retrieved %d of %d matches.\n", 
        query, res->total, res->total_found);

    return 0;
}
------------------------------------------

$gcc -lsphinxclient -o test test.c
$./test
 [2010-09-19 16:54 UTC] rich06 at gmail dot com
I've closed this bug. The configuration file had searchd listening on another port... 

I'm very sorry to have wasted your time on this however the error message about 'missing client protocol versions' is IMO a bit misleading...

Thanks for your help with this...
 [2010-09-20 02:25 UTC] santiago739 at gmail dot com
It's just a copy of error message from linsphinxclinet. I 
agree that this is a bit misleading and perhaps it makes 
sense to open related bug on sphinxsearch.com.

Thank you for your interest in PECL.
 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Mon Dec 06 23:03:35 2021 UTC