yunge / sphinx

Abandoned, please see https://github.com/plutov/sphinx
105 stars 51 forks source link

doRequest > just read 0 bytes into header! #19

Open hengfeiyang opened 8 years ago

hengfeiyang commented 8 years ago

send two query in same conn will occur this error: doRequest > just read 0 bytes into header!

like this:

cli := sphinx.NewClient().SetServer(sphinxIP, sphinxPort)
wds, err := cli.BuildKeywords(keyword, "content", false)
    var newKeyword []string
    for _, wd := range wds {
        if len([]rune(wd.Tokenized)) >=2 {
            newKeyword = append(newKeyword, wd.Tokenized)
        }
    }
    res, err := cli.Query(strings.Join(newKeyword, "|"), "content addcontent", "")
    if err != nil {
        return total, rows, err
    }

will return err:

doRequest > just read 0 bytes into header!

hengfeiyang commented 8 years ago

i found it, sphinx default is not persist connection, connection will close by server when done a query. so, you should close client conn when it is not persist connection, or use client.Open() to use persist connection.