If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > PostgreSQL > how to accept TCP\IP remote connections to Postgresql

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 06-25-09, 13:20
emaginat emaginat is offline
Registered User
 
Join Date: Jun 2009
Posts: 5
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
Reply With Quote
  #2 (permalink)  
Old 06-25-09, 14:40
shammat shammat is offline
Registered User
 
Join Date: Nov 2003
Posts: 2,407
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 '*'
Reply With Quote
  #3 (permalink)  
Old 06-26-09, 02:38
emaginat emaginat is offline
Registered User
 
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
Reply With Quote
  #4 (permalink)  
Old 06-26-09, 02:50
shammat shammat is offline
Registered User
 
Join Date: Nov 2003
Posts: 2,407
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)?
Reply With Quote
  #5 (permalink)  
Old 06-26-09, 03:33
emaginat emaginat is offline
Registered User
 
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;
}
Reply With Quote
  #6 (permalink)  
Old 06-26-09, 03:38
shammat shammat is offline
Registered User
 
Join Date: Nov 2003
Posts: 2,407
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?
Reply With Quote
  #7 (permalink)  
Old 06-26-09, 03:47
emaginat emaginat is offline
Registered User
 
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
Reply With Quote
  #8 (permalink)  
Old 06-26-09, 04:43
emaginat emaginat is offline
Registered User
 
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
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On