Results 1 to 8 of 8
  1. #1
    Join Date
    Jun 2009
    Posts
    5

    Unanswered: how to accept TCP\IP remote connections to Postgresql

    Hi all,

    How to accept TCP\IP remote connections to Postgresql.? Is there any specific settings to accept. please advice.


    Plz Help


    Thanks
    Mohir

  2. #2
    Join Date
    Nov 2003
    Posts
    2,934
    Provided Answers: 12
    Check out your value for listen_address:

    http://www.postgresql.org/docs/8.3/static/runtime-config-connection.html#GUC-LISTEN-ADDRESSES

    it should be set to '*'

  3. #3
    Join Date
    Jun 2009
    Posts
    5
    I have already set listen_addresses = '*' and the port.
    but when i m making connections it is giving me error "Connect: Read from socket failed: Unable to read data from the transport connection: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond."

    the whole concept is like that
    i m using a Sphinx search C# Client API using code "http://iterat.ive.ly/index.php/2008/01/05/sphinx-search-c-net-client-api/"
    along with i have installed sphinx and postgresql DB and configured both on my web server.
    Sphinx is running through command prompt but when i m using the dotnet code it is giving me error mentioned above.


    Plz help

    Thanks
    Mohit

  4. #4
    Join Date
    Nov 2003
    Posts
    2,934
    Provided Answers: 12
    Quote Originally Posted by emaginat
    I have already set listen_addresses = '*' and the port.
    but when i m making connections it is giving me error "Connect: Read from socket failed: Unable to read data from the transport connection: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond."
    You should have told us in the first post.
    Why hold back important information?

    To me this sounds like a badly configured firewall somewhere.

    Can you connect using the Postgres tools (e.g. psql)?

  5. #5
    Join Date
    Jun 2009
    Posts
    5
    Hi,

    sorry for not posting it in the first post.

    It is connecting the postgresql DB but not getting any data from it using dotnet.


    more explanation of the error is

    I m using this code where i m getting error

    SphinxClient cli = new SphinxClient("localhost", 5433);
    //set the pagination params
    //(this is page 2, 40 per page, 10000 max)
    cli.SetLimits(40, 40, 10000);

    // define the query and index
    // ("*" means any index)
    int q;
    q = cli.AddQuery("100", "*");
    SphinxResult[] results = cli****nQueries();
    cli.GetLastError();
    cli.GetLastWarning();

    When it is running "SphinxResult[] results = cli****nQueries();" it is giving me the
    IOException "Connect: Read from socket failed: Unable to read data from the transport
    connection: A connection attempt failed because the connected party did not properly
    respond after a period of time, or established connection failed because connected host
    has failed to respond."

    internally it is calling the TcpClient Connect() method defined in the SphinxClient.cs
    file. after reading the "int version = sr.ReadInt32();" code line it going in the catch
    block and giving IO Exception

    private TcpClient Connect()
    {
    TcpClient sock;

    try
    {
    //sock = new Socket(_host, _port);
    //sock = new Socket(AddressFamily.InterNetwork, SocketType.Raw, ProtocolType.IPv4);
    sock = new TcpClient(_host, _port);
    sock.ReceiveTimeout = SPH_CLIENT_TIMEOUT_MILLISEC;



    }
    catch (Exception e)
    {
    _error = "connection to " + _host + ":" + _port + " failed: " + e.Message;
    return null;
    }

    NetworkStream ns = null;

    try
    {
    ns = sock.GetStream();
    int temp;
    temp = sock.Available;
    if (sock.Connected)
    {
    log lg = new log();
    lg.logEntry("data available");
    }
    BinaryReader sr = new BinaryReader(ns);
    BinaryWriter sw = new BinaryWriter(ns);

    //char[] buf = new char[1024];

    //if (size != 1)
    // throw new Exception("Connect: Could not read version number from searchd server");

    //int version = Convert.ToInt16(buf[0]);
    int version = sr.ReadInt32();


    if (version < 1)
    {
    sock.Close();
    _error = "expected searchd protocol version 1+, got version " + version;
    return null;
    }

    //sw.Write(VER_MAJOR_PROTO);
    }
    catch (IOException e)
    {
    _error = "Connect: Read from socket failed: " + e.Message;
    try
    {
    sock.Close();
    }
    catch (IOException e1)
    {
    _error = _error + " Cannot close socket: " + e1.Message;
    }
    return null;
    }
    return sock;
    }

  6. #6
    Join Date
    Nov 2003
    Posts
    2,934
    Provided Answers: 12
    Quote Originally Posted by emaginat
    Hi,

    sorry for not posting it in the first post.

    It is connecting the postgresql DB but not getting any data from it using dotnet.
    Sorry I have no experience with .Net
    Can you connect and retrieve data using psql?

  7. #7
    Join Date
    Jun 2009
    Posts
    5
    Hi

    Independently pgsql i can connect and retrieve data
    Alongwith sphinx i can get data through command prompt
    but when i m using dotnet it is showing me error

    Plz advice

    Thanks

  8. #8
    Join Date
    Jun 2009
    Posts
    5
    my problem is solved. it was due to a parameter seamless_rotate = 1. i have set it to 0 and re-installed the service.
    Now it works fine with dotnet code.

    Thanks all
    Mohit

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •